From rowen at uw.edu Fri Apr 6 01:45:06 2012 From: rowen at uw.edu (Russell E. Owen) Date: Thu, 05 Apr 2012 16:45:06 -0700 Subject: [Image-SIG] PIL on Python 2.7? References: <7610a32e8be1b.4f6fc453@rug.nl> Message-ID: In article <7610a32e8be1b.4f6fc453 at rug.nl>, "B.Canatan" wrote: > ?Hi all, > > Will PIL work on Python 2.7 (on a Linux machine)? > > Sincerely, > Baris > --------------------------------------------------------------------- > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig The bits of PIL that I use work just fine on Python 2.7. -- Russell From elmar at net4werling.de Tue Apr 10 21:11:58 2012 From: elmar at net4werling.de (elmar werling) Date: Tue, 10 Apr 2012 21:11:58 +0200 Subject: [Image-SIG] Macinthos PIC files Message-ID: Hi everyone, I have pictures in Macinthos PIC/PICT format (HDR image (image/x-hdr),see appendix. Can anyone suggest a simple way to convert the pictures into JPEG-format? Thanks -------------- next part -------------- A non-text attachment was scrubbed... Name: example.pic Type: image/x-hdr Size: 24646 bytes Desc: not available URL: From chris.barker at noaa.gov Tue Apr 10 23:57:41 2012 From: chris.barker at noaa.gov (Chris Barker) Date: Tue, 10 Apr 2012 14:57:41 -0700 Subject: [Image-SIG] Macinthos PIC files In-Reply-To: <4F849C81.4060706@net4werling.de> References: <4F849C81.4060706@net4werling.de> Message-ID: On Tue, Apr 10, 2012 at 1:48 PM, Elmar Werling wrote: > Am 10.04.2012 21:46, schrieb Chris Barker: > >> On Tue, Apr 10, 2012 at 12:11 PM, elmar werling >> ?wrote: >> >>> I have pictures in Macinthos PIC/PICT format (HDR image (image/x-hdr),see >>> appendix. >>> >>> Can anyone suggest a simple way to convert the pictures into JPEG-format? >> >> Wow! OS-X "Preview" doesn't even know what to so with it -- this may be >> tough! >> >> Image Magik identifies it, but thinks the header is invalid: >> >> $ identify example.pic >> example.pic PICT 640x480 640x480+0+0 8-bit DirectClass 24.6KB 0.010u >> 0:00.019 >> identify: improper image header >> `/var/folders/Dc/Dc6nkuThGN0thxlW3QBBVXu0AwA/-Tmp-/magick-ZTHN3MI2' @ >> error/pict.c/ReadPICTImage/881. >> >> >> Are you sure that file is good? >> >> -Chris >> >> > Yea, file is good. Just changed to Windows / IrfanView and converted it to > JPEG (see appendix) maybe it got corrupted in download -- I"d give ImageMagick a try, and also maybe the python-mac list (or other mac list)m for ideas. -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 elmar at net4werling.de Wed Apr 11 12:21:07 2012 From: elmar at net4werling.de (elmar werling) Date: Wed, 11 Apr 2012 12:21:07 +0200 Subject: [Image-SIG] Macinthos PIC files In-Reply-To: References: <4F849C81.4060706@net4werling.de> Message-ID: Am 10.04.2012 23:57, schrieb Chris Barker: > On Tue, Apr 10, 2012 at 1:48 PM, Elmar Werling wrote: >> Am 10.04.2012 21:46, schrieb Chris Barker: >> >>> On Tue, Apr 10, 2012 at 12:11 PM, elmar werling >>> wrote: >>> >>>> I have pictures in Macinthos PIC/PICT format (HDR image (image/x-hdr),see >>>> appendix. >>>> >>>> Can anyone suggest a simple way to convert the pictures into JPEG-format? >>> >>> Wow! OS-X "Preview" doesn't even know what to so with it -- this may be >>> tough! >>> >>> Image Magik identifies it, but thinks the header is invalid: >>> >>> $ identify example.pic >>> example.pic PICT 640x480 640x480+0+0 8-bit DirectClass 24.6KB 0.010u >>> 0:00.019 >>> identify: improper image header >>> `/var/folders/Dc/Dc6nkuThGN0thxlW3QBBVXu0AwA/-Tmp-/magick-ZTHN3MI2' @ >>> error/pict.c/ReadPICTImage/881. >>> >>> >>> Are you sure that file is good? >>> >>> -Chris >>> >>> >> Yea, file is good. Just changed to Windows / IrfanView and converted it to >> JPEG (see appendix) > > maybe it got corrupted in download -- I"d give ImageMagick a try, and > also maybe the python-mac list (or other mac list)m for ideas. > > -Chris > > > downloaded file is ok. I just opened it with IrfanView. Elmar From Chare at labr.net Fri Apr 27 13:28:11 2012 From: Chare at labr.net (Chris Hare) Date: Fri, 27 Apr 2012 06:28:11 -0500 Subject: [Image-SIG] PIL and converting an image to and from a string value Message-ID: <199BC357-B628-4B67-A2C1-7EC69327C0EE@labr.net> Here is what I am trying to: the application user chooses an image file. I want to store the image data in a field in a sqlite database. My understanding from the reading I have done is that I have to convert the image data into a string , which I can then store in the database. Additionally, I need to be able to take the stored image data and convert it back to an image so I can display it in a canvas widget. I am using the python imaging library I think I have the following parts correct: image = Image.open("cover.jpg") image = image.resize((150,150),Image.ANTIALIAS) png = image.tostring("PNG") I am taking the image data from the file, resizing the image, and then using the PNG coder to force it into a PNG format image and converting it to a string. I am stuck however, in figuring out how to take the string data and converting it back to an image that I can put into the canvas widget. Either I am not finding a good explanation of how to do this or I am just not understanding what I am finding:-) Any ideas are appreciated! Thanks, Chris From charlesc-pyimagesig at pyropus.ca Fri Apr 27 15:21:44 2012 From: charlesc-pyimagesig at pyropus.ca (Charles Cazabon) Date: Fri, 27 Apr 2012 07:21:44 -0600 Subject: [Image-SIG] PIL and converting an image to and from a string value In-Reply-To: <199BC357-B628-4B67-A2C1-7EC69327C0EE@labr.net> References: <199BC357-B628-4B67-A2C1-7EC69327C0EE@labr.net> Message-ID: <20120427132143.GA11894@pyropus.ca> Chris Hare wrote: > > I am stuck however, in figuring out how to take the string data and > converting it back to an image that I can put into the canvas widget. See the PIL handbook, where it says "If you have an entire image file in a string, wrap it in a StringIO object, and use open to load it." Charles -- ------------------------------------------------------------------ Charles Cazabon Software, consulting, and services available at http://pyropus.ca/ ------------------------------------------------------------------ From chare at labr.net Fri Apr 27 16:35:44 2012 From: chare at labr.net (Chris Hare) Date: Fri, 27 Apr 2012 09:35:44 -0500 Subject: [Image-SIG] PIL and converting an image to and from a string value In-Reply-To: <20120427132143.GA11894@pyropus.ca> References: <199BC357-B628-4B67-A2C1-7EC69327C0EE@labr.net> <20120427132143.GA11894@pyropus.ca> Message-ID: <380CE3AE-B1E7-449E-B426-64CC5C4F036D@labr.net> okay - I have an error but I don't understand what I got wrong: self.imageBuffer = StringIO.StringIO() image = Image.open(filename) image = image.resize((150,150),Image.ANTIALIAS) image.save(self.imageBuffer, format= 'PNG') image = Image.open(self.imageBuffer) IOError: cannot identify image file The error occurs when trying to open the imageBuffer so I can work with the data in the buffer. What have I missed? On Apr 27, 2012, at 8:21 AM, Charles Cazabon wrote: > Chris Hare wrote: >> >> I am stuck however, in figuring out how to take the string data and >> converting it back to an image that I can put into the canvas widget. > > See the PIL handbook, where it says "If you have an entire image file in a > string, wrap it in a StringIO object, and use open to load it." > > Charles > -- > ------------------------------------------------------------------ > Charles Cazabon > Software, consulting, and services available at http://pyropus.ca/ > ------------------------------------------------------------------ > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig From gdr at garethrees.org Fri Apr 27 16:55:53 2012 From: gdr at garethrees.org (Gareth Rees) Date: Fri, 27 Apr 2012 15:55:53 +0100 Subject: [Image-SIG] PIL and converting an image to and from a string value In-Reply-To: <380CE3AE-B1E7-449E-B426-64CC5C4F036D@labr.net> References: <199BC357-B628-4B67-A2C1-7EC69327C0EE@labr.net> <20120427132143.GA11894@pyropus.ca> <380CE3AE-B1E7-449E-B426-64CC5C4F036D@labr.net> Message-ID: Chris Hare wrote: > okay - I have an error but I don't understand what I got wrong: > > self.imageBuffer = StringIO.StringIO() > image = Image.open(filename) > image = image.resize((150,150),Image.ANTIALIAS) > image.save(self.imageBuffer, format= 'PNG') > image = Image.open(self.imageBuffer) > IOError: cannot identify image file > > The error occurs when trying to open the imageBuffer so I can work with the data in the buffer. What have I missed? You need to rewind to the start of the buffer before trying to read from it: self.imageBuffer.seek(0) -- Gareth Rees From chris.barker at noaa.gov Fri Apr 27 17:50:47 2012 From: chris.barker at noaa.gov (Chris Barker) Date: Fri, 27 Apr 2012 08:50:47 -0700 Subject: [Image-SIG] PIL and converting an image to and from a string value In-Reply-To: <20120427132143.GA11894@pyropus.ca> References: <199BC357-B628-4B67-A2C1-7EC69327C0EE@labr.net> <20120427132143.GA11894@pyropus.ca> Message-ID: On Fri, Apr 27, 2012 at 6:21 AM, Charles Cazabon wrote: >> I am stuck however, in figuring out how to take the string data and >> converting it back to an image that I can put into the canvas widget. > > See the PIL handbook, where it says "If you have an entire image file in a > string, wrap it in a StringIO object, and use open to load it." Actually, I don't think that's what the OP wants. A couple notes: 1) "string" is a confusing term -- generally it means text, but in python (2.*) it means "an arrbitrary sequence of bytes, that can be interpreteed as text depending on context" -- that is why there is now a "string" object and a "bytes" object. IN py2, bytes and string are the same, but it's handy to use bytes for future compatibility with py3, and for clarity in your code. So in this case, we are talking about bytes objects. (side note: make sure you are storing bytes objects in your DB properly -- as a binary blob, so that it doens't mess with the data) Now the real point: you can store an image in two ways (at least) in a bytes object: 1) essentially a binary dump of what would be in an encoced file (PNG, whatever). This is would you d get if you did: the_image_bytes = file("an_image.png", 'rb').read() 2) a binary dump of the bytes in memeory of the image object, without encoding or compression -- this is waht you get whn you do: the_image_bytes = a_pil_image.tostring() The STringIO suggestion refers to the former, but I thikn the OP was dealing with the later. In the later case, you can re-construct teh image object with: Image.fromstring(mode, size, data) => image so: a_pil_image = Image.fromstring('RGB', (300, 500), the_image_bytes) note that you'll need to keep track of what the made and size of the image are -- PIL can't figure that out just from the data. Depending on your needs, you may in fact want to store the PNG-encoded bytes in the DB, and decode them when you pull them out, using the StringIO strick. HTH, -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 Chare at labr.net Fri Apr 27 17:59:09 2012 From: Chare at labr.net (Chris Hare) Date: Fri, 27 Apr 2012 10:59:09 -0500 Subject: [Image-SIG] PIL and converting an image to and from a string value In-Reply-To: References: <199BC357-B628-4B67-A2C1-7EC69327C0EE@labr.net> <20120427132143.GA11894@pyropus.ca> <380CE3AE-B1E7-449E-B426-64CC5C4F036D@labr.net> Message-ID: Thanks! That did it. The second part of my function is to drop the image in the StringIO buffer into a Tkinter canvas widget. If I do this: self.imageBuffer.seek(0) image = Image.open(self.imageBuffer) self.picture1.create_image(0, 0, image = image ) self.picture1 = Canvas(self.pictureFrame,width=150,height=150) I get: Exception in Tkinter callback Traceback (most recent call last): File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 1410, in __call__ return self.func(*args) File "z.py", line 802, in changePicture1 self.picture1.create_image(0, 0, image = image ) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 2198, in create_image return self._create('image', args, kw) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 2189, in _create *(args + self._options(cnf, kw)))) TclError: image "" doesn't exist If I change the code to use the image rest from Image.open above to create a TkImage.PhotoImage, self.imageBuffer.seek(0) image = Image.open(self.imageBuffer) photo = PhotoImage(image) self.picture1.create_image(0, 0, image = photo ) I get yet a different exception: Exception in Tkinter callback Traceback (most recent call last): File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 1410, in __call__ return self.func(*args) File "z.py", line 803, in changePicture1 self.picture1.create_image(0, 0, image = photo ) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 2198, in create_image return self._create('image', args, kw) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 2189, in _create *(args + self._options(cnf, kw)))) TypeError: __str__ returned non-string (type instance) Not sure what I got wrong. Based on what I think I understand fro the man pages and some net searches, I think either case should be okay. On Apr 27, 2012, at 9:55 AM, Gareth Rees wrote: > Chris Hare wrote: >> okay - I have an error but I don't understand what I got wrong: >> >> self.imageBuffer = StringIO.StringIO() >> image = Image.open(filename) >> image = image.resize((150,150),Image.ANTIALIAS) >> image.save(self.imageBuffer, format= 'PNG') >> image = Image.open(self.imageBuffer) >> IOError: cannot identify image file >> >> The error occurs when trying to open the imageBuffer so I can work with the data in the buffer. What have I missed? > > You need to rewind to the start of the buffer before trying to read from it: > > self.imageBuffer.seek(0) > > -- > Gareth Rees From glez_b at comunidad.unam.mx Thu Apr 19 02:53:14 2012 From: glez_b at comunidad.unam.mx (Boris Vladimir Comi) Date: Thu, 19 Apr 2012 00:53:14 -0000 Subject: [Image-SIG] Tutor Digest, Vol 98, Issue 51 In-Reply-To: References: Message-ID: Hi I have the following code that calculates the position and the value of each pixel of the image: def scm(directory): import os; fs = os.listdir(directory); # now fs will be a list of all the files in directory from edu.wisc.ssec.mcidas import AreaFile; for name in fs: print "Reading in:",name af = AreaFile(directory+"/"+name); ad = af.getAreaDirectory(); count = 0; data = af.getFloatData(); # now look through the first band y count pixels # MCS detected when his temperature infrared (TIR) is < 219 K for i in xrange(ad.getLines()): for j in xrange(ad.getElements()): if 552 < i < 900 and 244 < j < 572: if (data[0][i][j]) > 206 and (data[0][i][j]) < 208: print i, j, data[0][i][j]; Where in the code I can add the condition: to only print those values ??(206-208) to be maintained for three hours or more Boris Vladimir Comi Gonzalez Universidad Nacional Aut?noma de M?xico Grupo de Tormentas Convecivas -------------- next part -------------- An HTML attachment was scrubbed... URL: From regebro at gmail.com Thu Apr 19 06:50:52 2012 From: regebro at gmail.com (Lennart Regebro) Date: Thu, 19 Apr 2012 04:50:52 -0000 Subject: [Image-SIG] [Python-porting] Tutor Digest, Vol 98, Issue 51 In-Reply-To: References: Message-ID: >From the headers of this mail: To: python codigo This is wrong. Is this an indication of the reason why we get Tutor mails to python-porting a lot nowadays? Somebody typed the wrong address in a site somewhere? //Lennart From glez_b at comunidad.unam.mx Fri Apr 20 17:20:33 2012 From: glez_b at comunidad.unam.mx (Boris Vladimir Comi) Date: Fri, 20 Apr 2012 15:20:33 -0000 Subject: [Image-SIG] Segment an Image Message-ID: Hello, I have one image data in the following format: 200406011215.goes12ir These images are composed of lines and elements with their corresponding value of brightness ( 0 -255). >>> print im.format, im.size, im.mode MCIDAS (1732, 2600) L I'm trying to make a script that targets a region with certain properties. script: import Image im = Image.open(/home/mcidas/Documents/datos/200404031215.goes12ir") im.show() How I can target a region of the displayed image whose brightness value is > 205? Anyone have an idea how I can identify and draw a mark on the regions of the image that meets the specified value Boris Vladimir Comi Gonzalez Universidad Nacional Aut?noma de M?xico Grupo de Tormentas Convecivas -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark.asbach at iais.fraunhofer.de Thu Apr 26 17:24:15 2012 From: mark.asbach at iais.fraunhofer.de (Asbach, Mark) Date: Thu, 26 Apr 2012 15:24:15 -0000 Subject: [Image-SIG] Macinthos PIC files In-Reply-To: References: <4F849C81.4060706@net4werling.de> Message-ID: <9F2478AC-3F23-409B-B1F7-09E346095F7F@iais.fraunhofer.de> Hi everyone, Am 11.04.2012 um 12:21 schrieb elmar werling: >>>>> I have pictures in Macinthos PIC/PICT format (HDR image (image/x-hdr),see >>>>> appendix. >>>>> >>>>> Can anyone suggest a simple way to convert the pictures into JPEG-format? >>>> >>>> Wow! OS-X "Preview" doesn't even know what to so with it -- this may be >>>> tough! The PICT format relies on old codecs that are only available in 32bit mode and QuickTime knows how to load these bundles via a 32bit subprocess. If you rename the file to example.pict you will find that Preview tells you that you can open the file if you restart Preview in 32bit mode. For batch conversion, I use GraphicConverter that is also able to open the file (if renamed to .pict). I would recommend it. Best, Mark -- Mark Asbach Fraunhofer IAIS, Sankt Augustin, Germany http://mmprec.iais.fraunhofer.de/asbach From boris.kizelshteyn at popcha.com Thu Apr 19 01:05:08 2012 From: boris.kizelshteyn at popcha.com (Boris Kizelshteyn) Date: Wed, 18 Apr 2012 23:05:08 -0000 Subject: [Image-SIG] Some gibberish returned by ExifTags.TAGS Message-ID: Hi All, Some of the exif values are coming back as strings like this: ?x00P?x00r?x00o?x00d?x00u?x00c?x00t?x00i?x00o?x00n?x00s?x00 Any idea what it could be? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From cbwhiz at gmail.com Tue Apr 10 19:25:15 2012 From: cbwhiz at gmail.com (CBWhiz) Date: Tue, 10 Apr 2012 17:25:15 -0000 Subject: [Image-SIG] PIL on windows *.pyd manifest bug report Message-ID: I've installed PIL on a Windows 7 machine with Python 2.7.1. It works completely fine from the command prompt, ie, form within python.exe. However, I'm using mod_wsgi as my Python interpreter, and _imaging.pyd fails to load. I had the same problem with pyodbc.pyd, and their bug tracker is following the issue at http://code.google.com/p/pyodbc/issues/detail?id=214 . The suggested solution worked for pyodbc, and I gave it a try on _imaging.pyd, which also fixed the problem. To clarify, this solved my problem: mt.exe -inputresource:c:\windows\syswow64\python27.dll;#2 -outputresource:C:\Python27\Lib\site-packages\PIL\_imaging.pyd;#2 From diamonddriver296 at gmail.com Mon Apr 16 19:44:30 2012 From: diamonddriver296 at gmail.com (Jim Thames) Date: Mon, 16 Apr 2012 17:44:30 -0000 Subject: [Image-SIG] install failure Message-ID: Hi folks: Trying to install PIL on a W7x64 box with Active State 2.7.2. PIL install say sit can't find the right version of python. I assume this is a registry problem. Can you point me to a resource for solving this? Thanks in advance... Jim Thames Private Pilot, Software Architect -------------- next part -------------- An HTML attachment was scrubbed... URL: From ewadac at hotmail.com Thu Apr 12 16:04:17 2012 From: ewadac at hotmail.com (Brian) Date: Thu, 12 Apr 2012 14:04:17 -0000 Subject: [Image-SIG] Jpeg not working correctly with Python 2.7 and PIL Message-ID: Hello - I've spent the better part of the last day re-installing python 2.7 (from windows binaries from both activestate and python.org) and PIL. I've done this on two Win7 machines, one 64-bit and one 32-bit. On the 64bit machine, I've installed (and uninstalled) both the 32bit and 64bit versions of python (again, both activestate and python.org binaries). Everything in python and pil works as expected except that certain calls in pil return the error related to the jpeg decoder (IOError: decoder jpeg not available). I've spent hours searching through forums trying to find the fix but no luck. It appears that this type of error has been present for years but not everyone encounters it (based on what I'm seeing in the forums). It also appears that those that do encounter it must resort to tweaking the source and re-compiling pil. Note: I do not know (or really want to know) how to compile from source which is why I'm using the binaries... I've done enough trial and error testing that I believe: - this issue is not unique to my system and - that a significant portion of other people are also encountering it and - that no "easy" (or at least non-techie) fix is available on the net - and please spare me the "real men compile from source" comments :) Thanks for your help, Brian Current Python version is: Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32 Simple code to reproduce problem: \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ import Image path_filename_big = "c:\\temp\image\\big\\test_big.jpg" path_filename_small = "c:\\temp\image\\small\\test_small.jpg" def image_to_thumbnail(image_file): im = Image.open(image_file) size = 50,70 im.thumbnail(size, Image.ANTIALIAS) im.save(path_filename_small) image_to_thumbnail(path_filename_big) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ Traceback (most recent call last): File "T:/Dropbox/Dev_Gsi/Python/testing/Testing.py", line 41, in image_to_thumbnail(path_filename_big) File "T:/Dropbox/Dev_Gsi/Python/testing/Testing.py", line 37, in image_to_thumbnail im.thumbnail(size, Image.ANTIALIAS) File "C:\Users\brayb\AppData\Roaming\Python\Python27\site-packages\PIL\Image.py", line 1559, in thumbnail self.load() File "C:\Users\brayb\AppData\Roaming\Python\Python27\site-packages\PIL\ImageFile.py", line 189, in load d = Image._getdecoder(self.mode, d, a, self.decoderconfig) File "C:\Users\brayb\AppData\Roaming\Python\Python27\site-packages\PIL\Image.py", line 385, in _getdecoder raise IOError("decoder %s not available" % decoder_name) IOError: decoder jpeg not available