-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
Failing to detect alpha channel in JPEG2000 files #1449
Comments
Can you share an image that can be used to reproduce this? |
@dlemstra of course, my sample files I can't share on the internet, but I can send one another way if that is possible. |
I didn't see anything in your post that would say that your image was private? You could share it by email? It can be found on my profile page. p.s. MagickViewer hasn't been updated in ages and I am considering to archive it and tell people to move to ImageGlass. |
Sent - thankyou! And yes, I was just using it as a test to prove the file itself wasn't broken since it was a convenient viewing application. :) |
We made some changes to ImageMagick recently when reading jpeg2000 images. There is a marker in the channel that specifies if it is an alpha channel or not. And it turns out that for your image the 4th channel is a meta channel instead of an alpha channel. And the current version of ImageMagick no longer reads that channel. I just pushed a patch to add support for reading that extra channel again. In the next version of Magick.NET you will be able to read that channel again but it won't be marked as an alpha channel. What do you see in other viewers that makes you think that this image has an alpha channel? |
Interesting; the file definitely is intended to have a alpha channel (it's a 3D texture), but it appears that whatever tool is writing the file is doing so improperly (I'm actually not surprised, most J2K libraries are not ... great). I've opened it in a few other JPEG2000 libraries which do see it as a alpha channel (OpenJpeg, CSJ2K) but that may be them misinterpreting the spec, or just naively assuming 4 channels = RGBA. Thank you so much for investigating and adding that patch. |
We could introduce an option that would always force the 4th channel to be an alpha channel? And then add this to the |
Yeah, that would be fantastic. |
The next release will have an |
Very much appreciated - one last question from me, is there a beta version I can help test with? |
I was able to add some unit tests for this locally that use an that I created with the same alpha flag set to zero as in the image that your provided. But you can probably test this yourself with one of the build artifacts after I have updated ImageMagick in this repository in a couple days. |
…a 2nd or 4th channel is an alpha channel (#1449).
Magick.NET version
13.3.0 Q16-AnyCPU
Environment (Operating system, version and so on)
Amazon Linux 2
Description
JPEG2000 files containing alpha channels no longer correctly set the image.hasAlpha attribute correctly.
The current version of MagickViewer correctly saves a PNG containing the alpha channel of the same test file.
Steps to Reproduce
In the following code (it needs to handle multiple container types, hence the layering) hasAlpha no longer returns true, where previously it would.
Additionally, on further inspection, it also appears ChannelCount is now 3, not 4.
Environment: Amazon Linux 2, .NET Core 7 using NativeAOT.
The text was updated successfully, but these errors were encountered: