postcss-get-color icon indicating copy to clipboard operation
postcss-get-color copied to clipboard

Vibrant variant not always available

Open Kronuz opened this issue 6 years ago • 3 comments

Not all variants are always available for all images, making this plugin throw error about variant not available some times for some images (Muted for example)

https://github.com/akfish/node-vibrant/pull/50

Kronuz avatar Sep 11 '17 20:09 Kronuz

Hi @Kronuz! Currently, the plugin takes the first color in palette when variant is not available, and shows a warning message. What do you think it should be the ideal behavior in this case?

ismamz avatar Sep 15 '17 11:09 ismamz

Well, the thing is if no color is found, get-color() shows me an error and dies. For example, I was requesting get-color("image.jpeg", Muted) and I got the error in the console saying undefined didn' have something or such, and compilation died; the only colors available there in such object were Vibrant variations, after closer inspection.

What I think it should do is probably on the vibrant's side. It should always return colors for every swatch; no matter if there's no exact matching color; it could return the closest (which some times would include non-conformant/ugly-looking colors for the palettte), or better, from the closest it could saturate/desaturated and/or darken/lighten to match a swatch; that way I'd know a color for the palette variation I need would always be available

Kronuz avatar Sep 15 '17 13:09 Kronuz

Ok. I agree that throw an error is not the ideal behavior, this is why I added a warning and returned the first value in palette, avoiding leave an empty value.

As you say, this problem should be solved on Vibrant's side.

If you have another suggestion, I would like to hear it!

ismamz avatar Sep 15 '17 21:09 ismamz