[Image-SIG] Problem with JPEG and CMYK color space

kevin at cazabon.com kevin at cazabon.com
Sat Apr 15 13:32:20 CEST 2006


Actually, the problem is that PIL also has problems reading CMYK JPEG files 
apparently.  I just proved that by loading your CMYK test files and doing a 
"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 image 
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.

Kevin.
----- 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"):
> http://www.bernispa.com/pil/index.html
>
> 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 
> example:
> 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).
>
> Regards.
>
> Cesare.
> _______________________________________________
> Image-SIG maillist  -  Image-SIG at python.org
> http://mail.python.org/mailman/listinfo/image-sig
>
>
> 




More information about the Image-SIG mailing list