Bug 93468 - Poppler can't display transparent JPEG 2000 images
Summary: Poppler can't display transparent JPEG 2000 images
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-21 14:40 UTC by Tristan Miller
Modified: 2016-03-12 02:52 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
PDF including several test images (701.03 KB, text/plain)
2015-12-21 14:40 UTC, Tristan Miller
Details
PNG showing how Attachment 120624 is rendered (174.31 KB, image/png)
2015-12-21 14:41 UTC, Tristan Miller
Details
handle SMaskInData = 0 for JPX encoded images (7.56 KB, patch)
2016-03-11 15:30 UTC, Thomas Freitag
Details | Splinter Review

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.