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

Remove alpha channel from transparent images #13

Merged
merged 1 commit into from
Oct 22, 2024
Merged

Conversation

bb
Copy link
Contributor

@bb bb commented Oct 2, 2024

This PR removes the alpha channel from transparent images. Transparency is not supported by blurhash, see woltapp/blurhash#100.

The pixels array should have chunks of 3 bytes per pixel, but images which have an alpha channel (e.g. png files) have 4 bytes per pixel. This is also verified in Gargron/blurhash@3d8a39c since version 0.1.8 which was released last week.

fixes

This PR fixes #12.

possible improvements

The flatten method used here takes an optional argument background:. Adding this and making it configurable for users of this plugin would allow configuring a different background color than the default (white).

alternatives

Users of this plugin might alternatively consider migrating to thumbhash if real transparency is needed.

@renchap renchap merged commit 1580cc7 into renchap:master Oct 22, 2024
0 of 5 checks passed
@renchap
Copy link
Owner

renchap commented Oct 22, 2024

Thanks a lot, it indeed fixes the issue, and avoids a crash when running against the latest blurhash version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Uploading .png image don't produce expected effect correctly
2 participants