80d3c08a93
- Move to global objects for files and validation - Only write changed files - Check images for changes before scaling - Simplify code
25 lines
498 B
Swift
25 lines
498 B
Swift
import Foundation
|
|
|
|
struct ImageOutput: Hashable {
|
|
|
|
let source: String
|
|
|
|
let width: Int
|
|
|
|
let desiredHeight: Int?
|
|
|
|
var ratio: Float? {
|
|
guard let desiredHeight = desiredHeight else {
|
|
return nil
|
|
}
|
|
return Float(desiredHeight) / Float(width)
|
|
}
|
|
|
|
func hasSimilarRatio(as other: ImageOutput) -> Bool {
|
|
guard let other = other.ratio, let ratio = ratio else {
|
|
return true
|
|
}
|
|
return abs(other - ratio) < 0.1
|
|
}
|
|
}
|