Download the PHP package aryehraber/statamic-color-extractor without Composer
On this page you can find all versions of the php package aryehraber/statamic-color-extractor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aryehraber/statamic-color-extractor
More information about aryehraber/statamic-color-extractor
Files in aryehraber/statamic-color-extractor
Package statamic-color-extractor
Short Description Extract colors from images.
License MIT
Homepage https://github.com/aryehraber/statamic-color-extractor
Informations about the package statamic-color-extractor
Color Extractor
Extract colors from images.
This addon provides a new Modifier which takes an image asset and returns its dominant (or average) color as a HEX value.

Installation
Install the addon via composer:
Publish the config file:
Usage
Simply add the color modifier to an image asset to output the HEX color value:
Example
By default, the underlying color extractor tries to find the most dominant color in the image, however, results can vary (see example screenshot below). Therefore, an average param can be passed in to instead find the average color found in the image:
The default type can be changed to average instead via the config file, which opens up a dominant param:
The contrast parameter will try to find a color from the image palette with the most contrast to the dominant color:
Dominant vs. Average vs. Contrast
Example screenshot to demonstrate the difference between the color extraction strategies:

Manually Editing Colors
Whenever a color is extracted from an image, it's added to the asset's meta data. This means you can manually override it by adding the following fields to your assets.yaml blueprint:
Extract Command
By default, colors are extracted on-demand when the modifier is first used on an image. This can slow down page loads with many images.
To improve performance, pre-generate color data using the commands below.
Note: The command will skip assets that already have color data unless --force is used.
Auto Extract on Asset Upload
When auto_extract is enabled in the config file (see Installation), colors will automatically be extracted when new images are uploaded. This extracts all 3 color types (dominant, average, contrast) and is useful to ensure there's no slow down on first page load.
Credits
Inspiration: https://github.com/sylvainjule/kirby-colorextractor
Color Extractor: https://github.com/thephpleague/color-extractor
All versions of statamic-color-extractor with dependencies
statamic/cms Version ^6.0
intervention/image Version ^3.0
league/color-extractor Version ^0.4