You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am expecting that transparent images such as pngs, gifs or webp that contain an alpha channel would return 1. Anything opaque, such as any jpg would return null.
Actual behavior
It will always return 1. Regardless of whether or not it has an alpha channel, or if its transparent or not.
Having looked at this for a while now I'm wondering if this might be a bug. Loading imagemagick directly, within the module, and running its getImageAlphaChannel() method returns the expected result.
NOTE: If I downgrade to Craft CMS 4.3.5 I do not see this issue.
Thanks for the report! We've tracked this down to an issue in the underlying Imagine library. It looks like in version 1.3 they introduced a change that will result in isTransparent returning true when $palette->supportsAlpha() is true (which happens to be the case for the RGB palette that most things will use).
I've opened an issue over there but I'm also going to see if we have a good way to work around it. I just wanted to provide an update for future travelers (and before I forget the result of our digging)
This one was quite the journey! Thanks to the library authors I've opened a PR that replaces the isTransparent value with something more reliable for the next 3 and 4 releases.
What happened?
Description
Whilst attempting to use isTransparent in a Craft module, I'm seeing true returned for all images.
Steps to reproduce
In order to access the property in twig, I have a module set up something like this:
The isTransparent property can then be accessed in twig via something like:
Expected behavior
I am expecting that transparent images such as pngs, gifs or webp that contain an alpha channel would return 1. Anything opaque, such as any jpg would return null.
Actual behavior
It will always return 1. Regardless of whether or not it has an alpha channel, or if its transparent or not.
Having looked at this for a while now I'm wondering if this might be a bug. Loading imagemagick directly, within the module, and running its
getImageAlphaChannel()
method returns the expected result.NOTE: If I downgrade to Craft CMS 4.3.5 I do not see this issue.
See attached module as example of my test: imagehelpers-module.zip
Craft CMS version
4.3.6.1
PHP version
8.1.12
Operating system and version
MacOS with DDev
Database type and version
No response
Image driver and version
imagick 3.7.0 / gd 2.3.3
The text was updated successfully, but these errors were encountered: