Answer the question
In order to leave comments, you need to log in
How to determine the color that can be used to make an inscription on the image so that it is clearly visible?
Good day. Faced such task. The user uploads an image, the program writes text on it, and returns the image with the text to the user. The question is - how to choose a color that will be clearly visible in the image? Well, i.e. if the image is bestin.ua/static/uploads/news/16_05_12/e282595eb6f... , then we must write the text in white, because black will be hard to see, and if this is t1.moskva.fm/uimg/artists/source/c2/c206c1c8348cd4... , then white text is completely out of topic. Please tell me the solution Thank you in advance
Answer the question
In order to leave comments, you need to log in
There is such a thing as a color wheel. The most contrasting color to the given one lies through 180 degrees.
Here is a visual demonstration
More correct - to look for the most distant point from the current one in the RGB cube (according to the laws of geometry, this will always be the vertex).
invR = (1 - (R div 128))*255
invG = (1 - (G div 128))*255
invB = (1 - (B div 128))*255
It is best seen when a contour is made around the letters in a contrasting color to the text, with this method the image can be arbitrarily colorful.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question