import CoreGraphics
import UIKit

enum ImageQualityPreset {
    case low, middle, high

    var compressionQuality: CGFloat {
        switch self {
        case .low: return 0.3
        case .middle: return 0.6
        case .high: return 1.0
        }
    }

    var scale: CGFloat {
        switch self {
        case .low: return 0.3
        case .middle: return 0.6
        case .high: return 1.0
        }
    }
}

extension UIImage {
    func resized(to scale: CGFloat) -> UIImage? {
        let newSize = CGSize(width: self.size.width * scale, height: self.size.height * scale)
        let renderer = UIGraphicsImageRenderer(size: newSize)
        return renderer.image { _ in
            self.draw(in: CGRect(origin: .zero, size: newSize))
        }
    }
}
