color-thief icon indicating copy to clipboard operation
color-thief copied to clipboard

The result is different

Open Yuki-Zhao opened this issue 5 years ago • 1 comments

the first picture was from the website.( https://www.lokeshdhakar.com/projects/color-thief/) image

the second picture, i download the dist from github. image

i compared two pictures, the result is different. why ?

Yuki-Zhao avatar Oct 30 '19 08:10 Yuki-Zhao

https://github.com/lokesh/color-thief/blob/1c70277219c7bcfcd5ea4481cdb17136077c4fc1/src/color-thief.js#L89

It seems that it is caused by the wrong number of pixels obtained here. The size here is the actual size displayed by the picture rather than the original size. Therefore, the extracted color will change according to the width of the image container.

Should it be changed to this? @lokesh

const pixelCount = image.naturalWidth * image.naturalHeight;

u3u avatar Apr 22 '20 06:04 u3u