Pailead

1.4.1

A palette generating and extraction Swift library for macOS, iOS, and Linux
pducks32/Pailead

What's New

2019-05-12T10:17:40Z
  • Adds Carthage support
  • Fix: Crash on empty VBoxs where average causes division by zero.

Pailead

Version License Platform

Pailead works just like the Palette library on Android and other tools like node-vibrant but is completely written in Swift and optimized for macOS and iOS.

Installation

Pailead is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "Pailead"

Usage

Extracting Palette

All images are resized to 1000 pixels to speed up extraction, but don't worry this hasn't been shown to degrade the quality of the palette.

let image = <#Image#>
Pailead.extractPalette(from: image) { palette in
<#Do Something with Palette#>
}

Palette Swatches

The generated palette generates useful swatches to use in your UI or as a loading background perhaps. All swatches are actual colors found in the MMCQ calculation though it will generate some if no suitable ones can be found. These are:

  • Muted Swatch (middle range luma and low saturation)
  • Dark Muted Swatch (low range luma)
  • Light Muted Swatch (high range luma)
  • Vibrant Swatch (middle range luma and high saturation)
  • Dark Vibrant Swatch (low range luma)
  • Light Vibrant Swatch (high range luma)

How it works

Modified Mean Cut Quantization

That's a big word. The image's pixels are grouped and counted. Then they are laid out in RGB space. From there the quantizer finds RGB boxes that encapsulate the pixels equally. From these boxes the average color is generated and then sorted by how common it is in the image.

Todo

  • Switch to swatches
  • Add palette
  • Paralleize pixel extraction
  • Add more performance tests
  • Make better docs with example uses
  • Optimize processing loop
  • Add support for other clustering algorithms

Name

If palette is pronounced pa-let then Pailead is pronounced pa-lid.

The word comes from the Irish word paileƔd meaning palette which is what this library extracts.

Author

Description

  • Swift Tools 4.0.0
View More Packages from this Author

Dependencies

  • None
Last updated: Wed Aug 31 2022 15:00:04 GMT-0500 (GMT-05:00)