[Image-SIG] Problem with JPEG and CMYK color space
kevin at cazabon.com
kevin at cazabon.com
Sat Apr 15 14:01:39 CEST 2006
In the JPEGImagePlugin.py module, there's a hack to handle Photoshop 2.5
CMYK JPEG images (around line 273)... that's causing half the problem upon
loading JPEG's. By commenting that out, you get a proper image, although
it's still inverted.
I can't seem to find the right place to re-invert the image upon load, but
I'll see what I can find. Anyone with suggestions would be welcome.
There's probably a better way to do this though, so the data is read
correctly in the first place (in CMYK, 0,0,0,0 = white, 255,255,255,255 =
full black... this is probably the problem).
----- Original Message -----
From: <kevin at cazabon.com>
To: "Cesare Leonardi" <ced at bernispa.com>; <image-sig at python.org>
Sent: Saturday, April 15, 2006 1:32 PM
Subject: Re: [Image-SIG] Problem with JPEG and CMYK color space
> Actually, the problem is that PIL also has problems reading CMYK JPEG
> apparently. I just proved that by loading your CMYK test files and doing
> "show", then loading a CMYK TIFF file and doing a show (note that to use
> show, it converts to RGB with the internal conversion, so the colors won't
> be perfect). The TIFF loaded fine, the JPEG didn't.
> The patch I've submitted fixes the problem with saving incorrectly, but
> doesn't fix the reading issue (yet). So, as long as your source CMYK
> doesn't come from a JPEG file it's ok (with my invert patch).
> I'll see if I can spend some time looking at that this weekend.
> ----- Original Message -----
> From: "Cesare Leonardi" <ced at bernispa.com>
> To: <image-sig at python.org>
> Sent: Friday, April 14, 2006 9:38 AM
> Subject: Re: [Image-SIG] Problem with JPEG and CMYK color space
>> kevin at cazabon.com ha scritto:
>>> When saving a CMYK file to JPG, PIL seems to invert the colors. I've
>>> submitted a patch to Fredrik already for this, and it should be in the
>>> next major build.
>>> Adding a simple invert to the image before saving will help.
>> Thanks all for your responses.
>> Kevin, i've made some tests following what you've suggested and here is
>> the results.
>> To obtain the color inversion i've used the function invert() in
>> ImageChops module. I've added the code and the new sample images in this
>> page (see "part 2"):
>> As you can see your suggestion works partially.
>> Images 02 and 03 (that was particular in "part 1") are the only that
>> after the inversion looks ok.
>> All the other images looks less dark, but the color are always different
>> than the original.
>> The particular thing to note is that the images produced by the
>> inversion looks the same as Image.show(). Seems that show() already do
>> the inversion.
>> There is another thing that i have noted only now: the images saved by
>> PIL are often less big than the original. Sometimes much less. For
>> test01: 1435 KB test01-dst: 198 KB test01-dst-invert: 198 KB
>> test04: 1237 KB test01-dst: 405 KB test01-dst-invert: 405 KB
>> test08: 1647 KB test01-dst: 777 KB test01-dst-invert: 776 KB
>> test09: 1715 KB test01-dst: 665 KB test01-dst-invert: 665 KB
>> test10: 2032 KB test01-dst: 659 KB test01-dst-invert: 659 KB
>> I can think that PIL optimize the compression, but that difference are
>> really big. Isn't it suspicious? I expect that saving an image in a new
>> file without modifications produces a file very similar to the original,
>> isn't it?
>> The original images was not produced by me so the author can have used
>> low compression. I cannot make tests since i haven't a program that can
>> save in CMYK (Gimp seems not able).
>> Image-SIG maillist - Image-SIG at python.org
> Image-SIG maillist - Image-SIG at python.org
More information about the Image-SIG