Automatically select the card background color according to the color tone of the image

Hello friends,
I have a point in my development, I’m waiting for your help.

As you can see in the following image, the description field of the image is automatically created according to the main color of the image. How can I do that ?

Draw the image onto a canvas and parse the pixel-colors and see which color is strongest (or generate an average)

How can I do that? Can you give me details? (code etc.)

You might have a look at Vibrant.js to get the prominent colours of an image but I haven’t used it myself. The API of Vibrant seems pretty straight forward and includes a simple example.

1 Like

Yes that one would do it…

Thanks :smiley: ı’m try now. ı hope it’s works.