Bug 93468

Summary: Poppler can't display transparent JPEG 2000 images
Product: poppler Reporter: Tristan Miller <psychonaut>
Component: generalAssignee: poppler-bugs <poppler-bugs>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: psychonaut
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:
Attachments: PDF including several test images
PNG showing how Attachment 120624 is rendered
handle SMaskInData = 0 for JPX encoded images

Description Tristan Miller 2015-12-21 14:40:07 UTC
Created attachment 120624 [details]
PDF including several test images

Poppler seems to properly decode most non-transparent JPEG 2000 images in PDFs.  However, transparent JPEG 2000 images are distorted beyond recognition.

Attached is a PDF with five images:

1. A transparent bitmap
2. #1 converted into a transparent JPEG 2000 with OpenJPEG
3. #1 converted into a transparent JPEG 2000 with GraphicsMagick (no idea how it does this; possibly it just invokes OpenJPEG)
4. #1 converted into a non-transparent JPEG 2000 with GraphicsMagick
5. #1 converted into a non-transparent JPEG 2000 with Jasper

All the images display fine except for the two transparent JPEG 2000s.
Comment 1 Tristan Miller 2015-12-21 14:41:05 UTC
Created attachment 120625 [details]
PNG showing how Attachment 120624 [details] is rendered

The attached PNG file shows how Attachment 120624 [details] is rendered by Okular, Evince, Gimp, etc.
Comment 2 Thomas Freitag 2016-03-11 15:27:50 UTC
Mmmh, Tristan, image 2 and 3 contain an alpha channel and are therefore not handled correctly by poppler. BUT: where in case of image 1 an image object and a corresponding smask is set in the PDF and so the transparency remains, the parameter SMaskInData is not set for image 2 and 3. The PDF spec says that in this case the alpha channel in the jpx encoded data should be ignored (Default: SMaskInData = 0).
So these images will remain non-transparent and look like image 5.
I will upload a patch that handles SMaskInData = 0 correctly but still will not display correctly if SMaskInData is 1 or 2. This would mean more effort also in the output devices to handle that correctly, so I will not implement that before I get some good examples.
Comment 3 Thomas Freitag 2016-03-11 15:30:47 UTC
Created attachment 122230 [details] [review]
handle SMaskInData = 0 for JPX encoded images

This patch fixes it in case of SMaskInData = 0
Comment 4 Albert Astals Cid 2016-03-12 02:52:25 UTC
Pushed

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.