Calculation of fixed background colors suitable fro transparent image

17 views Asked by At

I really have a problem, where i don't know how to solve it.

I'm using python at the moment, but this should not matter for this case.

I have got a list of fixed background colors and I've got an transparent image. Now I want to calculate, which background color would be suitable for the transparent image. The transparent image can include text or colourful drawings and it's important that we dont put dark blue text on a black background for expample.

What would be a good solution for this issue?

background_colors = {
    "asphalt": "#3f3e3c",
    "baby_blue": "#8fb8db",
    "black": "#000000",
    "cranberry": "#6e0a25",
    "heather_grey": "#acb0b3",
    "green": "#006136",
    "yellow": "#f0e87b",
    "navy": "#15232b",
    "olive": "#4a4f26",
    "orange": "#FF5C39",
    "pink": "#f8A3BC",
    "purple": "#514689",
    "red": "#b71111",
    "royal": "#1c4086",
    "white": "#ffffff"
}

I tried to generate a palette with ColorThief and then putting it in a CIELab Colorspace and calculating the deltas. But still we have contrast issue etc. A friend of mine told me to use HSV.

And also transparent pixels make a problem, because they will often be recognized as black.

0

There are 0 answers