List Info

Thread: problem about color about some jpeg




problem about color about some jpeg
user name
2007-04-17 01:11:26
I had a file f.jpg. It can be corrent show by acdsee or
IrfanView, but
can not open it by IE.

>>> f=Image.open('f.jpg')
>>> f.show()

The new pic is color error, please see screen_snape.jpg .

f.jpg can be get from : http://farm1.static.flickr.com/174/462386397_579d1f
4915_o.jpg
(IE only see red cross)

screen_snape.jpg gan be get from:http://farm1.static.flickr.com/216/462386405_d24140
a4b9_o.jpg

My mother language is't English.


_______________________________________________
Image-SIG maillist  -  Image-SIGpython.org
htt
p://mail.python.org/mailman/listinfo/image-sig

Re: problem about color about some jpeg
user name
2007-04-17 02:05:51
feihu_roger ha scritto:
> I had a file f.jpg. It can be corrent show by acdsee or
IrfanView, but
> can not open it by IE.
> 
>>>> f=Image.open('f.jpg')
>>>> f.show()
> 
> The new pic is color error, please see screen_snape.jpg
.
> 
> f.jpg can be get from : http://farm1.static.flickr.com/174/462386397_579d1f
4915_o.jpg
> (IE only see red cross)
> 
> screen_snape.jpg gan be get from:http://farm1.static.flickr.com/216/462386405_d24140
a4b9_o.jpg

Your images are JPEG using CMYK colorspace (normally JPEG
use RGB 
colorspace). It is a format that many image viewer cannot
handle (in 
fact IE and Firefox cannot shows them) but still used in
some graphics 
context.
It's known that PIL has some problems treating JPEG CMYK, as
reported at 
least in these thread started from me:
http://mail.python.org/pipermail/image-sig/2006
-April/003862.html
http://mail.python.org/pipermail/image-sig/2
007-February/004336.html
Sorry but in the meantime the web space i've used in these
thread to 
post some sample images and some text note, is not available
to me 
anymore, so the links are broken.

However, in the first thread Kevin Cazabon has posted a
patch that 
resolved the problem with all my images and that was
accepted by PIL 
developers. The problem is that the patch applied is not the
same as 
proposed by Kevin and the upstream version still shows
problems on some 
images.

If you want to try, some month ago i've verified that
Kevin's patch 
still applies correctly to 1.1.6.
You can rename your "JpegImagePlugin.py" to
something else and 
substituting it with attached one (remove
"KevinPatch").

Good luck.   

Cesare.


_______________________________________________
Image-SIG maillist  -  Image-SIGpython.org
htt
p://mail.python.org/mailman/listinfo/image-sig

  
Re: problem about color about some jpeg
user name
2007-04-17 06:08:29
Thank u very much. The patch work current.

> You can rename your "JpegImagePlugin.py" to
something else and 
> substituting it with attached one (remove
"KevinPatch").
> 
> Good luck.   


_______________________________________________
Image-SIG maillist  -  Image-SIGpython.org
htt
p://mail.python.org/mailman/listinfo/image-sig

Re: problem about color about some jpeg
user name
2007-04-18 00:02:23
Just in case, attaching Kevin's patch as unified diff:

Index: JpegImagePlugin.py
============================================================
=======
--- JpegImagePlugin.py	(revision 207)
+++ JpegImagePlugin.py	(revision 208)
 -32,7
+32,7 
 __version__ = "0.5"

 import array, string
-import Image, ImageFile
+import Image, ImageFile, ImageChops

 def i16(c,o=0):
     return ord(c[o+1]) + (ord(c[o])<<8)
 -270,8
+270,11 
                     handler(self, i)
                 if i == 0xFFDA: # start of scan
                     rawmode = self.mode
-                    if self.mode == "CMYK":
-                        rawmode = "CMYK;I"
+                    # 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!
+
                     self.tile = [("jpeg", (0,0) +
self.size, 0, (rawmode, ""))]
                     # self.__offset = self.fp.tell()
                     break
 -282,6
+285,10 
             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:
 -378,7
+385,7 
     "RGB": "RGB",
     "RGBA": "RGB",
     "RGBX": "RGB",
-    "CMYK": "CMYK;I",
+    "CMYK": "CMYK",
     "YCbCr": "YCbCr",
 }

 -406,6
+413,10 
         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):

Best regards,
Alexey.

_______________________________________________
Image-SIG maillist  -  Image-SIGpython.org
htt
p://mail.python.org/mailman/listinfo/image-sig

  
[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )