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

[FR] hasTransparency / hasAlpha Method #285

Open
davidhellmann opened this issue Nov 24, 2019 · 2 comments
Open

[FR] hasTransparency / hasAlpha Method #285

davidhellmann opened this issue Nov 24, 2019 · 2 comments

Comments

@davidhellmann
Copy link

Hey,

like we write in Discord. Maybe it’s possible to add a Method to check if the Image has some Transparency.

EEAF13DE-84FB-4A49-A8AE-38E83052E6C0

Thanks!

@aelvan
Copy link
Owner

aelvan commented Dec 6, 2019

This probably wasn't as easy as I thought... ;) I was thinking that Imagick's getImageAlphaChannel would give me this, but it returns true if there is an alpha channel, and not whether or not there actually is any transparent pixels in the image. The way I understood your usecase, I think that's maybe what you were after? The way getImageAlphaChannel works, I think you'll get approximately the same result by just checking the file extension.

To figure out if there are actual transparent pixels, it looks like the only solution is to loop over all the picture's pixels and analyze the color value. That sounds like a lot of wasted resources (cpu cycles), but...

Let me know if my understanding of your usecase was correct, or if the alpha channel thing would be useful.

@davidhellmann
Copy link
Author

The loop over the pixels sounds not really good for performance, thats right.
Yes, I have to find out if the image has some transparent pixels but when this is a big performance issue it's fine to go with the file extension. But of course, png means not transparency that's my only problem.

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

No branches or pull requests

2 participants