t28hub / auto-palette-ts

🎨 Extract prominent color palette from your image automatically.
MIT License
10 stars 2 forks source link

Error extracting color from image #301

Open Fox333-Lab opened 5 months ago

Fox333-Lab commented 5 months ago

Hi, i am getting the below issue when trying extract colors from image

image

below is line of code causing the issue:

let file = e.target.files[0];
const reader = new FileReader();

reader.readAsDataURL(file);
reader.onload = (e: any) => {
setImage(e.target.result);
};

const palette = Palette.extract(image);  /* this line is causing the issue */

Note: Using NextjJS 14.1.2

Thank you in advance

n-ce commented 4 months ago

https://github.com/t28hub/auto-palette-ts/blob/df91b4e314bd7b4dc52bd764161352e9996fe5fe/README.md?plain=1#L22

It does not support image url.

ginestah commented 1 week ago

Hi, i am getting the below issue when trying extract colors from image

image

below is line of code causing the issue:

let file = e.target.files[0];
const reader = new FileReader();

reader.readAsDataURL(file);
reader.onload = (e: any) => {
setImage(e.target.result);
};

const palette = Palette.extract(image);  /* this line is causing the issue */

Note: Using NextjJS 14.1.2

Thank you in advance

You should be able to convert it by first creating an html img element with the image url as the src.