-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Description
Hey!
Found a bug for the following function:
extension UIImage {
func getDominantColors(with minCount: Int = 0) -> [UIColor]? {
var resultColors: [UIColor]?
// Try With PNG Data
if let pngData = pngData(),
let pngImage = UIImage(data: pngData),
let colors = try? pngImage.dominantColors(with: .best, algorithm: .iterative) {
if colors.count >= minCount {
return colors
} else {
resultColors = colors
}
}
// Try With JPEG Data
if let jpegData = jpegData(compressionQuality: 1),
let jpegImage = UIImage(data: jpegData),
let colors = try? jpegImage.dominantColors(with: .best, algorithm: .iterative) {
if colors.count >= minCount {
return colors
} else {
resultColors = colors
}
}
// Try With Original Image
if let colors = try? dominantColors(with: .best, algorithm: .iterative) {
if colors.count >= minCount {
return colors
} else {
resultColors = colors
}
}
if let colors = try? dominantColors() {
if colors.count >= minCount {
return colors
} else {
resultColors = colors
}
}
return resultColors
}
}
When the following image is added as input parameter, crash inside ColorKit happened:

terribleben
Metadata
Metadata
Assignees
Labels
No labels
