Bug 21420 - [PATCH] Support for CMYK JPGs broken
Summary: [PATCH] Support for CMYK JPGs broken
Status: CLOSED FIXED
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: images (show other bugs)
Version: 0.20.5
Hardware: Other other
: P3 normal
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-08 21:36 UTC by Ben Galbraith
Modified: 2012-04-01 07:13 UTC (History)
0 users



Attachments
Fixes the described bug (4.00 KB, patch)
2003-07-08 21:40 UTC, Ben Galbraith
Details | Diff
CMYK JPEG generated by Adobe Photoshop (437.93 KB, image/jpeg)
2003-07-09 14:43 UTC, Ben Galbraith
Details
CMYK JPEG generated by the "ImageWrite" image I/O plug-in for JAI (56.49 KB, image/jpeg)
2003-07-09 14:44 UTC, Ben Galbraith
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Galbraith 2003-07-08 21:36:32 UTC
It is well known that Adobe Photoshop for unknown reasons inverts the channel
values in a CMYK JPG file, such that 0 is black rather white.  The author of
org.apache.fop.image.JpegImage knew this and wrote support for it.

However, the condition used to determine if the JPG was generated by Photoshop
is incorrect.  JpegImage checks if the Adobe APPE marker is present in the file.
 If it is, it assumes that Photoshop created the file.  Actually, many other
applications use the Adobe APPE marker standard when creating JPG files but do
*not* invert the CMYK channel values.  As a result, these JPG files are being
displayed with inverted colors.
Comment 1 Ben Galbraith 2003-07-08 21:40:47 UTC
Created attachment 7175 [details]
Fixes the described bug
Comment 2 Ben Galbraith 2003-07-08 21:45:00 UTC
Attachment 7175 [details] is my solution to the bug.

It examines a region of the header FFE1 which appears to consistently identify
JPGs generated by Adobe Photoshop with the text string "Adobe Photoshop"
beginning 124 bytes past the index of "FFE1".  I have tested this patch with
five unique CMYK JPGs generated by Adobe Photoshop 7.

While a better solution would be to check if the CMYK channel values are indeed
inverted, I know of no way to perform such a test.  The following URL, part of
the IJG JPEG library, seems to confirm that there is no such test:

http://courses.cs.deu.edu.tr/cse566/libjpeg.htm
Comment 3 Ben Galbraith 2003-07-09 14:43:23 UTC
Created attachment 7192 [details]
CMYK JPEG generated by Adobe Photoshop
Comment 4 Ben Galbraith 2003-07-09 14:44:14 UTC
Created attachment 7193 [details]
CMYK JPEG generated by the "ImageWrite" image I/O plug-in for JAI
Comment 5 Victor Mote 2003-07-27 22:39:32 UTC
After testing before and after, I have applied the patch to the maintenance 
branch. Thanks very much.

Please note that this class has been modified in what look to my eye like 
substantial ways in the trunk. The image logic or something related to layout 
of images appears to be broken in the trunk ATM, as placing either test file 
into normal.fo throws FOP into an infinite loop. So, we may need to revisit 
this in the trunk code at some future time. I'm sorry for that inconvenience.
Comment 6 Ben Galbraith 2003-07-30 20:23:36 UTC
Thanks for applying the patch!

Let me know when you're ready to revisit this for the trunk code; I'll be happy
to write a new patch.  Or better yet, I'll just do it when the first milestone
trunk version is released.
Comment 7 Glenn Adams 2012-04-01 07:13:11 UTC
batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed