From ned at nedbatchelder.com Mon Nov 3 23:24:05 2008 From: ned at nedbatchelder.com (Ned Batchelder) Date: Mon, 03 Nov 2008 17:24:05 -0500 Subject: [Image-SIG] ImageDraw leaks unless deleted? Message-ID: <490F7A05.9060204@nedbatchelder.com> In the docs for ImageDraw (http://www.pythonware.com/library/pil/handbook/imagedraw.htm), the example includes "del draw". I don't understand why that line is necessary, since when the variable goes out of scope, the object will be deleted. But in our unit tests, we had a problem with memory use growing too large to complete the tests. By adding some "del draw" lines into our code, we halved the memory requirement. In all cases, these dels were in places where the variable would go out of scope or be overwritten shortly anyway. Why are the dels necessary? Is this a subtle memory management bug in ImageDraw? --Ned. http://nedbatchelder.com From ben at ekran.org Tue Nov 4 23:13:57 2008 From: ben at ekran.org (B. Bogart) Date: Tue, 04 Nov 2008 14:13:57 -0800 Subject: [Image-SIG] PIL not loading some TIFF files? Message-ID: <4910C925.30903@ekran.org> Hello all, I'm unable to get PIL (Image.open) to load certain TIFF files generated by another application (using libtiff). According to imageMagick the files are the same type: mask.tif TIFF 640x480 640x480+0+0 DirectClass 8-bit 900.383kb store-00000.tif[1] TIFF 640x480 640x480+0+0 DirectClass 8-bit 1.17202mb mask.tif loads fine: >>> image = Image.open("mask.tif") >>> but store-00000.tif fails: >>> image = Image.open("store-00000.tif") Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.5/site-packages/PIL/Image.py", line 1917, in open raise IOError("cannot identify image file") IOError: cannot identify image file >>> I'm running PIL 1.1.6-3 in python 2.5 on ubuntu hardy. You can grab these two files from: http://www.ekran.org/ben/tmp/mask.tif http://www.ekran.org/ben/tmp/store-00000.tif This is a problem because it is files created by this very application I need to be able to read with PIL. Converting them is not practical because there will be at least 900 images and processing time is an issue. Thanks, B. Bogart From Bryan.Green at acxiom.com Tue Nov 4 23:52:00 2008 From: Bryan.Green at acxiom.com (Green Bryan - bgreen) Date: Tue, 4 Nov 2008 16:52:00 -0600 Subject: [Image-SIG] PIL not loading some TIFF files? In-Reply-To: <4910C925.30903@ekran.org> References: <4910C925.30903@ekran.org> Message-ID: There are some differences between the two. Mask.tif claims to have been created by the GIMP and has a bps of 3 8-bit values. Store-0000.tif has a software type of PD/GEM and a bps of 4 8-bit values. c:\store-00000.tif: Magic: 0x4949 Version: 0x2a Directory 0: offset 1228808 (0x12c008) next 0 (0) ImageWidth (256) SHORT (3) 1<640> ImageLength (257) SHORT (3) 1<480> BitsPerSample (258) SHORT (3) 4<8 8 8 8> Compression (259) SHORT (3) 1<1> Photometric (262) SHORT (3) 1<2> StripOffsets (273) LONG (4) 1<8> SamplesPerPixel (277) SHORT (3) 1<4> StripByteCounts (279) LONG (4) 1<1228800> PlanarConfig (284) SHORT (3) 1<1> Software (305) ASCII (2) 7 c:\mask.tif: Magic: 0x4949 Version: 0x2a Directory 0: offset 921608 (0xe1008) next 0 (0) SubFileType (254) LONG (4) 1<0> ImageWidth (256) SHORT (3) 1<640> ImageLength (257) SHORT (3) 1<480> BitsPerSample (258) SHORT (3) 3<8 8 8> Compression (259) SHORT (3) 1<1> Photometric (262) SHORT (3) 1<2> DocumentName (269) ASCII (2) 66 ImageDescription (270) ASCII (2) 22 StripOffsets (273) LONG (4) 8<8 122888 245768 368648 491528 614408 737288 860168> Orientation (274) SHORT (3) 1<1> SamplesPerPixel (277) SHORT (3) 1<3> RowsPerStrip (278) SHORT (3) 1<64> StripByteCounts (279) LONG (4) 8<122880 122880 122880 122880 122880 122880 122880 61440> XResolution (282) RATIONAL (5) 1<72> YResolution (283) RATIONAL (5) 1<72> PlanarConfig (284) SHORT (3) 1<1> ResolutionUnit (296) SHORT (3) 1<2> -----Original Message----- From: image-sig-bounces+bryan.green=acxiom.com at python.org [mailto:image-sig-bounces+bryan.green=acxiom.com at python.org] On Behalf Of B. Bogart Sent: Tuesday, November 04, 2008 4:14 PM To: image-sig at python.org Subject: [Image-SIG] PIL not loading some TIFF files? Hello all, I'm unable to get PIL (Image.open) to load certain TIFF files generated by another application (using libtiff). According to imageMagick the files are the same type: mask.tif TIFF 640x480 640x480+0+0 DirectClass 8-bit 900.383kb store-00000.tif[1] TIFF 640x480 640x480+0+0 DirectClass 8-bit 1.17202mb mask.tif loads fine: >>> image = Image.open("mask.tif") >>> but store-00000.tif fails: >>> image = Image.open("store-00000.tif") Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.5/site-packages/PIL/Image.py", line 1917, in open raise IOError("cannot identify image file") IOError: cannot identify image file >>> I'm running PIL 1.1.6-3 in python 2.5 on ubuntu hardy. You can grab these two files from: http://www.ekran.org/ben/tmp/mask.tif http://www.ekran.org/ben/tmp/store-00000.tif This is a problem because it is files created by this very application I need to be able to read with PIL. Converting them is not practical because there will be at least 900 images and processing time is an issue. Thanks, B. Bogart _______________________________________________ Image-SIG maillist - Image-SIG at python.org http://mail.python.org/mailman/listinfo/image-sig ************************************************************************* The information contained in this communication is confidential, is intended only for the use of the recipient named above, and may be legally privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please resend this communication to the sender and delete the original message or any copy of it from your computer system. Thank you. ************************************************************************* From Bryan.Green at acxiom.com Wed Nov 5 00:18:20 2008 From: Bryan.Green at acxiom.com (Green Bryan - bgreen) Date: Tue, 4 Nov 2008 17:18:20 -0600 Subject: [Image-SIG] PIL not loading some TIFF files? In-Reply-To: References: <4910C925.30903@ekran.org> Message-ID: It appears that the problem has to do with the following tags not being set in the image. I set these with the tiffset program and PIL then loaded the image without any trouble. I do not know how to set these tags in PIL. Maybe someone has a suggestion? Also, if you open the file in GIMP and save the problem is fixed. I understand this is not a solution for you-- just making note. Most viewers follow fairly closely to the tif spec (they also try and do the "right thing" for non-standard software)-- PIL is not so forgiving. If needed you could write a script to fix the tags on the fly using the command line tiffset program. It is fast. XResolution (282) RATIONAL (5) 1<72> YResolution (283) RATIONAL (5) 1<72> ResolutionUnit (296) SHORT (3) 1<2> -----Original Message----- From: image-sig-bounces+bryan.green=acxiom.com at python.org [mailto:image-sig-bounces+bryan.green=acxiom.com at python.org] On Behalf Of Green Bryan - bgreen Sent: Tuesday, November 04, 2008 4:52 PM To: B. Bogart; image-sig at python.org Subject: Re: [Image-SIG] PIL not loading some TIFF files? There are some differences between the two. Mask.tif claims to have been created by the GIMP and has a bps of 3 8-bit values. Store-0000.tif has a software type of PD/GEM and a bps of 4 8-bit values. c:\store-00000.tif: Magic: 0x4949 Version: 0x2a Directory 0: offset 1228808 (0x12c008) next 0 (0) ImageWidth (256) SHORT (3) 1<640> ImageLength (257) SHORT (3) 1<480> BitsPerSample (258) SHORT (3) 4<8 8 8 8> Compression (259) SHORT (3) 1<1> Photometric (262) SHORT (3) 1<2> StripOffsets (273) LONG (4) 1<8> SamplesPerPixel (277) SHORT (3) 1<4> StripByteCounts (279) LONG (4) 1<1228800> PlanarConfig (284) SHORT (3) 1<1> Software (305) ASCII (2) 7 c:\mask.tif: Magic: 0x4949 Version: 0x2a Directory 0: offset 921608 (0xe1008) next 0 (0) SubFileType (254) LONG (4) 1<0> ImageWidth (256) SHORT (3) 1<640> ImageLength (257) SHORT (3) 1<480> BitsPerSample (258) SHORT (3) 3<8 8 8> Compression (259) SHORT (3) 1<1> Photometric (262) SHORT (3) 1<2> DocumentName (269) ASCII (2) 66 ImageDescription (270) ASCII (2) 22 StripOffsets (273) LONG (4) 8<8 122888 245768 368648 491528 614408 737288 860168> Orientation (274) SHORT (3) 1<1> SamplesPerPixel (277) SHORT (3) 1<3> RowsPerStrip (278) SHORT (3) 1<64> StripByteCounts (279) LONG (4) 8<122880 122880 122880 122880 122880 122880 122880 61440> XResolution (282) RATIONAL (5) 1<72> YResolution (283) RATIONAL (5) 1<72> PlanarConfig (284) SHORT (3) 1<1> ResolutionUnit (296) SHORT (3) 1<2> -----Original Message----- From: image-sig-bounces+bryan.green=acxiom.com at python.org [mailto:image-sig-bounces+bryan.green=acxiom.com at python.org] On Behalf Of B. Bogart Sent: Tuesday, November 04, 2008 4:14 PM To: image-sig at python.org Subject: [Image-SIG] PIL not loading some TIFF files? Hello all, I'm unable to get PIL (Image.open) to load certain TIFF files generated by another application (using libtiff). According to imageMagick the files are the same type: mask.tif TIFF 640x480 640x480+0+0 DirectClass 8-bit 900.383kb store-00000.tif[1] TIFF 640x480 640x480+0+0 DirectClass 8-bit 1.17202mb mask.tif loads fine: >>> image = Image.open("mask.tif") >>> but store-00000.tif fails: >>> image = Image.open("store-00000.tif") Traceback (most recent call last): File "", line 1, in File "/usr/lib/python2.5/site-packages/PIL/Image.py", line 1917, in open raise IOError("cannot identify image file") IOError: cannot identify image file >>> I'm running PIL 1.1.6-3 in python 2.5 on ubuntu hardy. You can grab these two files from: http://www.ekran.org/ben/tmp/mask.tif http://www.ekran.org/ben/tmp/store-00000.tif This is a problem because it is files created by this very application I need to be able to read with PIL. Converting them is not practical because there will be at least 900 images and processing time is an issue. Thanks, B. Bogart _______________________________________________ Image-SIG maillist - Image-SIG at python.org http://mail.python.org/mailman/listinfo/image-sig ************************************************************************ * The information contained in this communication is confidential, is intended only for the use of the recipient named above, and may be legally privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please resend this communication to the sender and delete the original message or any copy of it from your computer system. Thank you. ************************************************************************ * _______________________________________________ Image-SIG maillist - Image-SIG at python.org http://mail.python.org/mailman/listinfo/image-sig From ben at ekran.org Wed Nov 5 01:06:03 2008 From: ben at ekran.org (B. Bogart) Date: Tue, 04 Nov 2008 16:06:03 -0800 Subject: [Image-SIG] PIL not loading some TIFF files? In-Reply-To: References: <4910C925.30903@ekran.org> Message-ID: <4910E36B.1010409@ekran.org> Thanks for the details. I've passed this info onto the pd/Gem developers so they can add these tags to all tifs written by the software. Are these tags required as part of the TIFF spec? Or are they just best practise? Thanks again, B. Bogart Green Bryan - bgreen wrote: > It appears that the problem has to do with the following tags not being > set in the image. I set these with the tiffset program and PIL then > loaded the image without any trouble. I do not know how to set these > tags in PIL. Maybe someone has a suggestion? Also, if you open the > file in GIMP and save the problem is fixed. I understand this is not a > solution for you-- just making note. > > Most viewers follow fairly closely to the tif spec (they also try and do > the "right thing" for non-standard software)-- PIL is not so forgiving. > If needed you could write a script to fix the tags on the fly using the > command line tiffset program. It is fast. > > XResolution (282) RATIONAL (5) 1<72> > YResolution (283) RATIONAL (5) 1<72> > ResolutionUnit (296) SHORT (3) 1<2> > > > -----Original Message----- > From: image-sig-bounces+bryan.green=acxiom.com at python.org > [mailto:image-sig-bounces+bryan.green=acxiom.com at python.org] On Behalf > Of Green Bryan - bgreen > Sent: Tuesday, November 04, 2008 4:52 PM > To: B. Bogart; image-sig at python.org > Subject: Re: [Image-SIG] PIL not loading some TIFF files? > > There are some differences between the two. Mask.tif claims to have > been created by the GIMP and has a bps of 3 8-bit values. > Store-0000.tif has a software type of PD/GEM and a bps of 4 8-bit > values. > > > c:\store-00000.tif: > Magic: 0x4949 Version: 0x2a > Directory 0: offset 1228808 (0x12c008) next 0 (0) > ImageWidth (256) SHORT (3) 1<640> > ImageLength (257) SHORT (3) 1<480> > BitsPerSample (258) SHORT (3) 4<8 8 8 8> > Compression (259) SHORT (3) 1<1> > Photometric (262) SHORT (3) 1<2> > StripOffsets (273) LONG (4) 1<8> > SamplesPerPixel (277) SHORT (3) 1<4> > StripByteCounts (279) LONG (4) 1<1228800> > PlanarConfig (284) SHORT (3) 1<1> > Software (305) ASCII (2) 7 > > c:\mask.tif: > Magic: 0x4949 Version: 0x2a > Directory 0: offset 921608 (0xe1008) next 0 (0) > SubFileType (254) LONG (4) 1<0> > ImageWidth (256) SHORT (3) 1<640> > ImageLength (257) SHORT (3) 1<480> > BitsPerSample (258) SHORT (3) 3<8 8 8> > Compression (259) SHORT (3) 1<1> > Photometric (262) SHORT (3) 1<2> > DocumentName (269) ASCII (2) 66 > ImageDescription (270) ASCII (2) 22 > StripOffsets (273) LONG (4) 8<8 122888 245768 368648 491528 614408 > 737288 860168> > Orientation (274) SHORT (3) 1<1> > SamplesPerPixel (277) SHORT (3) 1<3> > RowsPerStrip (278) SHORT (3) 1<64> > StripByteCounts (279) LONG (4) 8<122880 122880 122880 122880 122880 > 122880 122880 61440> > XResolution (282) RATIONAL (5) 1<72> > YResolution (283) RATIONAL (5) 1<72> > PlanarConfig (284) SHORT (3) 1<1> > ResolutionUnit (296) SHORT (3) 1<2> > > -----Original Message----- > From: image-sig-bounces+bryan.green=acxiom.com at python.org > [mailto:image-sig-bounces+bryan.green=acxiom.com at python.org] On Behalf > Of B. Bogart > Sent: Tuesday, November 04, 2008 4:14 PM > To: image-sig at python.org > Subject: [Image-SIG] PIL not loading some TIFF files? > > Hello all, > > I'm unable to get PIL (Image.open) to load certain TIFF files generated > by another application (using libtiff). > > According to imageMagick the files are the same type: > > mask.tif TIFF 640x480 640x480+0+0 DirectClass 8-bit 900.383kb > store-00000.tif[1] TIFF 640x480 640x480+0+0 DirectClass 8-bit 1.17202mb > > mask.tif loads fine: > >>>> image = Image.open("mask.tif") >>>> > > but store-00000.tif fails: > >>>> image = Image.open("store-00000.tif") > Traceback (most recent call last): > File "", line 1, in > File "/usr/lib/python2.5/site-packages/PIL/Image.py", line 1917, in > open > raise IOError("cannot identify image file") > IOError: cannot identify image file > > I'm running PIL 1.1.6-3 in python 2.5 on ubuntu hardy. > > You can grab these two files from: > > http://www.ekran.org/ben/tmp/mask.tif > http://www.ekran.org/ben/tmp/store-00000.tif > > This is a problem because it is files created by this very application I > need to be able to read with PIL. Converting them is not practical > because there will be at least 900 images and processing time is an > issue. > > Thanks, > B. Bogart > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > ************************************************************************ > * > The information contained in this communication is confidential, is > intended only for the use of the recipient named above, and may be > legally privileged. > > If the reader of this message is not the intended recipient, you are > hereby notified that any dissemination, distribution or copying of this > communication is strictly prohibited. > > If you have received this communication in error, please resend this > communication to the sender and delete the original message or any copy > of it from your computer system. > > Thank you. > ************************************************************************ > * > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From lists+Image_SIG at hoech.org Wed Nov 5 14:25:15 2008 From: lists+Image_SIG at hoech.org (=?ISO-8859-1?Q?Florian_H=F6ch?=) Date: Wed, 05 Nov 2008 14:25:15 +0100 Subject: [Image-SIG] PIL not loading some TIFF files? In-Reply-To: <4910C925.30903@ekran.org> References: <4910C925.30903@ekran.org> Message-ID: <49119EBB.6010903@hoech.org> Hello, >> mask.tif loads fine: >> >>>>> image = Image.open("mask.tif") >>>>> >> >> but store-00000.tif fails: PIL does not support alpha channels in TIFF files. Regards, Florian From Bryan.Green at acxiom.com Wed Nov 5 15:22:44 2008 From: Bryan.Green at acxiom.com (Green Bryan - bgreen) Date: Wed, 5 Nov 2008 08:22:44 -0600 Subject: [Image-SIG] PIL not loading some TIFF files? In-Reply-To: <49119EBB.6010903@hoech.org> References: <4910C925.30903@ekran.org> <49119EBB.6010903@hoech.org> Message-ID: Florian is completely correct. I went down the wrong path and thanks to a typo thought I had the file loaded with PIL when I did not. The PD/GEM people should still make sure the tags are updated correctly when writing a baseline tiff image. You need to be able to handle ExtraSamples to claim that you can handle TIFF. TIFF 6.0 Specification Final-June 3, 1992 These are the required fields for RGB images (in numerical order): TagName Decimal Hex Type Value ImageWidth 256 100 SHORT or LONG ImageLength 257 101 SHORT or LONG BitsPerSample 258 102 SHORT 8,8,8 Compression 259 103 SHORT 1 or 32773 PhotometricInterpretation 262 106 SHORT 2 StripOffsets 273 111 SHORT or LONG SamplesPerPixel 277 115 SHORT 3 or more RowsPerStrip 278 116 SHORT or LONG StripByteCounts 279 117 LONG or SHORT XResolution 282 11A RATIONAL YResolution 283 11B RATIONAL ResolutionUnit 296 128 SHORT 1, 2 or 3 The BitsPerSample values listed above apply only to the main image data. If ExtraSamples are present, the appropriate BitsPerSample values for those samples must also be included -----Original Message----- From: image-sig-bounces+bryan.green=acxiom.com at python.org [mailto:image-sig-bounces+bryan.green=acxiom.com at python.org] On Behalf Of Florian H?ch Sent: Wednesday, November 05, 2008 7:25 AM To: image-sig at python.org Subject: Re: [Image-SIG] PIL not loading some TIFF files? Hello, >> mask.tif loads fine: >> >>>>> image = Image.open("mask.tif") >>>>> >> >> but store-00000.tif fails: PIL does not support alpha channels in TIFF files. Regards, Florian _______________________________________________ Image-SIG maillist - Image-SIG at python.org http://mail.python.org/mailman/listinfo/image-sig *************************************************************************** The information contained in this communication is confidential, is intended only for the use of the recipient named above, and may be legally privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please resend this communication to the sender and delete the original message or any copy of it from your computer system. Thank You. **************************************************************************** From Bryan.Green at acxiom.com Wed Nov 5 01:11:50 2008 From: Bryan.Green at acxiom.com (Green Bryan - bgreen) Date: Tue, 4 Nov 2008 18:11:50 -0600 Subject: [Image-SIG] PIL not loading some TIFF files? References: <4910C925.30903@ekran.org> <4910E36B.1010409@ekran.org> Message-ID: They are required per the TIFF 6.0 baseline standard. Here is a link (and I pasted the relevant text from p.64): http://www.alternatiff.com/resources/TIFF6.pdf Required Fields for RGB Images These are the required fields for RGB images (in numerical order): TagName Decimal Hex Type Value ImageWidth 256 100 SHORT or LONG ImageLength 257 101 SHORT or LONG BitsPerSample 258 102 SHORT 8,8,8 Compression 259 103 SHORT 1 or 32773 PhotometricInterpretation 262 106 SHORT 2 StripOffsets 273 111 SHORT or LONG SamplesPerPixel 277 115 SHORT 3 or more RowsPerStrip 278 116 SHORT or LONG StripByteCounts 279 117 LONG or SHORT XResolution 282 11A RATIONAL YResolution 283 11B RATIONAL ResolutionUnit 296 128 SHORT 1, 2 or 3 24 TIFF 6.0 Specification Final?June 3, 1992 The BitsPerSample values listed above apply only to the main image data. If ExtraSamples are present, the appropriate BitsPerSample values for those samples must also be included. Baseline TIFF RGB images were called TIFF Class R images in earlier versions of the TIFF specification. -----Original Message----- From: B. Bogart [mailto:ben at ekran.org] Sent: Tue 11/4/2008 6:06 PM To: Green Bryan - bgreen Cc: image-sig at python.org Subject: Re: [Image-SIG] PIL not loading some TIFF files? Thanks for the details. I've passed this info onto the pd/Gem developers so they can add these tags to all tifs written by the software. Are these tags required as part of the TIFF spec? Or are they just best practise? Thanks again, B. Bogart Green Bryan - bgreen wrote: > It appears that the problem has to do with the following tags not being > set in the image. I set these with the tiffset program and PIL then > loaded the image without any trouble. I do not know how to set these > tags in PIL. Maybe someone has a suggestion? Also, if you open the > file in GIMP and save the problem is fixed. I understand this is not a > solution for you-- just making note. > > Most viewers follow fairly closely to the tif spec (they also try and do > the "right thing" for non-standard software)-- PIL is not so forgiving. > If needed you could write a script to fix the tags on the fly using the > command line tiffset program. It is fast. > > XResolution (282) RATIONAL (5) 1<72> > YResolution (283) RATIONAL (5) 1<72> > ResolutionUnit (296) SHORT (3) 1<2> > > > -----Original Message----- > From: image-sig-bounces+bryan.green=acxiom.com at python.org > [mailto:image-sig-bounces+bryan.green=acxiom.com at python.org] On Behalf > Of Green Bryan - bgreen > Sent: Tuesday, November 04, 2008 4:52 PM > To: B. Bogart; image-sig at python.org > Subject: Re: [Image-SIG] PIL not loading some TIFF files? > > There are some differences between the two. Mask.tif claims to have > been created by the GIMP and has a bps of 3 8-bit values. > Store-0000.tif has a software type of PD/GEM and a bps of 4 8-bit > values. > > > c:\store-00000.tif: > Magic: 0x4949 Version: 0x2a > Directory 0: offset 1228808 (0x12c008) next 0 (0) > ImageWidth (256) SHORT (3) 1<640> > ImageLength (257) SHORT (3) 1<480> > BitsPerSample (258) SHORT (3) 4<8 8 8 8> > Compression (259) SHORT (3) 1<1> > Photometric (262) SHORT (3) 1<2> > StripOffsets (273) LONG (4) 1<8> > SamplesPerPixel (277) SHORT (3) 1<4> > StripByteCounts (279) LONG (4) 1<1228800> > PlanarConfig (284) SHORT (3) 1<1> > Software (305) ASCII (2) 7 > > c:\mask.tif: > Magic: 0x4949 Version: 0x2a > Directory 0: offset 921608 (0xe1008) next 0 (0) > SubFileType (254) LONG (4) 1<0> > ImageWidth (256) SHORT (3) 1<640> > ImageLength (257) SHORT (3) 1<480> > BitsPerSample (258) SHORT (3) 3<8 8 8> > Compression (259) SHORT (3) 1<1> > Photometric (262) SHORT (3) 1<2> > DocumentName (269) ASCII (2) 66 > ImageDescription (270) ASCII (2) 22 > StripOffsets (273) LONG (4) 8<8 122888 245768 368648 491528 614408 > 737288 860168> > Orientation (274) SHORT (3) 1<1> > SamplesPerPixel (277) SHORT (3) 1<3> > RowsPerStrip (278) SHORT (3) 1<64> > StripByteCounts (279) LONG (4) 8<122880 122880 122880 122880 122880 > 122880 122880 61440> > XResolution (282) RATIONAL (5) 1<72> > YResolution (283) RATIONAL (5) 1<72> > PlanarConfig (284) SHORT (3) 1<1> > ResolutionUnit (296) SHORT (3) 1<2> > > -----Original Message----- > From: image-sig-bounces+bryan.green=acxiom.com at python.org > [mailto:image-sig-bounces+bryan.green=acxiom.com at python.org] On Behalf > Of B. Bogart > Sent: Tuesday, November 04, 2008 4:14 PM > To: image-sig at python.org > Subject: [Image-SIG] PIL not loading some TIFF files? > > Hello all, > > I'm unable to get PIL (Image.open) to load certain TIFF files generated > by another application (using libtiff). > > According to imageMagick the files are the same type: > > mask.tif TIFF 640x480 640x480+0+0 DirectClass 8-bit 900.383kb > store-00000.tif[1] TIFF 640x480 640x480+0+0 DirectClass 8-bit 1.17202mb > > mask.tif loads fine: > >>>> image = Image.open("mask.tif") >>>> > > but store-00000.tif fails: > >>>> image = Image.open("store-00000.tif") > Traceback (most recent call last): > File "", line 1, in > File "/usr/lib/python2.5/site-packages/PIL/Image.py", line 1917, in > open > raise IOError("cannot identify image file") > IOError: cannot identify image file > > I'm running PIL 1.1.6-3 in python 2.5 on ubuntu hardy. > > You can grab these two files from: > > http://www.ekran.org/ben/tmp/mask.tif > http://www.ekran.org/ben/tmp/store-00000.tif > > This is a problem because it is files created by this very application I > need to be able to read with PIL. Converting them is not practical > because there will be at least 900 images and processing time is an > issue. > > Thanks, > B. Bogart > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > ************************************************************************ > * > The information contained in this communication is confidential, is > intended only for the use of the recipient named above, and may be > legally privileged. > > If the reader of this message is not the intended recipient, you are > hereby notified that any dissemination, distribution or copying of this > communication is strictly prohibited. > > If you have received this communication in error, please resend this > communication to the sender and delete the original message or any copy > of it from your computer system. > > Thank you. > ************************************************************************ > * > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From yuequnpan at myspace.cn Thu Nov 6 03:46:08 2008 From: yuequnpan at myspace.cn (Pan,YueQun) Date: Thu, 6 Nov 2008 10:46:08 +0800 Subject: [Image-SIG] help! decoder jpeg not available Message-ID: <258B937352B41941BA83277ED111AC4A01372B3A@mysp-hq-ex01.cnmscorp.myspace.cn> In gentoo linux, the install is ok ,build information is: running build running build_py running build_ext -------------------------------------------------------------------- PIL 1.1.6 BUILD SUMMARY -------------------------------------------------------------------- version 1.1.6 platform linux2 2.4.3 (#1, Apr 17 2007, 02:26:48) [GCC 4.1.1 (Gentoo 4.1.1-r3)] -------------------------------------------------------------------- *** TKINTER support not available --- JPEG support ok --- ZLIB (PNG/ZIP) support ok --- FREETYPE2 support ok -------------------------------------------------------------------- To add a missing option, make sure you have the required library, and set the corresponding ROOT variable in the setup.py script. To check the build, run the selftest.py script. running build_scripts $ python selftest.py Failure in example: _info(Image.open("Images/lena.jpg")) from line #24 of selftest.testimage Exception raised: Traceback (most recent call last): File "./doctest.py", line 499, in _run_examples_inner exec compile(source, "", "single") in globs File "", line 1, in ? File "./selftest.py", line 22, in _info im.load() File "PIL/ImageFile.py", line 180, in load d = Image._getdecoder(self.mode, d, a, self.decoderconfig) File "PIL/Image.py", line 375, in _getdecoder raise IOError("decoder %s not available" %decoder_name) IOError: decoder jpeg not available 1 items had failures: 1 of 57 in selftest.testimage ***Test Failed*** 1 failures. *** 1 tests of 57 failed. I've install the jpeg-6b package,the install information is as follows: $./configure --enable-shared --enable-static CFLAGS='-g' checking for gcc... gcc checking whether the C compiler (gcc -g ) works... yes checking whether the C compiler (gcc -g ) is a cross-compiler... no checking whether we are using GNU C... yes checking how to run the C preprocessor... gcc -E checking for function prototypes... yes checking for stddef.h... yes checking for stdlib.h... yes checking for string.h... yes checking for size_t... yes checking for type unsigned char... yes checking for type unsigned short... yes checking for type void... yes checking for working const... yes checking for inline... __inline__ checking for broken incomplete types... ok checking for short external names... ok checking to see if char is signed... yes checking to see if right shift is signed... yes checking to see if fopen accepts b spec... yes checking for a BSD compatible install... /usr/bin/install -c checking for ranlib... ranlib checking host system type... x86_64-unknown-linux-gnu checking for ranlib... ranlib checking for gcc... gcc checking whether we are using GNU C... yes checking for gcc option to produce PIC... -fPIC checking if gcc PIC flag -fPIC works... yes checking if gcc static flag -static works... -static checking whether ln -s works... yes checking for ld used by GCC... /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../x86_64-pc-linux-gnu/b in/ld checking if the linker (/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../x86_64-pc-linux-gnu/ bin/ld) is GNU ld... yes checking whether the linker (/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../x86_64-pc-linux-gnu/ bin/ld) supports shared libraries... yes checking for BSD-compatible nm... /usr/bin/nm -B checking command to parse /usr/bin/nm -B output... yes checking how to hardcode library paths into programs... immediate checking for /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../x86_64-pc-linux-gnu/b in/ld option to reload object files... -r checking dynamic linker characteristics... Linux ld.so checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes checking for objdir... .libs creating libtool checking libjpeg version number... 62 creating ./config.status creating Makefile creating jconfig.h jconfig.h is unchanged $make $make test rm -f testout* ./djpeg -dct int -ppm -outfile testout.ppm ./testorig.jpg ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp ./testorig.jpg ./cjpeg -dct int -outfile testout.jpg ./testimg.ppm ./djpeg -dct int -ppm -outfile testoutp.ppm ./testprog.jpg ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg ./testimg.ppm ./jpegtran -outfile testoutt.jpg ./testprog.jpg cmp ./testimg.ppm testout.ppm cmp ./testimg.bmp testout.bmp cmp ./testimg.jpg testout.jpg cmp ./testimg.ppm testoutp.ppm cmp ./testimgp.jpg testoutp.jpg cmp ./testorig.jpg testoutt.jpg $sudo make install /usr/bin/install -c -m 644 jconfig.h /usr/local/include/jconfig.h /usr/bin/install -c -m 644 ./jpeglib.h /usr/local/include/jpeglib.h /usr/bin/install -c -m 644 ./jmorecfg.h /usr/local/include/jmorecfg.h /usr/bin/install -c -m 644 ./jerror.h /usr/local/include/jerror.h ./libtool --mode=install /usr/bin/install -c libjpeg.la /usr/local/lib/libjpeg.la /usr/bin/install -c .libs/libjpeg.so.62.0.0 /usr/local/lib/libjpeg.so.62.0.0 rm -f /usr/local/lib/libjpeg.so.62 /usr/local/lib/libjpeg.so (cd /usr/local/lib && ln -s libjpeg.so.62.0.0 libjpeg.so.62) (cd /usr/local/lib && ln -s libjpeg.so.62.0.0 libjpeg.so) /usr/bin/install -c libjpeg.la /usr/local/lib/libjpeg.la /usr/bin/install -c .libs/libjpeg.a /usr/local/lib/libjpeg.a ranlib /usr/local/lib/libjpeg.a chmod 644 /usr/local/lib/libjpeg.a PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/ bin:/sbin" ldconfig -n /usr/local/lib ------------------------------------------------------------------------ ------ Libraries have been installed in: /usr/local/lib To link against installed libraries in a given directory, LIBDIR, you must use the `-LLIBDIR' flag during linking. You will also need to do one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,--rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf' See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ------------------------------------------------------------------------ ------ ./libtool --mode=install /usr/bin/install -c cjpeg /usr/local/bin/cjpeg /usr/bin/install -c .libs/cjpeg /usr/local/bin/cjpeg ./libtool --mode=install /usr/bin/install -c djpeg /usr/local/bin/djpeg /usr/bin/install -c .libs/djpeg /usr/local/bin/djpeg ./libtool --mode=install /usr/bin/install -c jpegtran /usr/local/bin/jpegtran /usr/bin/install -c .libs/jpegtran /usr/local/bin/jpegtran ./libtool --mode=install /usr/bin/install -c rdjpgcom /usr/local/bin/rdjpgcom /usr/bin/install -c rdjpgcom /usr/local/bin/rdjpgcom ./libtool --mode=install /usr/bin/install -c wrjpgcom /usr/local/bin/wrjpgcom /usr/bin/install -c wrjpgcom /usr/local/bin/wrjpgcom /usr/bin/install -c -m 644 ./cjpeg.1 /usr/local/man/man1/cjpeg.1 /usr/bin/install -c -m 644 ./djpeg.1 /usr/local/man/man1/djpeg.1 /usr/bin/install -c -m 644 ./jpegtran.1 /usr/local/man/man1/jpegtran.1 /usr/bin/install -c -m 644 ./rdjpgcom.1 /usr/local/man/man1/rdjpgcom.1 /usr/bin/install -c -m 644 ./wrjpgcom.1 /usr/local/man/man1/wrjpgcom.1 It seems everything is OK ,but it doesn't work! I run in my own program, the error information is as follows: Traceback (most recent call last): File "ImageRecog.py", line 2, in ? img = Image.open(sys.argv[1]).convert('YCbCr') File "/usr/lib64/python2.4/site-packages/PIL/Image.py", line 653, in convert self.load() File "/usr/lib64/python2.4/site-packages/PIL/ImageFile.py", line 155, in load self.load_prepare() File "/usr/lib64/python2.4/site-packages/PIL/ImageFile.py", line 223, in load_prepare self.im = Image.core.new(self.mode, self.size) File "/usr/lib64/python2.4/site-packages/PIL/Image.py", line 36, in __getattr__ raise ImportError("The _imaging C module is not installed") ImportError: The _imaging C module is not installed and it's true that the _imaging model not exists! Can you help me? thanks! Yuequn Pan *** Attention *** This electronic mail including attachments is intended only for the person(s) or entity to which it is addressed and may contain confidential and/or legally privileged material and information. Unauthorized disclosure, copying, distribution or use of this material and information may be unlawful and is prohibited. If you are not the intended recipient and have received this mail in error, please contact the sender and delete all contents of the e-mail as well as any copies made. -------------- next part -------------- An HTML attachment was scrubbed... URL: From panyuequn at gmail.com Thu Nov 6 04:08:22 2008 From: panyuequn at gmail.com (Pan Yuequn) Date: Thu, 6 Nov 2008 11:08:22 +0800 Subject: [Image-SIG] help! decoder jpeg not available Message-ID: <6a0ac0af0811051908y4e6dcacei4c75482a9f5853e2@mail.gmail.com> In gentoo linux, the install is ok ,build information is: running build running build_py running build_ext -------------------------------------------------------------------- PIL 1.1.6 BUILD SUMMARY -------------------------------------------------------------------- version 1.1.6 platform linux2 2.4.3 (#1, Apr 17 2007, 02:26:48) [GCC 4.1.1 (Gentoo 4.1.1-r3)] -------------------------------------------------------------------- *** TKINTER support not available --- JPEG support ok --- ZLIB (PNG/ZIP) support ok --- FREETYPE2 support ok -------------------------------------------------------------------- To add a missing option, make sure you have the required library, and set the corresponding ROOT variable in the setup.py script. To check the build, run the selftest.py script. running build_scripts $ python selftest.py Failure in example: _info(Image.open("Images/lena.jpg")) from line #24 of selftest.testimage Exception raised: Traceback (most recent call last): File "./doctest.py", line 499, in _run_examples_inner exec compile(source, "", "single") in globs File "", line 1, in ? File "./selftest.py", line 22, in _info im.load() File "PIL/ImageFile.py", line 180, in load d = Image._getdecoder(self.mode, d, a, self.decoderconfig) File "PIL/Image.py", line 375, in _getdecoder raise IOError("decoder %s not available" %decoder_name) IOError: decoder jpeg not available 1 items had failures: 1 of 57 in selftest.testimage ***Test Failed*** 1 failures. *** 1 tests of 57 failed. I've install the jpeg-6b package,the install information is as follows: $./configure --enable-shared --enable-static CFLAGS='-g' checking for gcc... gcc checking whether the C compiler (gcc -g ) works... yes checking whether the C compiler (gcc -g ) is a cross-compiler... no checking whether we are using GNU C... yes checking how to run the C preprocessor... gcc -E checking for function prototypes... yes checking for stddef.h... yes checking for stdlib.h... yes checking for string.h... yes checking for size_t... yes checking for type unsigned char... yes checking for type unsigned short... yes checking for type void... yes checking for working const... yes checking for inline... __inline__ checking for broken incomplete types... ok checking for short external names... ok checking to see if char is signed... yes checking to see if right shift is signed... yes checking to see if fopen accepts b spec... yes checking for a BSD compatible install... /usr/bin/install -c checking for ranlib... ranlib checking host system type... x86_64-unknown-linux-gnu checking for ranlib... ranlib checking for gcc... gcc checking whether we are using GNU C... yes checking for gcc option to produce PIC... -fPIC checking if gcc PIC flag -fPIC works... yes checking if gcc static flag -static works... -static checking whether ln -s works... yes checking for ld used by GCC... /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../x86_64-pc-linux-gnu/bin/ld checking if the linker (/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../x86_64-pc-linux-gnu/bin/ld) is GNU ld... yes checking whether the linker (/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../x86_64-pc-linux-gnu/bin/ld) supports shared libraries... yes checking for BSD-compatible nm... /usr/bin/nm -B checking command to parse /usr/bin/nm -B output... yes checking how to hardcode library paths into programs... immediate checking for /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../x86_64-pc-linux-gnu/bin/ld option to reload object files... -r checking dynamic linker characteristics... Linux ld.so checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... yes checking for objdir... .libs creating libtool checking libjpeg version number... 62 creating ./config.status creating Makefile creating jconfig.h jconfig.h is unchanged $make $make test rm -f testout* ./djpeg -dct int -ppm -outfile testout.ppm ./testorig.jpg ./djpeg -dct int -bmp -colors 256 -outfile testout.bmp ./testorig.jpg ./cjpeg -dct int -outfile testout.jpg ./testimg.ppm ./djpeg -dct int -ppm -outfile testoutp.ppm ./testprog.jpg ./cjpeg -dct int -progressive -opt -outfile testoutp.jpg ./testimg.ppm ./jpegtran -outfile testoutt.jpg ./testprog.jpg cmp ./testimg.ppm testout.ppm cmp ./testimg.bmp testout.bmp cmp ./testimg.jpg testout.jpg cmp ./testimg.ppm testoutp.ppm cmp ./testimgp.jpg testoutp.jpg cmp ./testorig.jpg testoutt.jpg $sudo make install /usr/bin/install -c -m 644 jconfig.h /usr/local/include/jconfig.h /usr/bin/install -c -m 644 ./jpeglib.h /usr/local/include/jpeglib.h /usr/bin/install -c -m 644 ./jmorecfg.h /usr/local/include/jmorecfg.h /usr/bin/install -c -m 644 ./jerror.h /usr/local/include/jerror.h ./libtool --mode=install /usr/bin/install -c libjpeg.la /usr/local/lib/ libjpeg.la /usr/bin/install -c .libs/libjpeg.so.62.0.0 /usr/local/lib/libjpeg.so.62.0.0 rm -f /usr/local/lib/libjpeg.so.62 /usr/local/lib/libjpeg.so (cd /usr/local/lib && ln -s libjpeg.so.62.0.0 libjpeg.so.62) (cd /usr/local/lib && ln -s libjpeg.so.62.0.0 libjpeg.so) /usr/bin/install -c libjpeg.la /usr/local/lib/libjpeg.la /usr/bin/install -c .libs/libjpeg.a /usr/local/lib/libjpeg.a ranlib /usr/local/lib/libjpeg.a chmod 644 /usr/local/lib/libjpeg.a PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin:/sbin" ldconfig -n /usr/local/lib ------------------------------------------------------------------------------ Libraries have been installed in: /usr/local/lib To link against installed libraries in a given directory, LIBDIR, you must use the `-LLIBDIR' flag during linking. You will also need to do one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,--rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf' See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ------------------------------------------------------------------------------ ./libtool --mode=install /usr/bin/install -c cjpeg /usr/local/bin/cjpeg /usr/bin/install -c .libs/cjpeg /usr/local/bin/cjpeg ./libtool --mode=install /usr/bin/install -c djpeg /usr/local/bin/djpeg /usr/bin/install -c .libs/djpeg /usr/local/bin/djpeg ./libtool --mode=install /usr/bin/install -c jpegtran /usr/local/bin/jpegtran /usr/bin/install -c .libs/jpegtran /usr/local/bin/jpegtran ./libtool --mode=install /usr/bin/install -c rdjpgcom /usr/local/bin/rdjpgcom /usr/bin/install -c rdjpgcom /usr/local/bin/rdjpgcom ./libtool --mode=install /usr/bin/install -c wrjpgcom /usr/local/bin/wrjpgcom /usr/bin/install -c wrjpgcom /usr/local/bin/wrjpgcom /usr/bin/install -c -m 644 ./cjpeg.1 /usr/local/man/man1/cjpeg.1 /usr/bin/install -c -m 644 ./djpeg.1 /usr/local/man/man1/djpeg.1 /usr/bin/install -c -m 644 ./jpegtran.1 /usr/local/man/man1/jpegtran.1 /usr/bin/install -c -m 644 ./rdjpgcom.1 /usr/local/man/man1/rdjpgcom.1 /usr/bin/install -c -m 644 ./wrjpgcom.1 /usr/local/man/man1/wrjpgcom.1 It seems everything is OK ,but it doesn't work! I run in my own program, the error information is as follows: Traceback (most recent call last): File "ImageRecog.py", line 2, in ? img = Image.open(sys.argv[1]).convert('YCbCr') File "/usr/lib64/python2.4/site-packages/PIL/Image.py", line 653, in convert self.load() File "/usr/lib64/python2.4/site-packages/PIL/ImageFile.py", line 155, in load self.load_prepare() File "/usr/lib64/python2.4/site-packages/PIL/ImageFile.py", line 223, in load_prepare self.im = Image.core.new(self.mode, self.size) File "/usr/lib64/python2.4/site-packages/PIL/Image.py", line 36, in __getattr__ raise ImportError("The _imaging C module is not installed") ImportError: The _imaging C module is not installed and it's true that the _imaging model not exists! Can you help me? thanks! Yuequn Pan -------------- next part -------------- An HTML attachment was scrubbed... URL: From nwagner at iam.uni-stuttgart.de Thu Nov 6 15:40:18 2008 From: nwagner at iam.uni-stuttgart.de (Nils Wagner) Date: Thu, 06 Nov 2008 15:40:18 +0100 Subject: [Image-SIG] combine jpeg's Message-ID: Hi all, Is it possible to combine 4 jpegs into 1 jpeg ? A small example would be appreciated. Thanks in advance Nils From mail at karsten.name Tue Nov 11 10:21:32 2008 From: mail at karsten.name (Karsten Hiddemann) Date: Tue, 11 Nov 2008 10:21:32 +0100 Subject: [Image-SIG] help! decoder jpeg not available In-Reply-To: <258B937352B41941BA83277ED111AC4A01372B3A@mysp-hq-ex01.cnmscorp.myspace.cn> References: <258B937352B41941BA83277ED111AC4A01372B3A@mysp-hq-ex01.cnmscorp.myspace.cn> Message-ID: <49194E9C.7060602@karsten.name> Pan,YueQun schrieb: > In gentoo linux, the install is ok ,build information is: You install PIL in Gentoo by emerging dev-python/imaging. Did you do it that way? If that still gives you errors, then file a bug at bugs.gentoo.org, otherwise use the ebuild instead. To install version 1.1.6 instead of 1.1.5, you have to add dev-python/imaging to /etc/portage/package.keywords Cheers, Karsten From cannon.el at gmail.com Tue Nov 11 22:05:52 2008 From: cannon.el at gmail.com (Laura & Edward Cannon) Date: Tue, 11 Nov 2008 13:05:52 -0800 Subject: [Image-SIG] combine jpeg's In-Reply-To: References: Message-ID: please clarify, what exactly do you mean On Thu, Nov 6, 2008 at 6:40 AM, Nils Wagner wrote: > Hi all, > > Is it possible to combine 4 jpegs into 1 jpeg ? > A small example would be appreciated. > > Thanks in advance > > Nils > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From fredrik at pythonware.com Wed Nov 12 10:22:15 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 12 Nov 2008 10:22:15 +0100 Subject: [Image-SIG] antialiased lines and polygons In-Reply-To: References: Message-ID: Laura & Edward Cannon wrote: > A quick question, is their a way to get an antialiased line or polygon > in PIL? I draw my shapes just fine, but the edges are jagged. Some > packages I know can antialias to reduce the appearance of > pixelization, is PIL one of those? there's no built-in support for antialiasing (yet), but the aggdraw bindings for the AGG library work pretty well with PIL: http://effbot.org/zone/aggdraw-index.htm From fredrik at pythonware.com Wed Nov 12 10:28:13 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 12 Nov 2008 10:28:13 +0100 Subject: [Image-SIG] combine jpeg's In-Reply-To: References: Message-ID: Nils Wagner wrote: > Is it possible to combine 4 jpegs into 1 jpeg ? > A small example would be appreciated. The correct way to do this depends on your definition of "combine", of course, but assuming that you have four smaller JPEG files, all having the same size, you can simply do: im1 = Image.open("...") im2 = Image.open("...") im3 = Image.open("...") im4 = Image.open("...") # assume all input images have the same size x = im1.size[0] y = im1.size[1] out = Image.new("RGB", (x+x, y+y), None) out.paste((0, 0), im1) out.paste((x, 0), im2) out.paste((0, y), im3) out.paste((x, y), im4) out.save("out.jpg") Note that recompressing JPEG images may introduce artifacts, but if you avoid doing that over and over, that shouldn't be much of a problem for this specific case. From fredrik at pythonware.com Thu Nov 13 11:40:14 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 13 Nov 2008 11:40:14 +0100 Subject: [Image-SIG] Bug in ImageWin (display.c) In-Reply-To: <49099133.6010803@gmail.com> References: <49099133.6010803@gmail.com> Message-ID: Noboru Uchida wrote: > Problem: Dib.draw() fails occasionally and raises Overflow Error. > > Reason: > In display.c, Window Handles(HWND) and Device Contexts(HDC) are both > declared as "int". > HWND/HDC arguments are parsed by PyArg_ParseTuple(), using format "i". > > "i" converts Python integer to plain C integer, but when the value is > greater than 0x7fffffff, it seems to fail in Overflow Error. > > The problem is, HWND/HDC *can* take such values. > > I think unsigned integer and Format "I" would fix this problem. Thanks. I suspect that this is a C API incompatibility introduced by the PEP 237 activities back in 2.2 or 2.3 (the "I" formatting code was introduced in 2.3), but it's definitely a bug. From fredrik at pythonware.com Thu Nov 13 11:43:37 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 13 Nov 2008 11:43:37 +0100 Subject: [Image-SIG] PIL license question In-Reply-To: References: Message-ID: Tomasz Zieli?ski wrote: > Also, I noticed that apt-getted PIL package on Ubuntu doesn't include > PIL license text (at least I couldn't find it). Should I put one > somewhere around? for the record, we've diskussed this off-list, and the relevant license text is installed under: /usr/share/doc/python-imaging by the standard installers. From noboru.uchida.777 at gmail.com Thu Nov 13 12:51:02 2008 From: noboru.uchida.777 at gmail.com (Noboru Uchida) Date: Thu, 13 Nov 2008 20:51:02 +0900 Subject: [Image-SIG] Animated GIF problem Message-ID: <491C14A6.4080805@gmail.com> Hi. Excuse my poor English. * Problem: Some animated GIFs can't be played properly. You can see this using "player.py" sample script and Animated GIF files, which doesn't have per-frame palettes. When playing back Animated GIFs, you can use Image.seek(), then you call Image.paste() or something. I found this is not enough for animated GIF file, which doesn't have per-frame local palette informations. In such a file, the global palette *must* be used to render GIF frame, but the global palette doesn't seem properly used by PIL. As a result, after second frame, rendering results are broken. * Reason: 1. In GifImageFile._open(), ImagePalette instance for the global palette is created using ImagePalette.raw(), and saved as "global_palette" variable. 2. In GifImageFile.seek(), when GIF file doesn't have per-flame local palette, global palette is set to "palette" variable. This is not a copy. Now both "palette" and "global_palette" point to same ImagePalette instance. 3. In Image.load(), palette.dirty, palette.mode and palette.rawmode are overwritten (why?). 4. When seeking to second frame, and second frame doesn't have local palette, variable "palette" is set to "global_palette". But, this time, "global_palette" is already overwritten in step 3. 5. In Image.load(), this time, palette.dirty is None. More over, palette.rawmode is broken because of step 3. As a result, proper palette information seems not given to C implementation code. * Workaround: After seek(), I can manually fix palette information as following: image.palette.dirty = 1 image.palette.rawmode = "RGB" and do loading/rendering jobs. But, I think this should be done in PIL code, not users' one. From gomtuu at gmail.com Sun Nov 16 06:30:02 2008 From: gomtuu at gmail.com (Don Laursen) Date: Sun, 16 Nov 2008 00:30:02 -0500 Subject: [Image-SIG] Paletted image with alpha Message-ID: <408e16a00811152130y2ebef931l50018ba245dd19ea@mail.gmail.com> Hello, I wrote an application that views 3D mesh files from a Playstation game (Final Fantasy Tactics). I've been using PIL to read the texture data, and it's been working fine. Recently, though, I decided to try to make a texture editor. Since I don't actually want to write image-editing software, I decided to export the images so they can be edited and then re-imported. But I've run into a problem. The texture for a mesh is stored as a 4-bits-per-pixel bitmap. Each polygon in the mesh has a palette number associated with it, and the appropriate palette is applied to the texture when a polygon is rendered to the screen. The palettes are 16 colors, each color having 5 bits each for R, G, and B and 1 bit for A. The fact that transparency is encoded as an alpha value in palette entries is what's giving me trouble. To make the images easy to edit, I'm applying a palette (whichever one the user selects from among the mesh's 16 palettes) before I export them, but I need to be able to preserve the palette's alpha information in the exported file and during the editing process. If I don't, then either the transparency information will be lost, or two colors that are both transparent will get combined into a single transparent color, which will mess up the image when rendered with one of the other palettes. (Two colors that are transparent in one palette are very likely to be separate opaque colors in another palette.) According to Wikipedia, PNG is supposed to support alpha data in palettes, but I don't see support for that in PIL. PIL does have a PA mode, but I haven't been able to convert P or RGBA images to PA. I get this error: File "/usr/lib/python2.5/site-packages/PIL/Image.py", line 677, in convert im = im.convert(mode, dither) ValueError: conversion from RGB to PA not supported It says that even when I convert the image to P mode first. The Im and Tiff formats in PIL both appear to have support for PA mode, so if I can convert the image to PA, I'm guessing I can save it as one of those. But does anyone know if any image editors have support for alpha data in palettes? I can't remember ever seeing such a thing. Any help would be appreciated, -gomtuu From noboru.uchida.777 at gmail.com Sun Nov 16 19:30:15 2008 From: noboru.uchida.777 at gmail.com (Noboru Uchida) Date: Mon, 17 Nov 2008 03:30:15 +0900 Subject: [Image-SIG] Animated GIF problem In-Reply-To: <491C14A6.4080805@gmail.com> References: <491C14A6.4080805@gmail.com> Message-ID: <492066B7.5010007@gmail.com> Some more explanation. At least, when the disposal method is 2 or 3, C implemantation object is destroyed and replaced with a new one when seeking to next frame. So, palette needs be passed to it, even when the same palette is used. Another problem. wxPython's demo example AG00028_.gif can't be played properly. In this GIF, A man is hola-hooping, and only small part around hoop should be redrawn. 1st frame's disposal method is 1, and it indicates to keep whole image remained. After 2nd frame, small part should be redrawn, whose disposal methods are 2. The problem is, PIL throws away previous image and fills *entire* image with the background color, when disposal method 2 is indicated. I'm not quite familier with Animated GIFs, but I think only the rectangle which is occupied by the previous frame should be filled when disposal method 2 is indicated, isn't it? > Hi. Excuse my poor English. > > * Problem: > > Some animated GIFs can't be played properly. > You can see this using "player.py" sample script and > Animated GIF files, which doesn't have per-frame palettes. > > When playing back Animated GIFs, you can use Image.seek(), > then you call Image.paste() or something. > > I found this is not enough for animated GIF file, which doesn't have > per-frame local palette informations. > > In such a file, the global palette *must* be used to render GIF frame, > but the global palette doesn't seem properly used by PIL. > As a result, after second frame, rendering results are broken. > > * Reason: > > 1. In GifImageFile._open(), ImagePalette instance for > the global palette is created using ImagePalette.raw(), > and saved as "global_palette" variable. > > 2. In GifImageFile.seek(), when GIF file doesn't have per-flame local > palette, global palette is set to "palette" variable. > This is not a copy. Now both "palette" and "global_palette" > point to same ImagePalette instance. > > 3. In Image.load(), palette.dirty, palette.mode and palette.rawmode > are overwritten (why?). > > 4. When seeking to second frame, and second frame doesn't have local > palette, variable "palette" is set to "global_palette". > But, this time, "global_palette" is already overwritten in step 3. > > 5. In Image.load(), this time, palette.dirty is None. More over, > palette.rawmode is broken because of step 3. > As a result, proper palette information seems not given to C > implementation code. > > * Workaround: > > After seek(), I can manually fix palette information as following: > > image.palette.dirty = 1 > image.palette.rawmode = "RGB" > > and do loading/rendering jobs. > But, I think this should be done in PIL code, not users' one. From vixvixreg at gmail.com Fri Nov 14 16:08:51 2008 From: vixvixreg at gmail.com (Vincent Xu) Date: Fri, 14 Nov 2008 10:08:51 -0500 Subject: [Image-SIG] [PIL] Python image library issue: domain users cannot save files Message-ID: Hi, I might have a permission issue when using PIL. If I am a domain user, even I have the permission to write in a folder, when I tried to do simple things like Image.open("foo.tif").save("bar.tif"), i am getting exception IOError ("0", "Error"). I tried to set os.umask(0) before I saved the file but the same exception threw. But If I am a local user, I have no problem with the same script. Does anyone ever have the same situation and know a work around for this? Thanks. Best, Vix -------------- next part -------------- An HTML attachment was scrubbed... URL: From cab938 at mail.usask.ca Tue Nov 18 20:52:23 2008 From: cab938 at mail.usask.ca (Christopher Brooks) Date: Tue, 18 Nov 2008 13:52:23 -0600 Subject: [Image-SIG] Reading images from a TAR file Message-ID: <000101c949b7$2cb804f0$86280ed0$@usask.ca> I've got tar files filled with images that I'm trying to read with PIL. I'm using the following snipit: if file.endswith( ".tar" ): # Read image files out of tar and into memory tar = tarfile.open( file , "r:" ) item = [] #hold a link to a file object for tarinfo in tar: fileobj = tar.extractfile( tarinfo ) im = Image.open( fileobj ) item.append( im ) This doesn't work, I get an exception: Traceback (most recent call last): File "ImageWorker.py", line 84, in results = process( source_files , commands ) File "ImageWorker.py", line 28, in process im = Image.open( fileobj ) File "/usr/lib/python2.5/site-packages/PIL/Image.py", line 1917, in open raise IOError("cannot identify image file") IOError: cannot identify image file This is odd, because the docs for Image.open say: " You can use either a string (representing the filename) or a file object. In the latter case, the file object must implement read, seek, and tell methods, and be opened in binary mode." And the docs for Tar.extractfile say: "Note: The file-like object is read-only and provides the following methods: read(), readline(), readlines(), seek(), tell()." So it seems that contracts are all met. A little bit of googling suggested that the TarIO module might be useful, but I can't seem to find this on PIL module reference page: http://www.pythonware.com/library/pil/handbook/index.htm My question is thus: 1. What's the best practice for reading images out of a tar file with pil and into in-memory Image objects? 2. Which of PIL.open() or the Tar.extractfile() is incorrect in their documentation, and where would I file this as a bug if it is PIL (even if it's just a bug in PILs documentation)? Thanks for any thoughts, Chris -- Christopher Brooks, MSc. Web: http://www.cs.usask.ca/~cab938 Mail: Advanced Research in Intelligent Educational Systems Laboratory Department of Computer Science University of Saskatchewan 176 Thorvaldson Building 110 Science Place Saskatoon, SK S7N 5C9 From njvack at wisc.edu Wed Nov 19 19:53:29 2008 From: njvack at wisc.edu (Nate Vack) Date: Wed, 19 Nov 2008 12:53:29 -0600 Subject: [Image-SIG] Using PIL to read and write PNGs with 16 bits / band? Message-ID: <8be813400811191053u39040db4pd091756986086eae@mail.gmail.com> Hi all, I'm doing some work on eyetracking data, and am interested in storing probability maps and other stuff in PNG images. As a start, I'm using the alpha channel to store a gaze map. I'm worried about losing precision when doing group stats, so I'd like to use 16 bits per band. >From what I can tell from reading past list entries and initial source-diving, the PngImagePlugin doesn't support writing 48 or 64-bit images. I'm less clear on this, but it seems that most of the infrastructure is in-place to support them -- at least, the raw modes for RGBA;16B and RGB;16B are defined and seem to get used when reading. What I can't figure out, though, is how (or whether) those options get transferred over to the Image object that gets created. So... before I go too very far down this rabbit hole, I'm wondering if anyone knows: is this something I can make work by hacking PngImagePlugin, or would I need to delve further into the workings of PIL? Thanks a million, -Nate From Jim.Vickroy at noaa.gov Thu Nov 20 23:15:47 2008 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Thu, 20 Nov 2008 15:15:47 -0700 Subject: [Image-SIG] going between numpy array and PIL.Image not behaving as expected Message-ID: <4925E193.8070500@noaa.gov> Hello all, I am having no success getting numpy and PIL to behave as expected when starting with a numpy array (see the attached script). Here is the output on my computer: Python version: 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] numpy version: 1.2.1 PIL version: 1.1.6 numpy source array: [[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11]] numpy source array shape: (3, 4) PIL image size: (4, 3) Traceback (most recent call last): File "C:\Documents and Settings\jim.vickroy\My Documents\Projects\GOES\SXI\__trials__\numpy-PIL.py", line 30, in ''' % (extrema, image.getextrema()) AssertionError: numpy image extrema (minimum,maximum): (0, 11) PIL image extrema (minimum,maximum): (0, 2) I would appreciate pointers on what I'm doing incorrectly. Thanks, -- jv -------------- next part -------------- A non-text attachment was scrubbed... Name: numpy-PIL.py Type: application/x-python Size: 1194 bytes Desc: not available URL: From cab938 at mail.usask.ca Fri Nov 21 21:22:09 2008 From: cab938 at mail.usask.ca (Christopher Brooks) Date: Fri, 21 Nov 2008 14:22:09 -0600 Subject: [Image-SIG] Mutable images Message-ID: <050101c94c16$d44a9960$7cdfcc20$@usask.ca> I want to resize an image using something like: src_image.resize( (20,20) ) This doesn't work, since resize() returns the new image. So something like: src_image = src_image.resize( (20,20) ) works instead. Problem is that I have other references to the image that src_image is pointing to, and I want them to be updated as well. I thought maybe there would be a load() that takes an Image as a parameter and thus changes the underlying object but not the reference, but this doesn't seem to be the case. Any thoughts on part of the library I'm missing? Chris -- Christopher Brooks, MSc. Web: http://www.cs.usask.ca/~cab938 Mail: Advanced Research in Intelligent Educational Systems Laboratory Department of Computer Science University of Saskatchewan 176 Thorvaldson Building 110 Science Place Saskatoon, SK S7N 5C9 From cannon.el at gmail.com Fri Nov 21 22:30:26 2008 From: cannon.el at gmail.com (Laura & Edward Cannon) Date: Fri, 21 Nov 2008 13:30:26 -0800 Subject: [Image-SIG] Mutable images In-Reply-To: <050101c94c16$d44a9960$7cdfcc20$@usask.ca> References: <050101c94c16$d44a9960$7cdfcc20$@usask.ca> Message-ID: Something that would be simple would be a wrapper class containing an image as an attribute. You could reference the wrapper instead of the image itself, which would solve your problem. I think you could write a wrapper in 20-30 lines of code, and probably have a very small performance hit if any. On Fri, Nov 21, 2008 at 12:22 PM, Christopher Brooks wrote: > I want to resize an image using something like: > > src_image.resize( (20,20) ) > > This doesn't work, since resize() returns the new image. So something like: > > src_image = src_image.resize( (20,20) ) > > works instead. Problem is that I have other references to the image that > src_image is pointing to, and I want them to be updated as well. I thought > maybe there would be a load() that takes an Image as a parameter and thus > changes the underlying object but not the reference, but this doesn't seem > to be the case. > > Any thoughts on part of the library I'm missing? > > Chris > > -- > Christopher Brooks, MSc. > Web: http://www.cs.usask.ca/~cab938 > Mail: Advanced Research in Intelligent Educational Systems Laboratory > Department of Computer Science > University of Saskatchewan > 176 Thorvaldson Building > 110 Science Place > Saskatoon, SK > S7N 5C9 > > > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From Jim.Vickroy at noaa.gov Fri Nov 21 16:45:33 2008 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri, 21 Nov 2008 08:45:33 -0700 Subject: [Image-SIG] going between numpy array and PIL.Image not behaving as expected In-Reply-To: <4926A3D6.7070300@nedbatchelder.com> References: <4925E193.8070500@noaa.gov> <4926A3D6.7070300@nedbatchelder.com> Message-ID: <4926D79D.7010609@noaa.gov> Ned Batchelder wrote: > I'm not sure exactly what you are trying to do here, but the issue has > to do with the mapping of numpy array elements into pixels. Thanks for your clear and detailed reply and sorry for the vagueness of my posting; you did correctly read my mind! > Your code uses 32-bit ints, and fromarray defaults to "L" mode, which > is 8-bit grayscale pixels. fromarray uses the shape of the array to > create the shape of the image, but then just reads bytes until the > image has all the data it needs. In your case, it only needs to read > 3 32-bit ints to get enough bytes to fill the 3x4 "L" mode image. In > the first three ints, the min byte is zero and the max byte is 2, > which your image extrema verifies. > > If you change your code to use this: > > source = numpy.arange(0,12,dtype=numpy.int8) > > then everything will match up: your array has byte elements, and your > image will have byte pixels. Thanks, this does indeed work and your explanation made me wonder why specifying dtype=int (as in my posted script) did not work. Here is the signature of PIL.Image.fromarray in my installation (v 1.1.6): * fromarray(obj, mode=None) so when mode is not specified, the procedure determines it from the attributes of "obj" as follows: if mode is None: typestr = arr['typestr'] if not (typestr[0] == '|' or typestr[0] == _ENDIAN or typestr[1:] not in ['u1', 'b1', 'i4', 'f4']): raise TypeError("cannot handle data-type") typestr = typestr[:2] ##### why isn't this: typestr = typestr[1:] or typestr = typestr[1:3] ? ################## if typestr == 'i4': mode = 'I' elif typestr == 'f4': mode = 'F' elif typestr == 'b1': mode = '1' elif ndim == 2: mode = 'L' elif ndim == 3: mode = 'RGB' elif ndim == 4: mode = 'RGBA' else: raise TypeError("Do not understand data.") I am relatively inexperienced with both PIL and numpy, but the statement: * typestr = typestr[:2] seems to be incorrect; after it is executed, I do not see how typestr can ever be any of ('i4' , 'f4', 'b1'). If I make the indicated change to * typestr = typestr[1:] then "mode" is correctly inferred from "obj" and I do not have to explicitly specify it when applying the fromarray() procedure. Is this a logic error in fromarray()? > > > --Ned. > > Jim Vickroy wrote: >> Hello all, >> >> I am having no success getting numpy and PIL to behave as expected >> when starting with a numpy array (see the attached script). >> >> Here is the output on my computer: >> >> >> Python version: 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 >> 32 bit (Intel)] >> numpy version: 1.2.1 >> PIL version: 1.1.6 >> numpy source array: >> [[ 0 1 2 3] >> [ 4 5 6 7] >> [ 8 9 10 11]] >> numpy source array shape: (3, 4) >> PIL image size: (4, 3) >> Traceback (most recent call last): >> File "C:\Documents and Settings\jim.vickroy\My >> Documents\Projects\GOES\SXI\__trials__\numpy-PIL.py", line 30, in >> >> ''' % (extrema, image.getextrema()) >> AssertionError: >> numpy image extrema (minimum,maximum): (0, 11) >> PIL image extrema (minimum,maximum): (0, 2) >> >> >> >> I would appreciate pointers on what I'm doing incorrectly. >> >> Thanks, >> -- jv >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Image-SIG maillist - Image-SIG at python.org >> http://mail.python.org/mailman/listinfo/image-sig >> > > -- > Ned Batchelder, http://nedbatchelder.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Jim.Vickroy at noaa.gov Fri Nov 21 20:51:12 2008 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri, 21 Nov 2008 12:51:12 -0700 Subject: [Image-SIG] going between numpy array and PIL.Image not behaving as expected -- how to report a bug ? In-Reply-To: <4926FBC3.9080302@nedbatchelder.com> References: <4925E193.8070500@noaa.gov> <4926A3D6.7070300@nedbatchelder.com> <4926D79D.7010609@noaa.gov> <4926FBC3.9080302@nedbatchelder.com> Message-ID: <49271130.4040704@noaa.gov> Ned Batchelder wrote: > Yes, it definitely looks like a bug in fromarray. typestr is ' my environment, and the check against typestr[1:] seems to recognize > this. The line > > typestr = typestr[:2] > > should change, perhaps to: > > typestr = typestr[-2:] > > --Ned. > http://nedbatchelder.com OK, I have been wandering around http://www.pythonware.com/ for a while and have somehow missed the URL for bug reporting. Could someone point me in the right direction? Sorry if I have missed something obvious. P.S. (Ned) Thanks for coverage.py; I was a little slow to make the association! > > Jim Vickroy wrote: >> Ned Batchelder wrote: >>> I'm not sure exactly what you are trying to do here, but the issue >>> has to do with the mapping of numpy array elements into pixels. >> Thanks for your clear and detailed reply and sorry for the vagueness >> of my posting; you did correctly read my mind! >>> Your code uses 32-bit ints, and fromarray defaults to "L" mode, >>> which is 8-bit grayscale pixels. fromarray uses the shape of the >>> array to create the shape of the image, but then just reads bytes >>> until the image has all the data it needs. In your case, it only >>> needs to read 3 32-bit ints to get enough bytes to fill the 3x4 "L" >>> mode image. In the first three ints, the min byte is zero and the >>> max byte is 2, which your image extrema verifies. >>> >>> If you change your code to use this: >>> >>> source = numpy.arange(0,12,dtype=numpy.int8) >>> >>> then everything will match up: your array has byte elements, and >>> your image will have byte pixels. >> Thanks, this does indeed work and your explanation made me wonder why >> specifying dtype=int (as in my posted script) did not work. >> >> Here is the signature of PIL.Image.fromarray in my installation (v >> 1.1.6): >> >> * fromarray(obj, mode=None) >> >> so when mode is not specified, the procedure determines it from the >> attributes of "obj" as follows: >> if mode is None: >> typestr = arr['typestr'] >> if not (typestr[0] == '|' or typestr[0] == _ENDIAN or >> typestr[1:] not in ['u1', 'b1', 'i4', 'f4']): >> raise TypeError("cannot handle data-type") >> typestr = typestr[:2] ##### why isn't this: typestr = >> typestr[1:] or typestr = typestr[1:3] ? ################## >> if typestr == 'i4': >> mode = 'I' >> elif typestr == 'f4': >> mode = 'F' >> elif typestr == 'b1': >> mode = '1' >> elif ndim == 2: >> mode = 'L' >> elif ndim == 3: >> mode = 'RGB' >> elif ndim == 4: >> mode = 'RGBA' >> else: >> raise TypeError("Do not understand data.") >> >> I am relatively inexperienced with both PIL and numpy, but the >> statement: >> >> * typestr = typestr[:2] >> >> seems to be incorrect; after it is executed, I do not see how typestr >> can ever be any of ('i4' , 'f4', 'b1'). >> >> If I make the indicated change to >> >> * typestr = typestr[1:] >> >> then "mode" is correctly inferred from "obj" and I do not have to >> explicitly specify it when applying the fromarray() procedure. >> >> Is this a logic error in fromarray()? >>> >> >>> >>> --Ned. >> >>> >>> Jim Vickroy wrote: >>>> Hello all, >>>> >>>> I am having no success getting numpy and PIL to behave as expected >>>> when starting with a numpy array (see the attached script). >>>> >>>> Here is the output on my computer: >>>> >>>> >>>> Python version: 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC >>>> v.1310 32 bit (Intel)] >>>> numpy version: 1.2.1 >>>> PIL version: 1.1.6 >>>> numpy source array: >>>> [[ 0 1 2 3] >>>> [ 4 5 6 7] >>>> [ 8 9 10 11]] >>>> numpy source array shape: (3, 4) >>>> PIL image size: (4, 3) >>>> Traceback (most recent call last): >>>> File "C:\Documents and Settings\jim.vickroy\My >>>> Documents\Projects\GOES\SXI\__trials__\numpy-PIL.py", line 30, in >>>> >>>> ''' % (extrema, image.getextrema()) >>>> AssertionError: >>>> numpy image extrema (minimum,maximum): (0, 11) >>>> PIL image extrema (minimum,maximum): (0, 2) >>>> >>>> >>>> >>>> I would appreciate pointers on what I'm doing incorrectly. >>>> >>>> Thanks, >>>> -- jv >>>> ------------------------------------------------------------------------ >>>> >>>> _______________________________________________ >>>> Image-SIG maillist - Image-SIG at python.org >>>> http://mail.python.org/mailman/listinfo/image-sig >>>> >>> >>> -- >>> Ned Batchelder, http://nedbatchelder.com >>> >> > > -- > Ned Batchelder, http://nedbatchelder.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ned at nedbatchelder.com Fri Nov 21 13:04:38 2008 From: ned at nedbatchelder.com (Ned Batchelder) Date: Fri, 21 Nov 2008 07:04:38 -0500 Subject: [Image-SIG] going between numpy array and PIL.Image not behaving as expected In-Reply-To: <4925E193.8070500@noaa.gov> References: <4925E193.8070500@noaa.gov> Message-ID: <4926A3D6.7070300@nedbatchelder.com> I'm not sure exactly what you are trying to do here, but the issue has to do with the mapping of numpy array elements into pixels. Your code uses 32-bit ints, and fromarray defaults to "L" mode, which is 8-bit grayscale pixels. fromarray uses the shape of the array to create the shape of the image, but then just reads bytes until the image has all the data it needs. In your case, it only needs to read 3 32-bit ints to get enough bytes to fill the 3x4 "L" mode image. In the first three ints, the min byte is zero and the max byte is 2, which your image extrema verifies. If you change your code to use this: source = numpy.arange(0,12,dtype=numpy.int8) then everything will match up: your array has byte elements, and your image will have byte pixels. --Ned. Jim Vickroy wrote: > Hello all, > > I am having no success getting numpy and PIL to behave as expected > when starting with a numpy array (see the attached script). > > Here is the output on my computer: > > > Python version: 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 > 32 bit (Intel)] > numpy version: 1.2.1 > PIL version: 1.1.6 > numpy source array: > [[ 0 1 2 3] > [ 4 5 6 7] > [ 8 9 10 11]] > numpy source array shape: (3, 4) > PIL image size: (4, 3) > Traceback (most recent call last): > File "C:\Documents and Settings\jim.vickroy\My > Documents\Projects\GOES\SXI\__trials__\numpy-PIL.py", line 30, in > > ''' % (extrema, image.getextrema()) > AssertionError: > numpy image extrema (minimum,maximum): (0, 11) > PIL image extrema (minimum,maximum): (0, 2) > > > > I would appreciate pointers on what I'm doing incorrectly. > > Thanks, > -- jv > ------------------------------------------------------------------------ > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > -- Ned Batchelder, http://nedbatchelder.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ned at nedbatchelder.com Fri Nov 21 19:19:47 2008 From: ned at nedbatchelder.com (Ned Batchelder) Date: Fri, 21 Nov 2008 13:19:47 -0500 Subject: [Image-SIG] going between numpy array and PIL.Image not behaving as expected In-Reply-To: <4926D79D.7010609@noaa.gov> References: <4925E193.8070500@noaa.gov> <4926A3D6.7070300@nedbatchelder.com> <4926D79D.7010609@noaa.gov> Message-ID: <4926FBC3.9080302@nedbatchelder.com> Yes, it definitely looks like a bug in fromarray. typestr is ' Ned Batchelder wrote: >> I'm not sure exactly what you are trying to do here, but the issue >> has to do with the mapping of numpy array elements into pixels. > Thanks for your clear and detailed reply and sorry for the vagueness > of my posting; you did correctly read my mind! >> Your code uses 32-bit ints, and fromarray defaults to "L" mode, which >> is 8-bit grayscale pixels. fromarray uses the shape of the array to >> create the shape of the image, but then just reads bytes until the >> image has all the data it needs. In your case, it only needs to read >> 3 32-bit ints to get enough bytes to fill the 3x4 "L" mode image. In >> the first three ints, the min byte is zero and the max byte is 2, >> which your image extrema verifies. >> >> If you change your code to use this: >> >> source = numpy.arange(0,12,dtype=numpy.int8) >> >> then everything will match up: your array has byte elements, and your >> image will have byte pixels. > Thanks, this does indeed work and your explanation made me wonder why > specifying dtype=int (as in my posted script) did not work. > > Here is the signature of PIL.Image.fromarray in my installation (v 1.1.6): > > * fromarray(obj, mode=None) > > so when mode is not specified, the procedure determines it from the > attributes of "obj" as follows: > if mode is None: > typestr = arr['typestr'] > if not (typestr[0] == '|' or typestr[0] == _ENDIAN or > typestr[1:] not in ['u1', 'b1', 'i4', 'f4']): > raise TypeError("cannot handle data-type") > typestr = typestr[:2] ##### why isn't this: typestr = > typestr[1:] or typestr = typestr[1:3] ? ################## > if typestr == 'i4': > mode = 'I' > elif typestr == 'f4': > mode = 'F' > elif typestr == 'b1': > mode = '1' > elif ndim == 2: > mode = 'L' > elif ndim == 3: > mode = 'RGB' > elif ndim == 4: > mode = 'RGBA' > else: > raise TypeError("Do not understand data.") > > I am relatively inexperienced with both PIL and numpy, but the > statement: > > * typestr = typestr[:2] > > seems to be incorrect; after it is executed, I do not see how typestr > can ever be any of ('i4' , 'f4', 'b1'). > > If I make the indicated change to > > * typestr = typestr[1:] > > then "mode" is correctly inferred from "obj" and I do not have to > explicitly specify it when applying the fromarray() procedure. > > Is this a logic error in fromarray()? >> > >> >> --Ned. > >> >> Jim Vickroy wrote: >>> Hello all, >>> >>> I am having no success getting numpy and PIL to behave as expected >>> when starting with a numpy array (see the attached script). >>> >>> Here is the output on my computer: >>> >>> >>> Python version: 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC >>> v.1310 32 bit (Intel)] >>> numpy version: 1.2.1 >>> PIL version: 1.1.6 >>> numpy source array: >>> [[ 0 1 2 3] >>> [ 4 5 6 7] >>> [ 8 9 10 11]] >>> numpy source array shape: (3, 4) >>> PIL image size: (4, 3) >>> Traceback (most recent call last): >>> File "C:\Documents and Settings\jim.vickroy\My >>> Documents\Projects\GOES\SXI\__trials__\numpy-PIL.py", line 30, in >>> >>> ''' % (extrema, image.getextrema()) >>> AssertionError: >>> numpy image extrema (minimum,maximum): (0, 11) >>> PIL image extrema (minimum,maximum): (0, 2) >>> >>> >>> >>> I would appreciate pointers on what I'm doing incorrectly. >>> >>> Thanks, >>> -- jv >>> ------------------------------------------------------------------------ >>> >>> _______________________________________________ >>> Image-SIG maillist - Image-SIG at python.org >>> http://mail.python.org/mailman/listinfo/image-sig >>> >> >> -- >> Ned Batchelder, http://nedbatchelder.com >> > -- Ned Batchelder, http://nedbatchelder.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From wrybread at gmail.com Fri Nov 21 21:31:22 2008 From: wrybread at gmail.com (Alec Bennett) Date: Fri, 21 Nov 2008 12:31:22 -0800 Subject: [Image-SIG] Mutable images In-Reply-To: <050101c94c16$d44a9960$7cdfcc20$@usask.ca> References: <050101c94c16$d44a9960$7cdfcc20$@usask.ca> Message-ID: Seems too obvious to mention, but: src_image2 = src_image.resize( (20,20) ) On Fri, Nov 21, 2008 at 12:22 PM, Christopher Brooks wrote: > I want to resize an image using something like: > > src_image.resize( (20,20) ) > > This doesn't work, since resize() returns the new image. So something > like: > > src_image = src_image.resize( (20,20) ) > > works instead. Problem is that I have other references to the image that > src_image is pointing to, and I want them to be updated as well. I thought > maybe there would be a load() that takes an Image as a parameter and thus > changes the underlying object but not the reference, but this doesn't seem > to be the case. > > Any thoughts on part of the library I'm missing? > > Chris > > -- > Christopher Brooks, MSc. > Web: http://www.cs.usask.ca/~cab938 > Mail: Advanced Research in Intelligent Educational Systems Laboratory > Department of Computer Science > University of Saskatchewan > 176 Thorvaldson Building > 110 Science Place > Saskatoon, SK > S7N 5C9 > > > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Chris.Barker at noaa.gov Fri Nov 21 23:46:26 2008 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Fri, 21 Nov 2008 14:46:26 -0800 Subject: [Image-SIG] going between numpy array and PIL.Image not behaving as expected -- how to report a bug ? In-Reply-To: <49271130.4040704@noaa.gov> References: <4925E193.8070500@noaa.gov> <4926A3D6.7070300@nedbatchelder.com> <4926D79D.7010609@noaa.gov> <4926FBC3.9080302@nedbatchelder.com> <49271130.4040704@noaa.gov> Message-ID: <49273A42.7050400@noaa.gov> Jim Vickroy wrote: > Ned Batchelder wrote: >> Yes, it definitely looks like a bug in fromarray. typestr is '> my environment, and the check against typestr[1:] seems to recognize >> this. The line >> >> typestr = typestr[:2] >> >> should change, perhaps to: >> >> typestr = typestr[-2:] >> >> --Ned. >> http://nedbatchelder.com > OK, I have been wandering around http://www.pythonware.com/ for a while > and have somehow missed the URL for bug reporting. Could someone point > me in the right direction? I think this list may be as good as it gets for posting bug reports/patches. However that code was written by the numpy folks -- it would be a good idea to post this on the numpy list. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker at noaa.gov From Jim.Vickroy at noaa.gov Fri Nov 21 23:53:11 2008 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Fri, 21 Nov 2008 15:53:11 -0700 Subject: [Image-SIG] going between numpy array and PIL.Image not behaving as expected -- how to report a bug ? In-Reply-To: <49273A42.7050400@noaa.gov> References: <4925E193.8070500@noaa.gov> <4926A3D6.7070300@nedbatchelder.com> <4926D79D.7010609@noaa.gov> <4926FBC3.9080302@nedbatchelder.com> <49271130.4040704@noaa.gov> <49273A42.7050400@noaa.gov> Message-ID: <49273BD7.6000908@noaa.gov> Christopher Barker wrote: > Jim Vickroy wrote: >> Ned Batchelder wrote: >>> Yes, it definitely looks like a bug in fromarray. typestr is '>> in my environment, and the check against typestr[1:] seems to >>> recognize this. The line >>> >>> typestr = typestr[:2] >>> >>> should change, perhaps to: >>> >>> typestr = typestr[-2:] >>> >>> --Ned. >>> http://nedbatchelder.com >> OK, I have been wandering around http://www.pythonware.com/ for a >> while and have somehow missed the URL for bug reporting. Could >> someone point me in the right direction? > > I think this list may be as good as it gets for posting bug > reports/patches. However that code was written by the numpy folks -- > it would be a good idea to post this on the numpy list. Thanks, I will do that. > > -Chris > > > From ispiked at gmail.com Sun Nov 23 19:16:40 2008 From: ispiked at gmail.com (Adam Guthrie) Date: Sun, 23 Nov 2008 13:16:40 -0500 Subject: [Image-SIG] Creating an image from 's getImageData() data Message-ID: I'm using 's getImageData() function [0] to extract pixel data from a canvas. The function returns a CanvasPixelArray, which is just a comma-separated list of all the RGBA pixel values. I then try to create an image using Image.fromstring as follows: data = # remove the commas from the string data = data.replace(',', '') im = Image.fromstring("RGBA", (80,80), data) im.save("image.jpg") This all works fine without any errors. However, the resulting image is not the same as area that I extracted from the canvas. Here's an example of the resulting image: http://img92.imageshack.us/img92/3495/newimagept1.jpg. And here's an example of the expected image: http://img92.imageshack.us/img92/2562/graphxy9.jpg. I can't figure out what I'm doing wrong here. Does the "raw" decoder accept raw pixel data like this, or does it only like raw image formats with proper headers, etc. like BMPs. Do I need to write my own custom decoder? Thanks, Adam Guthrie [0] http://www.whatwg.org/specs/web-apps/current-work/#dom-context-2d-getimagedata From njvack at wisc.edu Tue Nov 25 22:20:49 2008 From: njvack at wisc.edu (Nate Vack) Date: Tue, 25 Nov 2008 15:20:49 -0600 Subject: [Image-SIG] Fix for writing tEXT chunks in PNG images Message-ID: <8be813400811251320s2a75dda5v19675b1043a61b2c@mail.gmail.com> Hi all, I'm writing PNG images and looking to save analysis info in tEXT metadata. I found Nick's most excellent workaround at http://blog.modp.com/2007/08/python-pil-and-png-metadata-take-2.html and built off it so you can just use the standard save() method on images. It's right on the verge of being a monkey patch ;-) Here's a post and the code: http://freshforever.net/2008/11/writing-png-metadata-in-pil-using-imagesave/ And, if it's easier, a pastie: http://pastie.org/323865 Alway -Nate From Jim.Vickroy at noaa.gov Mon Nov 24 19:35:46 2008 From: Jim.Vickroy at noaa.gov (Jim Vickroy) Date: Mon, 24 Nov 2008 11:35:46 -0700 Subject: [Image-SIG] PIL 1.1.6 patch submission for numpy interface Message-ID: <492AF402.4000602@noaa.gov> I request that line 1832: * typestr = typestr[:2] in the fromarray() function of the PIL 1.1.6 Image.py module be changed to: * typestr = typestr[1:] to address the problem previously documented at: * http://projects.scipy.org/pipermail/numpy-discussion/2006-December/024903.html Robert Kern and Travis Oliphant (numpy) suggested that I submit this change request to the PIL list since the numpy developers do not have PIL CVS privileges. Thanks, -- jv -------------- next part -------------- An HTML attachment was scrubbed... URL: From seongjoo.lee at gmail.com Tue Nov 25 07:12:06 2008 From: seongjoo.lee at gmail.com (Lee Seongjoo) Date: Tue, 25 Nov 2008 15:12:06 +0900 Subject: [Image-SIG] Fail to install PIL 1.1.6 for Python 2.5 Windows Message-ID: <2be03dc30811242212x54d5633du760945506f9c91b5@mail.gmail.com> Hello, PIL 1.1.6 for Python 2.5 on Windows failed. I think the problem was Python is running at the time of installation. Another attempt was failed even after Python was terminated. Help? -- Lee Seongjoo -------------- next part -------------- An HTML attachment was scrubbed... URL: From s-gerencia at regalzl.com Tue Nov 25 17:05:03 2008 From: s-gerencia at regalzl.com (SECRETARIA DE GERENCIA DE RGAL INTERNACIONAL) Date: Tue, 25 Nov 2008 10:05:03 -0600 Subject: [Image-SIG] PIL license question Message-ID: <000501c94f17$9410f070$b76fa8c0@REGAL.REGALZL> Hello, I need that please they helps me with the number of telephone of your representativ in Panama Regards Hilda Isaza -------------- next part -------------- An HTML attachment was scrubbed... URL: From rhh2109 at columbia.edu Thu Nov 27 09:30:04 2008 From: rhh2109 at columbia.edu (Roy H. Han) Date: Thu, 27 Nov 2008 03:30:04 -0500 Subject: [Image-SIG] Using GIMP filters within a Python script Message-ID: <6a5569ec0811270030u64c45210gbdb7e0e90f1b79a9@mail.gmail.com> Hi, Is there a way to access the filters available in GIMP to process images within Python? I see that there is a way to write Python-based plugins for GIMP, but I would like to call GIMP filters from Python. Maybe this is a naive question. I also see that there is an ImageFilter class in PIL, but GIMP has so many filters already written that I wondered whether I could use GIMP's filters right away. Thanks, RHH -------------- next part -------------- An HTML attachment was scrubbed... URL: From mann_sar at hotmail.com Fri Nov 28 17:05:40 2008 From: mann_sar at hotmail.com (Mandar Sarlashkar) Date: Fri, 28 Nov 2008 21:35:40 +0530 Subject: [Image-SIG] Patch Analysis Message-ID: Dear all, I am planning to use PIL in my assignment. One of the tasks is to calculate index such as 'Patch Density' for a classified Land-use Land Cover Image. I am not getting how to handle different class patches in an image. How can I retrieve information for each patch such as area and perimeter?I can use FRAGSTAS for getting such indices but a python script or guidance how it can be done using python and PIL will be more helpful. Thanking you for your time and consideration in advance.Regards,Maddy _________________________________________________________________ Search for videos of Bollywood, Hollywood, Mollywood and every other wood, only on Live.com http://www.live.com/?scope=video&form=MICOAL -------------- next part -------------- An HTML attachment was scrubbed... URL: From newz at bearfruit.org Sat Nov 29 03:49:10 2008 From: newz at bearfruit.org (Matthew Nuzum) Date: Fri, 28 Nov 2008 20:49:10 -0600 Subject: [Image-SIG] Using GIMP filters within a Python script In-Reply-To: <6a5569ec0811270030u64c45210gbdb7e0e90f1b79a9@mail.gmail.com> References: <6a5569ec0811270030u64c45210gbdb7e0e90f1b79a9@mail.gmail.com> Message-ID: 2008/11/27 Roy H. Han : > Is there a way to access the filters available in GIMP to process images > within Python? > I see that there is a way to write Python-based plugins for GIMP, but I > would like to call GIMP filters from Python. Hi, don't consider my answer definitive, but I believe there is. I was looking at the inkscape export to xcf feature and it is apparently a python script that controls gimp. Unfortunately it's not pure python, it looks like it's a python script that launches gimp and feeds in some of gimp's own scripting language (scheme?), but none the less it's about what you're asking and the code is readily available. http://inkscape.svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/share/extensions/gimp_xcf.py?view=markup -- Matthew Nuzum newz2000 on freenode From gwidion at mpc.com.br Sat Nov 29 05:52:23 2008 From: gwidion at mpc.com.br (Joao S. O. Bueno) Date: Sat, 29 Nov 2008 02:52:23 -0200 Subject: [Image-SIG] Using GIMP filters within a Python script In-Reply-To: References: <6a5569ec0811270030u64c45210gbdb7e0e90f1b79a9@mail.gmail.com> Message-ID: <200811290252.23374.gwidion@mpc.com.br> On Saturday 29 November 2008, Matthew Nuzum wrote: > 2008/11/27 Roy H. Han : > > Is there a way to access the filters available in GIMP to process images > > within Python? > > I see that there is a way to write Python-based plugins for GIMP, but I > > would like to call GIMP filters from Python. Hi there - You'd have to write a gimp-plug-in that acts like a "listener" bound to a tcp socket, http, named pipe or something, and then initiate gimp-actions in it from an external process. That is either that or starting gimp with no display, passing a script-fu command to call the desired plug-in at each use. (which is what inskcape's xcf import Mathew talks about does) Fortunatellya GIMP "listener" plug-in isin python is nto a hard thing to do., Ihave a nive http implementation of one. Try and download it from http://www.pion.com.br/~gwidion/logo_server.zip best wishes. js -><- > > Hi, don't consider my answer definitive, but I believe there is. I was > looking at the inkscape export to xcf feature and it is apparently a > python script that controls gimp. Unfortunately it's not pure python, > it looks like it's a python script that launches gimp and feeds in > some of gimp's own scripting language (scheme?), but none the less > it's about what you're asking and the code is readily available. > > http://inkscape.svn.sourceforge.net/viewvc/inkscape/inkscape/trunk/share/ex >tensions/gimp_xcf.py?view=markup From frederic.mantegazza at gbiloba.org Sat Nov 29 08:51:38 2008 From: frederic.mantegazza at gbiloba.org (=?iso-8859-15?q?Fr=E9d=E9ric?=) Date: Sat, 29 Nov 2008 08:51:38 +0100 Subject: [Image-SIG] Using GIMP filters within a Python script In-Reply-To: <6a5569ec0811270030u64c45210gbdb7e0e90f1b79a9@mail.gmail.com> References: <6a5569ec0811270030u64c45210gbdb7e0e90f1b79a9@mail.gmail.com> Message-ID: <200811290851.38811.frederic.mantegazza@gbiloba.org> On jeudi 27 novembre 2008, Roy H. Han wrote: > Is there a way to access the filters available in GIMP to process images > within Python? > I see that there is a way to write Python-based plugins for GIMP, but I > would like to call GIMP filters from Python. > Maybe this is a naive question. > I also see that there is an ImageFilter class in PIL, but GIMP has so > many filters already written that I wondered whether I could use GIMP's > filters right away. Why not using the new GEGL lib, which Gimp will now use? There are already python binding, and GEGL already has some basic filtering features: http://www.gegl.org http://gegl.org/pygegl http://www.gegl.org/operations.html -- Fr?d?ric http://www.gbiloba.org From starsareblueandfaraway at gmail.com Fri Nov 28 18:56:31 2008 From: starsareblueandfaraway at gmail.com (Roy H. Han) Date: Fri, 28 Nov 2008 12:56:31 -0500 Subject: [Image-SIG] Patch Analysis In-Reply-To: <6a5569ec0811280955i10a637e4j7af747a2c793bcf5@mail.gmail.com> References: <6a5569ec0811280955i10a637e4j7af747a2c793bcf5@mail.gmail.com> Message-ID: <6a5569ec0811280956t2ebc92c6h1bd3d732b917cae8@mail.gmail.com> Mandar, How are you getting your patches? If you are doing it on a pixel by pixel basis, then you can simply count the number of pixels in a patch to estimate the area and you can count the number of pixels in an outline of the patch to estimate the perimeter. On Fri, Nov 28, 2008 at 12:55 PM, Roy H. Han < starsareblueandfaraway at gmail.com> wrote: > How are you getting your patches? > If you are doing it on a pixel by pixel basis, then you can simply count > the number of pixels in a patch to estimate the area and you can count the > number of pixels in an outline of the patch to estimate the perimeter. > > 2008/11/28 Mandar Sarlashkar > >> >> Dear all, >> >> I am planning to use PIL in my assignment. >> >> One of the tasks is to calculate index such as 'Patch Density' for a >> classified Land-use Land Cover Image. >> >> I am not getting how to handle different class patches in an image. >> >> How can I retrieve information for each patch such as area and perimeter? >> >> I can use FRAGSTAS for getting such indices but a python script >> or guidance how it can be done using python and PIL will be more helpful. >> >> Thanking you for your time and consideration in advance. >> >> Regards, >> >> Maddy >> >> ------------------------------ >> What's on the ramp today could be on the streets tomorrow. Keep up with >> trends on MSN Lifestyle Try it! >> >> _______________________________________________ >> Image-SIG maillist - Image-SIG at python.org >> http://mail.python.org/mailman/listinfo/image-sig >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From blake at hailmail.net Sun Nov 30 00:30:14 2008 From: blake at hailmail.net (Dane Springmeyer) Date: Sat, 29 Nov 2008 15:30:14 -0800 Subject: [Image-SIG] Patch Analysis In-Reply-To: References: Message-ID: Hello Maddy, I'd look into GDAL and/or Grass, since to do such area and perimeter calculations in real world units you'll have more success working with the data using software that understands coordinate systems. Both GDAL and Grass have possibilities for scripting in python. If you can figure out how to do feature-based summaries with pure python and PIL, I'd be interested to hear about your approach. Dane On Nov 28, 2008, at 8:05 AM, Mandar Sarlashkar wrote: > > Dear all, > > I am planning to use PIL in my assignment. > > One of the tasks is to calculate index such as 'Patch Density' for a > classified Land-use Land Cover Image. > > I am not getting how to handle different class patches in an image. > How can I retrieve information for each patch such as area and > perimeter? > I can use FRAGSTAS for getting such indices but a python script > or guidance how it can be done using python and PIL will be more > helpful. > Thanking you for your time and consideration in advance. > Regards, > Maddy > > What's on the ramp today could be on the streets tomorrow. Keep up > with trends on MSN Lifestyle Try it! > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig -------------- next part -------------- An HTML attachment was scrubbed... URL: