Berni CED ha scritto:
So i think there is a bug in the code related to JPEG CYMK or there are
some JPEG unsupported feature. What do you think? Some advice?
Now PIL 1.1.6 includes a solution to that problem.
Since some days ago i was using PIL 1.1.4 with the patch from Kevin
Cazabon and for my experiments everything was fine. Some days ago i've
tryed to install python 2.5 along with PIL 1.1.6 (under Windows) and so
i've tryed to test some of the JPEG CMYK files that was problematic with
official PIL 1.1.4 and i noted that some images now are threated good
but other still looks bad. Substituting "JpegImagePlugin.py" with the
one patched by Kevin, everything is fine.
So seems that the file that comes with 1.1.6 is not functional
equivalent to the one patched by Kevin.
I've posted some examples in the following site (see PART 5 at the end):
http://www.bernispa.com/pil/index.html
I've also attached to this message the diff between the
"JpegImagePlugin.py" as found in PIL 1.1.6 and the same file patched
by Kevin (it was written for 1.1.4 but seems that the original file
as not changed meanwhile)
What do you think?
Cesare.
--- JpegImagePlugin.KevinCazabon.py 2007-01-25 11:47:10.000000000 +0100
+++ JpegImagePlugin.py 2006-06-23 01:43:34.000000000 +0200
@@ -1,6 +1,6 @@
#
# The Python Imaging Library.
-# $Id: JpegImagePlugin.py 2199 2004-12-18 08:49:05Z fredrik $
+# $Id: JpegImagePlugin.py 2763 2006-06-22 21:43:28Z fredrik $
#
# JPEG (JFIF) file handling
#
@@ -32,7 +32,7 @@
__version__ = "0.5"
import array, string
-import Image, ImageFile, ImageChops
+import Image, ImageFile
def i16(c,o=0):
return ord(c[o+1]) + (ord(c[o])<<8)
@@ -270,11 +270,8 @@
handler(self, i)
if i == 0xFFDA: # start of scan
rawmode = self.mode
- # patch by Kevin Cazabon to comment this out - nobody
should be using Photoshop 2.5 any more (and it breaks newer versions)
- # CMYK images are still inverted, we'll fix that just
before returning.
- #if self.mode == "CMYK" and self.info.has_key("adobe"):
- # rawmode = "CMYK;I" # Photoshop 2.5 is broken!
-
+ if self.mode == "CMYK":
+ rawmode = "CMYK;I"
self.tile = [("jpeg", (0,0) + self.size, 0, (rawmode, ""))]
# self.__offset = self.fp.tell()
break
@@ -285,10 +282,6 @@
else:
raise SyntaxError("no marker found")
- # patch by Kevin Cazabon to re-invert CMYK JPEG files
- if self.mode == "CMYK":
- self.im = ImageChops.invert(self).im
-
def draft(self, mode, size):
if len(self.tile) != 1:
@@ -385,7 +378,7 @@
"RGB": "RGB",
"RGBA": "RGB",
"RGBX": "RGB",
- "CMYK": "CMYK",
+ "CMYK": "CMYK;I",
"YCbCr": "YCbCr",
}
@@ -413,10 +406,6 @@
dpi[0], dpi[1]
)
- if im.mode == "CMYK":
- # invert it so it's handled correctly in Photoshop/etc. - Kevin
Cazabon.
- im = ImageChops.invert(im)
-
ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)])
def _save_cjpeg(im, fp, filename):
_______________________________________________
Image-SIG maillist - Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig