Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Logo background contrast bw images #481

Merged
merged 4 commits into from
Feb 23, 2024

Conversation

ajayadav09
Copy link
Contributor

@ajayadav09 ajayadav09 commented Feb 22, 2024

Used canvas to render and read image data pixels. calculated average color value and if the overall contrast value is more than 155, assuming the image is on the whiter side, the background will be black which solves the issue of png images blending with the background.

ref:
https://stackoverflow.com/questions/2541481/get-average-color-of-image-via-javascript
https://stackoverflow.com/questions/3942878/how-to-decide-font-color-in-white-or-black-depending-on-background-color
https://stackoverflow.com/questions/596216/formula-to-determine-perceived-brightness-of-rgb-color

@ajayadav09 ajayadav09 self-assigned this Feb 22, 2024
@ajayadav09 ajayadav09 added enhancement New feature or request WIP PR is a Work in Progress and not ready for review. labels Feb 22, 2024
@ajayadav09 ajayadav09 marked this pull request as ready for review February 22, 2024 13:22
@ajayadav09 ajayadav09 added Code Review The PR is in Code Review and removed enhancement New feature or request WIP PR is a Work in Progress and not ready for review. labels Feb 22, 2024
@arunshenoy99 arunshenoy99 merged commit c88b8a4 into trunk Feb 23, 2024
4 of 11 checks passed
@arunshenoy99 arunshenoy99 deleted the logo-background-contrast-bw-images branch February 23, 2024 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Review The PR is in Code Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants