Color Thief won’t work …

前端 未结 4 1947
南笙
南笙 2020-12-18 04:42

I’d like to use Color Thief, a script which allows you to extract the dominant color of an image.

Unfortunately I’m not able to get the code to work. I’d like the do

4条回答
  •  轮回少年
    2020-12-18 05:10

    I struggled for a few hours to get color-thief to work. In the end it was the tiny addition of [0] to point to the first array element:

    
    
    myImage = $('#theimage');
    colorThief = new ColorThief();
    color = colorThief.getColor(myImage[0]);
    red = color[0];
    green = color[1];
    blue = color[2];
    

提交回复
热议问题