https://github.com/623637646/uiimagecolorratio
A tool to calculate the color ratio of UIImage in iOS.
https://github.com/623637646/uiimagecolorratio
color colors ios ratio ratio-calculator uicolor uiimage
Last synced: about 1 year ago
JSON representation
A tool to calculate the color ratio of UIImage in iOS.
- Host: GitHub
- URL: https://github.com/623637646/uiimagecolorratio
- Owner: 623637646
- License: mit
- Created: 2021-05-04T08:00:29.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-06-16T13:22:58.000Z (about 5 years ago)
- Last Synced: 2025-03-21T01:51:12.385Z (about 1 year ago)
- Topics: color, colors, ios, ratio, ratio-calculator, uicolor, uiimage
- Language: Swift
- Homepage:
- Size: 202 KB
- Stars: 38
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# UIImageColorRatio
A tool to calculate the color ratio of UIImage in iOS.

# How to use UIImageColorRatio
Get the color ratio of UIImage.
```swift
let image = ... // your UIImage.
let result = image.calculateColorRatio(deviation: 10) // "deviation": The deviation on pixels, It's from 0 to 255. Bigger deviation means less kind of colors.
```
Get the effected image.
```
let image = ... // your UIImage.
let result = image.calculateColorRatio(deviation: 10)
let effectedImage = image.effectedImage(colorRatioResult: result)
```
# How to integrate UIImageColorRatio?
**UIImageColorRatio** can be integrated by [cocoapods](https://cocoapods.org/).
```
pod 'UIImageColorRatio'
```
Or use Swift Package Manager. SPM is supported from 1.2.0.
# Performance
You can see the duration of the calculation from `calculateColorRatio` API's result.
You **MUST** use **Release build configuration** to see the performance. Because swfit is very slow on Debug build configuration.

Refer here: https://stackoverflow.com/q/61998649/9315497
# Requirements
- iOS 10.0+
- Xcode 11+
- Swift 5.0+