color-thief
color-thief copied to clipboard
The result is different
the first picture was from the website.( https://www.lokeshdhakar.com/projects/color-thief/)
the second picture, i download the dist from github.
i compared two pictures, the result is different. why ?
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;