Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

Commit

Permalink
Merge pull request #54 from jathu/performance-improvement
Browse files Browse the repository at this point in the history
2x Performance Improvement
  • Loading branch information
jathu committed Jan 6, 2018
2 parents b63c881 + 9753403 commit a712c08
Show file tree
Hide file tree
Showing 64 changed files with 1,235 additions and 402 deletions.
41 changes: 22 additions & 19 deletions README.md
@@ -1,11 +1,13 @@
# UIImageColors

iTunes style color fetcher for UIImage. This is based on [Panic's OS X ColorArt](https://github.com/panicinc/ColorArt/) for iOS Swift.

In other words, it fetches the most dominant and prominent colors.
iTunes style color fetcher for UIImage. It fetches the most dominant and prominent colors.

![preview](preview.png)

## Installation

You can either directly copy [UIImageColors.swift](Sources/UIImageColors.swift) into your project *or* you can use CocoaPods: [UIImageColors](https://cocoapods.org/pods/UIImageColors).

## Example

Asynchronous example:
Expand Down Expand Up @@ -38,27 +40,19 @@ detailLabel.textColor = colors.detail
getColors() -> UIImageColors
```

Returns a `UIImageColors` object. The sample image is rescaled to a width of 250px and the aspect ratio height. This blocks the main thread.

```swift
getColors(scaleDownSize: CGSize) -> UIImageColors
getColors(quality: UIImageColorsQuality) -> UIImageColors
```

Returns a `UIImageColors` object with a custom image rescale. Use smaller sizes for better performance at the cost of quality colors. Use larger sizes for better color sampling and quality at the cost of performance. This blocks the main thread.

```swift
getColors(completionHandler: (UIImageColors) -> Void) -> Void
getColors(_ completion: (UIImageColors) -> Void) -> Void
```

Passes a `UIImageColors` object into the closure. The sample image is rescaled to a width of 250px and the aspect ratio height. This runs on the background thread.

```swift
getColors(scaleDownSize: CGSize, completionHandler: (UIImageColors) -> Void) -> Void
getColors(quality: UIImageColorsQuality, _ completion: (UIImageColors) -> Void) -> Void
```

Passes a `UIImageColors` object into the closure, with a custom image rescale. Use smaller sizes for better performance at the cost of quality colors. Use larger sizes for better color sampling and quality at the cost of performance. This runs on the background thread.

## UIImageColors Object
## UIImageColors Objects

`UIImageColors` is struct that contains four different `UIColor` variables.

Expand All @@ -71,13 +65,22 @@ public struct UIImageColors {
}
```

## Installation
`UIImageColorsQuality` is a enum with four different qualities. The qualities refer to how much the original image is scaled down. `Lowest` implies smaller size and faster performance at the cost of quality colors. `High` implies larger size with slower performance with good colors. `Highest` implies no downscaling and very good colors, but it is very slow.

You can either directly copy [UIImageColors.swift](Sources/UIImageColors.swift) into your project *or* you can use CocoaPods: [UIImageColors](https://cocoapods.org/pods/UIImageColors).
The default is set to `high`.

```swift
public enum UIImageColorsQuality: CGFloat {
case lowest = 50 // 50px
case low = 100 // 100px
case high = 250 // 250px
case highest = 0 // No scale
}
```

## License

The [license](https://github.com/jathu/UIImageColors/blob/master/LICENSE) is provided in the project folder. Please also refer to Panic's [original license](https://github.com/panicinc/ColorArt/#license).
The [license](https://github.com/jathu/UIImageColors/blob/master/LICENSE) is provided in the project folder. This is based on Panic's [OS X ColorArt](https://github.com/panicinc/ColorArt/#license).

------
June 2015 - Toronto
June 2015 - Toronto

0 comments on commit a712c08

Please sign in to comment.