Simple kirby panel hook that will extract the most dominant color for a given image and store it in the file’s metadata on the color field as an hex value eg: #fefefe.
This is useful for example when lazyloading images, Google uses the same technique in Google Images.
The hook will fire for any image you upload or replace in the panel.
Very smart! Thanks for sharing! I saw this yesterday and was starting to wonder how I could port a similar functionality to Kirby: https://github.com/benhowdle89/grade
And you sir just made it (well very similar idea at least). Thanks
Thanks a lot, that’s a superb idea!
Now I feel silly handpicking all the colors for all the references of a recent client: http://www.zieflekoch.de/referenzen
Is there a way to override the field? If the dominant color is not as fitting or beautiful?
Hi
I’m very interested to run this plugin, but it doens’t work with me…I’m running with Kirby 2.2.3 and when I’m dezipping the rep. into site/plugins/, it makes a blank page everywhere. This change when I rename the folder to dominantX for example. Every time I name the folder “dominantcolor”, like the PHP, it’s bugging. Do you know what’s the poblem ??
(I precise that I did the installation of color-picker and it’s work very well)
I guess it’s been solved since then, but one can add that with v.2.2.3 (or < 2.3.2), the multiple hooks setting won’t work, the field will simply not update :
@wilhearts, many thanks for this, works like a charm !
When used for image placeholders, though, I find it to have a tendency to pick the most saturated color instead of the most ‘quantitatively present’ one (had this issue with a more than grey-ish picture with a very small blue part, the blue got picked). Decreasing the thumb’s size helped. To get an average color of the whole image, it can even be switched to :
hey guys, this is plugin is very cool! Unfortunately I am having trouble getting it to work. I get “The color field is missing. Please add it to your installed fields or remove it from your blueprint” when clicking the image. I guess it’s something with the field not fully “provided”. Just for testing I also copied the dominantcolor folder to fields and get “Cannot declare class ComposerAutoloaderInit088afd70e9b149c67d8f73cf2b25d4b7, because the name is already in use” so the composer autoload seems to work if I understand this correctly. Thanks guys! -Alex