Color Thief won’t work …

前端 未结 4 1951
南笙
南笙 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:32

    Try this based on your code and a mix of everyone's answers. You need to wait for the image to load before using Color Theif. The color for photo1.jpg should be [125, 190, 193]

    Thanks @Shadow Wizard and @ejegg

    See Official way to ask jQuery wait for all images to load before executing something

    EDIT: Ok use this fiddle which works http://jsfiddle.net/bgYkT/

    
    
        
        
    
    
        
        
    
    
        
    
    
    
    
    
    
        
    
        

提交回复
热议问题