From charlie.clark at clark-consulting.eu Fri Apr 1 20:30:50 2011 From: charlie.clark at clark-consulting.eu (Charlie Clark) Date: Fri, 01 Apr 2011 20:30:50 +0200 Subject: [Image-SIG] Comparing images Message-ID: Hi, I need to check lot of images to see if they have the right logo in them. Fortunately I know the co-ordinates of where the logo in the image should be but I'm not sure on the best way to compare a selection from the image with a template. Currently I'm cropping the target image to the right size and comparing it with ImageChops.difference() with the template but I'm not sure how to interpret the results - I had hoped for either a largely black or white image but I'm largely getting the inverse of the logo. Any tips? Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Helmholtzstr. 20 D?sseldorf D- 40215 Tel: +49-211-600-3657 Mobile: +49-178-782-6226 From charlie.clark at clark-consulting.eu Fri Apr 1 21:37:12 2011 From: charlie.clark at clark-consulting.eu (Charlie Clark) Date: Fri, 01 Apr 2011 21:37:12 +0200 Subject: [Image-SIG] Comparing images In-Reply-To: References: Message-ID: Am 01.04.2011, 20:30 Uhr, schrieb Charlie Clark : > Hi, > I need to check lot of images to see if they have the right logo in > them. Fortunately I know the co-ordinates of where the logo in the image > should be but I'm not sure on the best way to compare a selection from > the image with a template. Currently I'm cropping the target image to > the right size and comparing it with ImageChops.difference() with the > template but I'm not sure how to interpret the results - I had hoped for > either a largely black or white image but I'm largely getting the > inverse of the logo. > Any tips? Gah, search a little harder and I find, of course, that effbot has already answered this! http://effbot.org/zone/pil-comparing-images.htm Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Helmholtzstr. 20 D?sseldorf D- 40215 Tel: +49-211-600-3657 Mobile: +49-178-782-6226 From dennis at brainstorm-digital.com Fri Apr 1 17:03:09 2011 From: dennis at brainstorm-digital.com (Dennis Huynh) Date: Fri, 01 Apr 2011 11:03:09 -0400 Subject: [Image-SIG] how to read metadata from jpg Message-ID: <4D95E92D.3030400@brainstorm-digital.com> how do you read the metadata from a jpeg with PIL? What module do I use? -------------- next part -------------- A non-text attachment was scrubbed... Name: dennis.vcf Type: text/x-vcard Size: 281 bytes Desc: not available URL: From vincentvsauce at gmail.com Fri Apr 1 21:25:15 2011 From: vincentvsauce at gmail.com (Vincent) Date: Fri, 1 Apr 2011 12:25:15 -0700 Subject: [Image-SIG] Crashed when Installing on window x64 Message-ID: I download both 1.1.7 & 1.1.6 PIL and when I tried to install the library it crash after clicking install. There's no problem finding the register Python but it crashed when trying to install. Does the library conflict with other imaging processing installed on the computer? I'm running on Windows 7 x64 bit. And Python 2.6 x32bit. -- Vincent -------------- next part -------------- An HTML attachment was scrubbed... URL: From raul1st2002 at gmail.com Tue Apr 5 04:57:53 2011 From: raul1st2002 at gmail.com (Ding Wei) Date: Mon, 4 Apr 2011 22:57:53 -0400 Subject: [Image-SIG] how can I open 32 float tiff with PIL? Message-ID: Hi there guys, I'm new to the Python and PIL. I want to open a 32 float tiff file with pil. But I always get a error like this: raise IOError("cannot identify image file") IOError: cannot identify image file I tried two different method to do the open? 1. import Image im = Image.open(?test.tif?? 2. import Image fp = open(?test.tif?, ?rb?) im = Image.open(fp? 8 bit RGB file works just fine, but neither 16bit or 32 bit can be opened. Did I do something wrong? Thank you for your help! -------------- next part -------------- An HTML attachment was scrubbed... URL: From charlie.clark at clark-consulting.eu Wed Apr 6 13:24:03 2011 From: charlie.clark at clark-consulting.eu (Charlie Clark) Date: Wed, 06 Apr 2011 13:24:03 +0200 Subject: [Image-SIG] how to read metadata from jpg In-Reply-To: <4D95E92D.3030400@brainstorm-digital.com> References: <4D95E92D.3030400@brainstorm-digital.com> Message-ID: Am 01.04.2011, 17:03 Uhr, schrieb Dennis Huynh : > how do you read the metadata from a jpeg with PIL? What module do I use? Hi Dennis, from PIL import ExifTags Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Helmholtzstr. 20 D?sseldorf D- 40215 Tel: +49-211-600-3657 Mobile: +49-178-782-6226 From dale at blackbagtech.com Wed Apr 6 18:30:24 2011 From: dale at blackbagtech.com (Dale Cieslak) Date: Wed, 6 Apr 2011 09:30:24 -0700 Subject: [Image-SIG] how can I open 32 float tiff with PIL? In-Reply-To: References: Message-ID: <90E33AEE-2FE5-4CFC-B144-85D2F10B2F75@blackbagtech.com> I had something similar. It all depends on whether the particular type of TIFF is supported by the TiffImagePlugin.py module. If you have a type of TIFF that doesn't match one of the types it supports, you're out of luck. You can try to convert the TIFF to a different format or try to patch the TiffImagePlugin.py module, which isn't trivial since you mentioned being new to Python. Best of luck, Dale On Apr 4, 2011, at 7:57 PM, Ding Wei wrote: > Hi there guys, > > I'm new to the Python and PIL. I want to open a 32 float tiff file with pil. But I always get a error like this: > > raise IOError("cannot identify image file") > IOError: cannot identify image file > > I tried two different method to do the open? > > 1. > import Image > im = Image.open(?test.tif?? > > 2. > import Image > fp = open(?test.tif?, ?rb?) > im = Image.open(fp? > > 8 bit RGB file works just fine, but neither 16bit or 32 bit can be opened. > > Did I do something wrong? > > Thank you for your help! > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 3739 bytes Desc: not available URL: From cannon.el at gmail.com Wed Apr 6 21:44:40 2011 From: cannon.el at gmail.com (Edward Cannon) Date: Wed, 6 Apr 2011 12:44:40 -0700 Subject: [Image-SIG] Crashed when Installing on window x64 In-Reply-To: References: Message-ID: <79CAC756-AC1C-4348-8A8C-E9D4D496B8C8@gmail.com> Make sure you have the32 bit PIL. I had similar issues and that was the problem. Also make sure you have 32 bit Python and not 64 by mistake. Edward Cannon Unicorn School On Apr 1, 2011, at 12:25 PM, Vincent wrote: > I download both 1.1.7 & 1.1.6 PIL and when I tried to install the library it crash after clicking install. There's no problem finding the register Python but it crashed when trying to install. Does the library conflict with other imaging processing installed on the computer? > > I'm running on Windows 7 x64 bit. And Python 2.6 x32bit. > > -- > Vincent > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig From cgohlke at uci.edu Wed Apr 6 22:10:42 2011 From: cgohlke at uci.edu (Christoph Gohlke) Date: Wed, 06 Apr 2011 13:10:42 -0700 Subject: [Image-SIG] Crashed when Installing on window x64 In-Reply-To: References: Message-ID: <4D9CC8C2.6050900@uci.edu> On 4/1/2011 12:25 PM, Vincent wrote: > I download both 1.1.7 & 1.1.6 PIL and when I tried to install the > library it crash after clicking install. There's no problem finding the > register Python but it crashed when trying to install. Does the library > conflict with other imaging processing installed on the computer? > > I'm running on Windows 7 x64 bit. And Python 2.6 x32bit. > > -- > Vincent > You could try open PIL-1.1.7.win32-py2.6.exe with an unzip program, e.g. WinRAR, and extract the content from PLATLIB to your Python26\Lib\site-packages directory. Christoph From cannon.el at gmail.com Wed Apr 6 21:47:48 2011 From: cannon.el at gmail.com (Edward Cannon) Date: Wed, 6 Apr 2011 12:47:48 -0700 Subject: [Image-SIG] how can I open 32 float tiff with PIL? In-Reply-To: <90E33AEE-2FE5-4CFC-B144-85D2F10B2F75@blackbagtech.com> References: <90E33AEE-2FE5-4CFC-B144-85D2F10B2F75@blackbagtech.com> Message-ID: <77829BA1-33C7-4843-982B-033996C77D12@gmail.com> Also look at the compression type that seems to usually be more of a hangup than the bit depth. On Apr 6, 2011, at 9:30 AM, Dale Cieslak wrote: > I had something similar. It all depends on whether the particular type of TIFF is supported by the TiffImagePlugin.py module. If you have a type of TIFF that doesn't match one of the types it supports, you're out of luck. You can try to convert the TIFF to a different format or try to patch the TiffImagePlugin.py module, which isn't trivial since you mentioned being new to Python. > > Best of luck, > Dale > > On Apr 4, 2011, at 7:57 PM, Ding Wei wrote: > >> Hi there guys, >> >> I'm new to the Python and PIL. I want to open a 32 float tiff file with pil. But I always get a error like this: >> >> raise IOError("cannot identify image file") >> IOError: cannot identify image file >> >> I tried two different method to do the open? >> >> 1. >> import Image >> im = Image.open(?test.tif?? >> >> 2. >> import Image >> fp = open(?test.tif?, ?rb?) >> im = Image.open(fp? >> >> 8 bit RGB file works just fine, but neither 16bit or 32 bit can be opened. >> >> Did I do something wrong? >> >> Thank you for your help! >> _______________________________________________ >> Image-SIG maillist - Image-SIG at python.org >> http://mail.python.org/mailman/listinfo/image-sig > > _______________________________________________ > 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 jdb at sitrep3.com Wed Apr 13 13:27:14 2011 From: jdb at sitrep3.com (=?UTF-8?B?Sm9lIEJvcsSh?=) Date: Wed, 13 Apr 2011 12:27:14 +0100 Subject: [Image-SIG] Image module destructor Message-ID: Hi, Just wondering if there is a way to destruct after use, for example: img = Image.open("/dir/to/file.png") img.info img.close So that I have to start from open in order to carry on using. Thanks Regards, Joseph David Bor? http://www.jdborg.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From charlie.clark at clark-consulting.eu Thu Apr 14 19:54:48 2011 From: charlie.clark at clark-consulting.eu (Charlie Clark) Date: Thu, 14 Apr 2011 19:54:48 +0200 Subject: [Image-SIG] Image module destructor In-Reply-To: References: Message-ID: Am 13.04.2011, 13:27 Uhr, schrieb Joe Bor? : > Hi, > Just wondering if there is a way to destruct after use, for example: > img = Image.open("/dir/to/file.png") > img.info > img.close > So that I have to start from open in order to carry on using. You can always just delete the object in Python: del img I don't think that explicitly invokes a destructor but it does stop you doing *anything* with the image subsequently. Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Helmholtzstr. 20 D?sseldorf D- 40215 Tel: +49-211-600-3657 Mobile: +49-178-782-6226 From sybaco at gmail.com Fri Apr 15 04:44:26 2011 From: sybaco at gmail.com (SYBA-CO) Date: Thu, 14 Apr 2011 22:44:26 -0400 Subject: [Image-SIG] Basic question Message-ID: Hi everyone, I'm new to python I have been battling with the installation of the PIL library, I have not been successful, I'm using Python 2.7 I also have the 3.x installed, but I'm using the 2.7 version for PIL compatibility. Can someone help me in the PIL installation If some one does help me, could you please provide the info in explicit detail. Oh yes I am. On a windows 7 system. Thank you very much. Sj. From seb.haase at gmail.com Fri Apr 15 09:47:55 2011 From: seb.haase at gmail.com (Sebastian Haase) Date: Fri, 15 Apr 2011 09:47:55 +0200 Subject: [Image-SIG] Basic question In-Reply-To: References: Message-ID: Hi, you have to tell us more details, like what have you done so far, where did you get which files, if you expect any help. -Sebastian Haase On Fri, Apr 15, 2011 at 4:44 AM, SYBA-CO wrote: > Hi everyone, I'm new to python I have been battling with the > installation of the PIL library, I have not been successful, I'm using > Python 2.7 I also have the 3.x installed, but I'm using the 2.7 > version for PIL compatibility. Can someone help me in the PIL > installation > If some one does help me, could you please provide the info in > explicit detail. Oh yes I am. On a windows 7 system. > Thank you very much. > Sj. > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From gabor at nekomancer.net Fri Apr 15 15:37:51 2011 From: gabor at nekomancer.net (=?ISO-8859-1?Q?G=E1bor_Farkas?=) Date: Fri, 15 Apr 2011 15:37:51 +0200 Subject: [Image-SIG] memoryError in FpxImageUploadPlugin.py Message-ID: hi, we have a python webserver that handles files uploaded by the users. some of those files cause a MemoryError in PIL. (unfortunately i do not have such a file). as you can see, it happens in the FpxImagPlugin: (pil 1.1.7) im = Image.open(original) File "/usr/local/lib/python2.6/site-packages/PIL/Image.py", line 1976, in open return factory(fp, filename) File "/usr/local/lib/python2.6/site-packages/PIL/ImageFile.py", line 91, in __init__ self._open() File "/usr/local/lib/python2.6/site-packages/PIL/FpxImagePlugin.py", line 61, in _open self.ole = OleFileIO(self.fp) File "/usr/local/lib/python2.6/site-packages/PIL/OleFileIO.py", line 260, in __init__ self.open(filename) File "/usr/local/lib/python2.6/site-packages/PIL/OleFileIO.py", line 289, in open self.loadfat(header) File "/usr/local/lib/python2.6/site-packages/PIL/OleFileIO.py", line 309, in loadfat s = self.getsect(ix) File "/usr/local/lib/python2.6/site-packages/PIL/OleFileIO.py", line 324, in getsect self.fp.seek(512 + self.sectorsize * sect) MemoryError any ideas what might cause this? alternatively, is there a way to tell PIL to only try to handle a given list of file-types? for example, in my cases, i only care about JPG/PNG/GIF... so i do not need PIL to try to find out if the file is in other formats.. is there any way do a fileformat-whitelist? thanks, gabor From seb.haase at gmail.com Fri Apr 15 15:54:56 2011 From: seb.haase at gmail.com (Sebastian Haase) Date: Fri, 15 Apr 2011 15:54:56 +0200 Subject: [Image-SIG] Basic question In-Reply-To: References: Message-ID: try >>>? import Image capital ! and/or >>> from PIL import Image -S On Fri, Apr 15, 2011 at 2:52 PM, SYBA-CO wrote: > > Hello Everyone, > Ok. > I have downloaded the PIL file from this location > http://www.pythonware.com/products/pil/#pil117 > > the module is ver 1.1.7 for Python 2.7 (windows Only 32bit) > PIL-1.1.7.win32-py2.7.exe > http://effbot.org/downloads/PIL-1.1.7.win32-py2.7.exe > > after downloading the module I clicked to install, it does give me feedback saying it found Python 2.7 in my registry and it is installing > That is what I have done so far, > > I try to use it by inserting the import image command in my program and I run it. I get an error " can't find the image module". > > so since i am new to Python have I missed a path alteration or have i missed any instructions somewhere, I do not have fundamental knowledge of the python directory structure IE: when you issue an import command does the interpreter scan a predefined path or how all that happens, I may need a visual explanation of the structure such as \lib\..lib\site...\ libs\ etc... > It is possible that because of my novice status I have missed a setup procedure........ > what other details would you like to know please let me know. > Thank you everyone, > Simon > > On Fri, Apr 15, 2011 at 3:47 AM, Sebastian Haase wrote: >> >> Hi, >> you have to tell us more details, like what have you done so far, >> where did you get which files, >> if you expect any help. >> >> -Sebastian Haase >> >> >> On Fri, Apr 15, 2011 at 4:44 AM, SYBA-CO wrote: >> > Hi everyone, I'm new to python I have been battling with the >> > installation of the PIL library, I have not been successful, I'm using >> > Python 2.7 I also have the 3.x installed, but I'm using the 2.7 >> > version for PIL compatibility. Can someone help me in the PIL >> > installation >> > If some one does help me, could you please provide the info in >> > explicit detail. Oh yes I am. On a windows 7 system. >> > Thank you very much. >> > Sj. >> > _______________________________________________ >> > Image-SIG maillist ?- ?Image-SIG at python.org >> > http://mail.python.org/mailman/listinfo/image-sig >> > > From gabor at nekomancer.net Sat Apr 16 17:51:38 2011 From: gabor at nekomancer.net (=?ISO-8859-1?Q?G=E1bor_Farkas?=) Date: Sat, 16 Apr 2011 17:51:38 +0200 Subject: [Image-SIG] memoryError in FpxImageUploadPlugin.py In-Reply-To: References: Message-ID: 2011/4/16 Alec Bennett : >> i only care about JPG/PNG/GIF... >> is there any way?do a fileformat-whitelist? > > Seems almost too obvious to mention, but you could do something like: > fname = "something.jpg" > image_extensions = (".jpg", ".png", ".gif") > extension = os.path.splitext(fname)[1].lower() > if extension in image_extensions: > ?? ?print "its an image!" > ?? ?do_some_stuff(fname) is PIL's image-format-detection purely filename-extension based? i mean, what happens if i take the problematic file, and rename it to have a jpeg-extension... will PIL not try the other file-format-plugins, when jpeg fails? gabor From wrybread at gmail.com Sat Apr 16 00:23:37 2011 From: wrybread at gmail.com (Alec Bennett) Date: Fri, 15 Apr 2011 15:23:37 -0700 Subject: [Image-SIG] memoryError in FpxImageUploadPlugin.py In-Reply-To: References: Message-ID: > i only care about JPG/PNG/GIF... > is there any way do a fileformat-whitelist? Seems almost too obvious to mention, but you could do something like: fname = "something.jpg" image_extensions = (".jpg", ".png", ".gif") extension = os.path.splitext(fname)[1].lower() if extension in image_extensions: print "its an image!" do_some_stuff(fname) 2011/4/15 G?bor Farkas > hi, > > we have a python webserver that handles files uploaded by the users. > some of those files cause a MemoryError in PIL. > (unfortunately i do not have such a file). as you can see, it happens > in the FpxImagPlugin: > (pil 1.1.7) > > im = Image.open(original) > File "/usr/local/lib/python2.6/site-packages/PIL/Image.py", line 1976, in > open > return factory(fp, filename) > File "/usr/local/lib/python2.6/site-packages/PIL/ImageFile.py", line > 91, in __init__ > self._open() > File "/usr/local/lib/python2.6/site-packages/PIL/FpxImagePlugin.py", > line 61, in _open > self.ole = OleFileIO(self.fp) > File "/usr/local/lib/python2.6/site-packages/PIL/OleFileIO.py", line > 260, in __init__ > self.open(filename) > File "/usr/local/lib/python2.6/site-packages/PIL/OleFileIO.py", line > 289, in open > self.loadfat(header) > File "/usr/local/lib/python2.6/site-packages/PIL/OleFileIO.py", line > 309, in loadfat > s = self.getsect(ix) > File "/usr/local/lib/python2.6/site-packages/PIL/OleFileIO.py", line > 324, in getsect > self.fp.seek(512 + self.sectorsize * sect) > MemoryError > > any ideas what might cause this? > > alternatively, is there a way to tell PIL to only try to handle a > given list of file-types? > for example, in my cases, i only care about JPG/PNG/GIF... so i do not need > PIL > to try to find out if the file is in other formats.. is there any way > do a fileformat-whitelist? > > thanks, > gabor > _______________________________________________ > 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 biomech at bionyx.ca Sat Apr 16 09:27:04 2011 From: biomech at bionyx.ca (Steven Hand) Date: Sat, 16 Apr 2011 01:27:04 -0600 Subject: [Image-SIG] TGA id field handling Message-ID: I have some TGA files that cannot be read by the PIL TgaImagePlugin just because they use the "id" field. This is easily fixed with the following changes to PIL/TgaImagePlugin.py. Can someone add these changes to the next release? --- /Users/steve/Downloads/Imaging-1.1.7/PIL/TgaImagePlugin.py 2009-10-31 18:44:12.000000000 -0600 +++ TgaImagePlugin.py 2011-04-15 20:58:31.000000000 -0600 @@ -45,7 +45,7 @@ def _accept(prefix): - return prefix[0] == "\0" + return True ## # Image plugin for Targa files. @@ -62,6 +62,8 @@ id = ord(s[0]) + self.fp.read( id ) + colormaptype = ord(s[1]) imagetype = ord(s[2]) @@ -72,7 +74,7 @@ self.size = i16(s[12:]), i16(s[14:]) # validate header fields - if id != 0 or colormaptype not in (0, 1) or\ + if colormaptype not in (0, 1) or\ self.size[0] <= 0 or self.size[1] <= 0 or\ depth not in (1, 8, 16, 24, 32): raise SyntaxError, "not a TGA file" -------------- next part -------------- An HTML attachment was scrubbed... URL: From charlie.clark at clark-consulting.eu Sun Apr 17 00:13:57 2011 From: charlie.clark at clark-consulting.eu (Charlie Clark) Date: Sun, 17 Apr 2011 00:13:57 +0200 Subject: [Image-SIG] memoryError in FpxImageUploadPlugin.py In-Reply-To: References: Message-ID: Am 16.04.2011, 17:51 Uhr, schrieb G?bor Farkas : > is PIL's image-format-detection purely filename-extension based? > i mean, what happens if i take the problematic file, and rename it > to have a jpeg-extension... will PIL not try the other > file-format-plugins, > when jpeg fails? No, PIL won'.t It isn't brilliant but that's how it works. Try and think through the converse: this could be JPEG but I'll work my way through the alternatives till I'm sure. In your situation it seems perfectly reasonable to expect the MIME-type to be available, so you can enforce it in the form handling. Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Helmholtzstr. 20 D?sseldorf D- 40215 Tel: +49-211-600-3657 Mobile: +49-178-782-6226 From wrybread at gmail.com Sun Apr 17 20:09:11 2011 From: wrybread at gmail.com (Alec Bennett) Date: Sun, 17 Apr 2011 20:09:11 +0200 Subject: [Image-SIG] memoryError in FpxImageUploadPlugin.py In-Reply-To: References: Message-ID: <16978779-D7DF-49FB-989B-1F5709264657@gmail.com> Agreed in a web form situation it seems reasonable to expect the file to have the correct file extension. And in fact that's the usual safeguard against people uploading php scripts or whatever containing malicious code. But if you really want to be able to detect file type independently of the extension you might research reading the file header. (that's a guess, I'm not saying that will definitely work). Sent from my payphone On Apr 17, 2011, at 12:13 AM, "Charlie Clark" wrote: > Am 16.04.2011, 17:51 Uhr, schrieb G?bor Farkas : > >> is PIL's image-format-detection purely filename-extension based? >> i mean, what happens if i take the problematic file, and rename it >> to have a jpeg-extension... will PIL not try the other file-format-plugins, >> when jpeg fails? > > No, PIL won'.t It isn't brilliant but that's how it works. Try and think through the converse: this could be JPEG but I'll work my way through the alternatives till I'm sure. In your situation it seems perfectly reasonable to expect the MIME-type to be available, so you can enforce it in the form handling. > > Charlie > -- > Charlie Clark > Managing Director > Clark Consulting & Research > German Office > Helmholtzstr. 20 > D?sseldorf > D- 40215 > Tel: +49-211-600-3657 > Mobile: +49-178-782-6226 > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig From edward at unicornschool.org Sun Apr 17 20:19:13 2011 From: edward at unicornschool.org (Edward Cannon) Date: Sun, 17 Apr 2011 11:19:13 -0700 Subject: [Image-SIG] memoryError in FpxImageUploadPlugin.py In-Reply-To: <16978779-D7DF-49FB-989B-1F5709264657@gmail.com> References: <16978779-D7DF-49FB-989B-1F5709264657@gmail.com> Message-ID: One of the things you might want to consider is that users are uploading either large or corrupted images. This might cause problems. Also if something else on the server is not playing nice this could cause problems. I would try wrapping the open call in a try... except loop. That way you could handle the error gracefully, perhaps by prompting the user to wait or try a smaller image. AFIK PIL does not look at file extensions, but at magic numbers when opening a file, it uses extensions primarily when saving files. Edward Cannon Unicorn School On Sun, Apr 17, 2011 at 11:09 AM, Alec Bennett wrote: > Agreed in a web form situation it seems reasonable to expect the file to have the correct file extension. And in fact that's the usual safeguard against people uploading php scripts or whatever containing malicious code. > > But if you really want to be able to detect file type independently of the extension you might research reading the file header. (that's a guess, I'm not saying that will definitely work). > > > > > Sent from my payphone > > On Apr 17, 2011, at 12:13 AM, "Charlie Clark" wrote: > >> Am 16.04.2011, 17:51 Uhr, schrieb G?bor Farkas : >> >>> is PIL's image-format-detection purely filename-extension based? >>> i mean, what happens if i take the problematic file, and rename it >>> to have a jpeg-extension... will PIL not try the other file-format-plugins, >>> when jpeg fails? >> >> No, PIL won'.t It isn't brilliant but that's how it works. Try and think through the converse: this could be JPEG but I'll work my way through the alternatives till I'm sure. In your situation it seems perfectly reasonable to expect the MIME-type to be available, so you can enforce it in the form handling. >> >> Charlie >> -- >> Charlie Clark >> Managing Director >> Clark Consulting & Research >> German Office >> Helmholtzstr. 20 >> D?sseldorf >> D- 40215 >> Tel: +49-211-600-3657 >> Mobile: +49-178-782-6226 >> _______________________________________________ >> Image-SIG maillist ?- ?Image-SIG at python.org >> http://mail.python.org/mailman/listinfo/image-sig > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From dschulz at gmail.com Sun Apr 17 07:19:26 2011 From: dschulz at gmail.com (Diego Schulz) Date: Sun, 17 Apr 2011 01:19:26 -0400 Subject: [Image-SIG] Minor problem building PIL on x86_64 under virtualenv Message-ID: Hi all, Please excuse me if this is not the apropriate list to discuss this. I was trying to build PIL in a virtual environment with pip, and after installing all the required packages (runtime and devel) in the host system, setup.py was still unable to detect the libraries. I'm working on Ubuntu 11.04 (not released yet), amd64. After some experimentation I realized that setup.py was looking in standard places (ie /usr/lib) and that works just fine with x86, but in x86_64 it really needs to look in '/usr/lib/x86_64-linux-gnu' since there's where the lib files are to be found. TL;DR Having problems building PIL in a virtual env with pip (Ubuntu 11.04 amd64), just added a line to setup.py and it works now. ---------------------------------------------------------------- ... # standard locations add_directory(library_dirs, "/usr/local/lib") add_directory(include_dirs, "/usr/local/include") add_directory(library_dirs, "/usr/lib/x86_64-linux-gnu") ##### <<<--- ADDED THIS add_directory(library_dirs, "/usr/lib") add_directory(include_dirs, "/usr/include") ... ... ---------------------------------------------------------------- I'm not sure if this is a general solution for x86_64 systems other than Debian-based ones, but it will surely can save some time to the next random guy who tries what I'm up to. cheers, diego -------------- next part -------------- An HTML attachment was scrubbed... URL: From charlie.clark at clark-consulting.eu Mon Apr 18 20:23:05 2011 From: charlie.clark at clark-consulting.eu (Charlie Clark) Date: Mon, 18 Apr 2011 20:23:05 +0200 Subject: [Image-SIG] Minor problem building PIL on x86_64 under virtualenv In-Reply-To: References: Message-ID: Am 17.04.2011, 07:19 Uhr, schrieb Diego Schulz : > Having problems building PIL in a virtual env with pip (Ubuntu 11.04 > amd64), > just added a line to setup.py and it works now. FWIW PIL is generally considered not to be safe for use with easy_install or pip. There is, however, Pillow which is PIL packaged for use with pip, easy_install and buildout. Charlie -- Charlie Clark Managing Director Clark Consulting & Research German Office Helmholtzstr. 20 D?sseldorf D- 40215 Tel: +49-211-600-3657 Mobile: +49-178-782-6226 From john_16 at list.ru Tue Apr 19 04:09:46 2011 From: john_16 at list.ru (=?utf-8?Q?JOHN=5F16?=) Date: Tue, 19 Apr 2011 06:09:46 +0400 Subject: [Image-SIG] perhaps bug report Message-ID: Hello. This message consist of two parts: 1) I found this situation: i have 2 same images in PNG format, but first save in RGB mode and second in 8-bit mode. FOr creating i use Pant.NET program on Windows XP SP3. PIL 1.1.7, Python 2.6.2 . In next you see code and result of executing: # -*- coding: utf-8 -*- import Image, ImageDraw for path in (r'C:\1.png',r'C:\2.png'): ??? image=Image.open(path) ??? print image.format, image.mode, image.size ??? ??? draw=ImageDraw.Draw(image) ??? draw.line(((0,0),image.size), width=3, fill='green') ??? image.show() PNG RGB (804, 1082) PNG P (804, 1082) Traceback (most recent call last): ? File "C:\Documents and Settings\mer\workspace\test\src\tst.py", line 9, in ??? draw.line(((0,0),image.size), width=3, fill='green') ? File "C:\Python26\Lib\site-packages\PIL\ImageDraw.py", line 198, in line ??? ink, fill = self._getink(fill) ? File "C:\Python26\Lib\site-packages\PIL\ImageDraw.py", line 145, in _getink ??? ink = self.palette.getcolor(ink) ? File "C:\Python26\Lib\site-packages\PIL\ImagePalette.py", line 62, in getcolor ??? self.palette = map(int, self.palette) ValueError: invalid literal for int() with base 10: '' This situation also founded on PIL 1.1.7, Python 2.7, openSUSE 11.4 Linux See in debuf founded place were raise exception and i think that is not my error in code. Is it bug? 2) in PIL version 1.1.7 on Windows if i do ImageFont.truetype() than i get exception because not _imagingft service in system? (like in Linux). is this normal situation on Windows & Where i can get this ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From cgohlke at uci.edu Tue Apr 19 06:44:36 2011 From: cgohlke at uci.edu (Christoph Gohlke) Date: Mon, 18 Apr 2011 21:44:36 -0700 Subject: [Image-SIG] perhaps bug report In-Reply-To: References: Message-ID: <4DAD1334.6070301@uci.edu> On 4/18/2011 7:09 PM, JOHN_16 wrote: > Hello. This message consist of two parts: > > 1) > I found this situation: i have 2 same images in PNG format, but first > save in RGB mode and second in 8-bit mode. FOr creating i use Pant.NET > program on Windows XP SP3. > PIL 1.1.7, Python 2.6.2 . In next you see code and result of executing: > > # -*- coding: utf-8 -*- > import Image, ImageDraw > > for path in (r'C:\1.png',r'C:\2.png'): > image=Image.open(path) > print image.format, image.mode, image.size > > draw=ImageDraw.Draw(image) > draw.line(((0,0),image.size), width=3, fill='green') > image.show() > > > > PNG RGB (804, 1082) > PNG P (804, 1082) > Traceback (most recent call last): > File "C:\Documents and Settings\mer\workspace\test\src\tst.py", line 9, > in > draw.line(((0,0),image.size), width=3, fill='green') > File "C:\Python26\Lib\site-packages\PIL\ImageDraw.py", line 198, in line > ink, fill = self._getink(fill) > File "C:\Python26\Lib\site-packages\PIL\ImageDraw.py", line 145, in _getink > ink = self.palette.getcolor(ink) > File "C:\Python26\Lib\site-packages\PIL\ImagePalette.py", line 62, in > getcolor > self.palette = map(int, self.palette) > ValueError: invalid literal for int() with base 10: '' > That should be `self.palette = map(ord, self.palette)` in ImagePalette.py", line 62. > This situation also founded on PIL 1.1.7, Python 2.7, openSUSE 11.4 Linux > See in debuf founded place were raise exception and i think that is not > my error in code. > Is it bug? > > 2) in PIL version 1.1.7 on Windows if i do ImageFont.truetype() than i > get exception because not _imagingft service in system (like in Linux). > is this normal situation on Windows & Where i can get this ? Try Christoph From rmazurel at zonnet.nl Wed Apr 20 07:33:38 2011 From: rmazurel at zonnet.nl (Ronald Mazurel) Date: Wed, 20 Apr 2011 07:33:38 +0200 Subject: [Image-SIG] installation PIL 1.1.7 Message-ID: <000e01cbff1c$805c9770$8115c650$@nl> Hello, I've installed Python 2.7 on a 64 bit computer, Windows Premium Home system. Installing Pil 1.1.7 was not succesfull with the file I found on your site: PIL-1.1.7.win32-py2.7.exe Message: Python version 2.7 required, wich was not found in the registry. Any idea how to solve this? Thanks for your answer, Ronald -------------- next part -------------- An HTML attachment was scrubbed... URL: From jhonlier12017 at hlg.jovenclub.cu Thu Apr 21 03:48:07 2011 From: jhonlier12017 at hlg.jovenclub.cu (Jhonlier Suarez Molina) Date: Wed, 20 Apr 2011 21:48:07 -0400 Subject: [Image-SIG] About PIL.Image.Image.rotate method refinement Message-ID: <4DAF8CD7.8040006@hlg.jovenclub.cu> When I was using PIL.Image.Image.rotate (expand=True) to make a sequence of rotations to be joined later in a clip; but I found a trouble: my object vibrates because the resulting vertex move around the expected vertex. This is harmful for animations because you get undesirable tremble. So I try the problem forcing the resulting surface size to be odd in both dimentions, because the middle of these "odd" surfaces is exactly a pixel, not a pixel given for rounding. Remember that the middle of 1 2 3 4 5 6 7 8 9 clearly is 5, but the center of 1 2 3 4 is "somewhere" beetwen 2 and 3. I rewrite the "rotate" method: def rotate(self, angle, resample=NEAREST, expand=0): "Rotate image. Angle given as degrees counter-clockwise." if expand: import math angle = -angle * math.pi / 180 matrix = [ math.cos(angle), math.sin(angle), 0.0, -math.sin(angle), math.cos(angle), 0.0 ] def transform(x, y, (a, b, c, d, e, f)=matrix): return a*x + b*y + c, d*x + e*y + f # calculate output size w, h = self.size xx = [] yy = [] for x, y in ((0, 0), (w, 0), (w, h), (0, h)): x, y = transform(x, y) xx.append(x) yy.append(y) w = int(math.ceil(max(xx)) - math.floor(min(xx))) h = int(math.ceil(max(yy)) - math.floor(min(yy))) # adjust center x, y = transform(w / 2.0, h / 2.0) matrix[2] = self.size[0] / 2.0 - x matrix[5] = self.size[1] / 2.0 - y return self.transform((w, h), AFFINE, matrix) if resample not in (NEAREST, BILINEAR, BICUBIC): raise ValueError("unknown resampling filter") self.load() if self.mode in ("1", "P"): resample = NEAREST return self._new(self.im.rotate(angle, resample)) for this: def rotate(self, angle, resample=NEAREST, expand=0): "Rotate image. Angle given as degrees counter-clockwise." if expand: import math angle = -angle * math.pi / 180 matrix = [ math.cos(angle), math.sin(angle), 0.0, -math.sin(angle), math.cos(angle), 0.0 ] def transform(x, y, (a, b, c, d, e, f)=matrix): return a*x + b*y + c, d*x + e*y + f # calculate output size w0, h0 = w, h = self.size xx = [] yy = [] for x, y in ((0, 0), (w, 0), (w, h), (0, h)): x, y = transform(x, y) xx.append(x) yy.append(y) w = int(math.ceil(max(xx)) - math.floor(min(xx))) if w & 1== 0: w += 1 h = int(math.ceil(max(yy)) - math.floor(min(yy))) if h & 1== 0: h += 1 # adjust center x, y = transform(w / 2.0, h / 2.0) matrix[2] = w0 / 2.0 - x matrix[5] = h0 / 2.0 - y return self.transform((w, h), AFFINE, matrix) if resample not in (NEAREST, BILINEAR, BICUBIC): raise ValueError("unknown resampling filter") self.load() if self.mode in ("1", "P"): resample = NEAREST return self._new(self.im.rotate(angle, resample)) This really works I am using it now and no more Parkinson in my animations. Saludos, Jhonlier -- __________ Informaci?n de ESET NOD32 Antivirus, versi?n de la base de firmas de virus 6059 (20110420) __________ ESET NOD32 Antivirus ha comprobado este mensaje. http://www.eset.com -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: LaComputadoradelafamiliacubana.jpg Type: image/jpeg Size: 5339 bytes Desc: not available URL: From bilalgarwood at hotmail.com Sun Apr 24 14:42:27 2011 From: bilalgarwood at hotmail.com (Bilal Garwood) Date: Sun, 24 Apr 2011 12:42:27 +0000 Subject: [Image-SIG] Hi - trying to make gif anims Message-ID: Hi support people I am using pygame and want to take a sequence of images from my game and make them into a gif anim. If possible I need help to import other modules and apply them to get what I want. I can save successive images using the pygame.image.save module, but this only allows saving in TGA, BMP(unformatted), JPEG or PNG. I have to convert the image to a gif format. the part I am stuck on is not the header and extension blocks of the gif, but the decoding of image data. It seems to switch the indexing away from a regular colour palette that has index FF or 255 as black. I think it has reshuffled the indexing somewhere, because my most used colour is blue and that is ascribed the FF index. I need to know how pygame.image.save rearranges the indices in the file. If anyone can help me around this problem, or suggest a simpler way that takes advantage of PIL modules and save to a gif animation I would be very grateful. Thanks in advance for your help -I think if this problem is solved it will probably contribute to a new pygame module, because gif animations could show previews of developers' gameplay, rather than static screenshots. Bilal -------------- next part -------------- An HTML attachment was scrubbed... URL: