Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Crash with plain white image - .get_color(quality=1) #215

Open
LuccaGarcia opened this issue Sep 4, 2021 · 3 comments
Open

Crash with plain white image - .get_color(quality=1) #215

LuccaGarcia opened this issue Sep 4, 2021 · 3 comments

Comments

@LuccaGarcia
Copy link

Using ColorThief to return the dominant color of a white image raises an exception

Code:
image

Exception happens at line four:
image

Image used:
white

Other colors do not seam to cause the same error

@yankovichv
Copy link

Same problem :(

@AyatoKirishima
Copy link

Same problem here ✨

@AyatoKirishima
Copy link

A try catch in the js file solved it for me (i pushed the hex code into my array aaaand problem solved)

 try {
        rgbColors = colorThief.getColor(element);
        console.log(rgbColors);
        console.log(rgbColors[0]);
        console.log(rgbColors[1]);
        console.log(rgbColors[2]);

        let result = rgbToHex(rgbColors[0], rgbColors[1], rgbColors[2]);

        console.log("Le résultat en hexa est : " + result); // #0033ff
        colorsArray.push(result);
        console.log(colorsArray);


    } catch (error) {
        console.log(error);
        colorsArray.push("#ffffff");
    }

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

4 participants