
"The last version improves the library quite a bit, adding TypeScript definitions but also a set of features that can directly help with creating text that contrasts well with the image. After examining an image, it has a basic isDark variable that can be checked, two contrast variables for white and black, and best of all, a simple textColor value that provides the best suggestion for what text color should be used to provide contrast."
"Color Thief examines an image and can tell you the dominant color as well as the five most used colors. The text-shadow absolutely helps with readability on busy images, but additional contrast detection features now make it easier to ensure text remains legible over varied image backgrounds."
Color Thief, a JavaScript library that extracts dominant and secondary colors from images, received a major update after 14 years. The new version adds TypeScript definitions and accessibility features designed to improve text contrast over images. Key additions include an isDark variable to detect image brightness, contrast measurements for white and black text, and a textColor property that recommends the best text color choice. The library analyzes images to determine whether light or dark text provides better readability. While the textColor suggestion isn't perfect for all scenarios, it significantly simplifies the process of ensuring readable text overlays on images.
Read at Raymondcamden
Unable to calculate read time
Collection
[
|
...
]