nystudio107 / craft-imageoptimize

Automatically create & optimize responsive image transforms, using either native Craft transforms or a service like Imgix, with zero template changes.
https://nystudio107.com/plugins/imageoptimize
Other
235 stars 36 forks source link

Feature Request: Contrast Calculation #147

Closed joshuabaker closed 5 years ago

joshuabaker commented 5 years ago

A nice addition to the dominant color calculation would be to color contrast for each, or overall (i.e. using the YIQ color space).

This could help identify if any accompanying overlay text should be dark or light.

khalwat commented 5 years ago

I think a way to do it would be to convert the colors to HSL, and then average the lightness of the dominant colors.

I'd then make this available via a property on the image, so you can decide what level of lightness determines it being light or dark.

khalwat commented 5 years ago

Implemented via https://github.com/nystudio107/craft-imageoptimize/commit/0fe4ee4a8372a1ae2fb277fa1a8b55e18b2eef91

joshuabaker commented 5 years ago

Thanks!