From gregh at object-craft.com.au Mon Aug 2 05:01:42 2004 From: gregh at object-craft.com.au (Greg Hamilton) Date: Mon Aug 2 05:01:48 2004 Subject: [Image-SIG] PCX Message-ID: <47E98E7E-E430-11D8-BAC5-000393B5EFF2@object-craft.com.au> I have a PCX image which I can't manipulate with PIL. The image loads without error. PIL identifies it as a mode '1' PCX file and reads the image size correctly. Unfortunately the image content is lost, I just get a black rectangle. I'm able to convert the image to PPM format using the Netpbm command line tool 'pcxtoppm'. PIL will load the PPM data correctly so it appears the PCX file is not corrupt. From fredrik at pythonware.com Mon Aug 2 10:20:13 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon Aug 2 10:20:21 2004 Subject: [Image-SIG] Re: PCX References: <47E98E7E-E430-11D8-BAC5-000393B5EFF2@object-craft.com.au> Message-ID: Greg Hamilton wrote: > I have a PCX image which I can't manipulate with PIL. > > The image loads without error. PIL identifies it as a mode '1' PCX file > and reads the image size correctly. Unfortunately the image content is > lost, I just get a black rectangle. can you mail me a copy of the file (via private mail)? (or if you prefer, post a copy somewhere and mail me the URL) From fredrik at pythonware.com Tue Aug 3 12:19:54 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue Aug 3 12:19:59 2004 Subject: [Image-SIG] Re: Problems with PIL1.1.4 using Py2exe References: <000801c46c2f$aad6e7d0$2ec3d00a@yoox.net> Message-ID: Gabriele Tazzari wrote: > Can you please tell me why the script runs and the exe doesn't ? > The error I get with the exe is > > Traceback (most recent call last): > File "", line 2, in ? > File "Image.pyo", line 1571, in open > IOError: cannot identify image file PIL scans the Python path for image plugins (*ImagePlugin files). to make sure that PY2EXE finds the image plugins you need, you must explicitly import them from your main program. for examples, see: http://mail.python.org/pipermail/python-list/2003-December/199226.html http://mail.python.org/pipermail/python-list/2003-December/199237.html From fredrik at pythonware.com Tue Aug 3 19:18:01 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue Aug 3 19:16:32 2004 Subject: [Image-SIG] Re: PCX References: <47E98E7E-E430-11D8-BAC5-000393B5EFF2@object-craft.com.au> Message-ID: Greg Hamilton wrote: > I have a PCX image which I can't manipulate with PIL. > > The image loads without error. PIL identifies it as a mode '1' PCX file > and reads the image size correctly. Unfortunately the image content is > lost, I just get a black rectangle. turns out that the tile member isn't properly set up for images where the PCX xmin or xmax headers are non-zero. here's a patch: Index: PIL/PcxImagePlugin.py =================================================================== --- PIL/PcxImagePlugin.py (revision 1939) +++ PIL/PcxImagePlugin.py (working copy) @@ -96,6 +96,8 @@ self.mode = mode self.size = bbox[2]-bbox[0], bbox[3]-bbox[1] + bbox = (0, 0) + self.size + self.tile = [("pcx", bbox, self.fp.tell(), (rawmode, planes * stride))] # -------------------------------------------------------------------- From gohaku at earthlink.net Wed Aug 4 03:41:32 2004 From: gohaku at earthlink.net (gohaku) Date: Wed Aug 4 09:54:53 2004 Subject: [Image-SIG] Returning Colormap values for an image? Message-ID: <69AC6CCC-E5B7-11D8-A488-000A9574CFD8@earthlink.net> Hi everyone, I would like to know if there is a function to return an array of an Image's colormap. Thanks in advance. -gohaku From fredrik at pythonware.com Wed Aug 4 10:03:09 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed Aug 4 10:01:37 2004 Subject: [Image-SIG] Re: Returning Colormap values for an image? References: <69AC6CCC-E5B7-11D8-A488-000A9574CFD8@earthlink.net> Message-ID: "gohaku" wrote: > I would like to know if there is a function to return an array of an > Image's colormap. you want the colors in the palette? here's one way to do it: http://article.gmane.org/gmane.comp.python.general/347330 From gregh at object-craft.com.au Mon Aug 9 02:06:50 2004 From: gregh at object-craft.com.au (Greg Hamilton) Date: Mon Aug 9 02:07:01 2004 Subject: [Image-SIG] CMYK->RGB [was Re: PCX] In-Reply-To: References: <47E98E7E-E430-11D8-BAC5-000393B5EFF2@object-craft.com.au> Message-ID: <0333683F-E998-11D8-B98A-000393B5EFF2@object-craft.com.au> Thanks Frederik, That's fixed the problem. Unfortunately I've found another curious quirk. I have a CMYK Jpeg file created with Photoshop which I need to convert to RGB. To do this I do something like: Image.open("cmyk_image.jpg").convert("RGB").save("rgb_image.jpg") The colour information in the resulting jpeg is wrong. Red is yellow, green is blue, grey is something akin to teal. Hopefully I'm doing something wrong. Greg On 04/08/2004, at 3:18 AM, Fredrik Lundh wrote: > Greg Hamilton wrote: > >> I have a PCX image which I can't manipulate with PIL. >> >> The image loads without error. PIL identifies it as a mode '1' PCX >> file >> and reads the image size correctly. Unfortunately the image content is >> lost, I just get a black rectangle. > > turns out that the tile member isn't properly set up for images where > the PCX xmin or xmax headers are non-zero. here's a patch: > > Index: PIL/PcxImagePlugin.py > =================================================================== > --- PIL/PcxImagePlugin.py (revision 1939) > +++ PIL/PcxImagePlugin.py (working copy) > @@ -96,6 +96,8 @@ > self.mode = mode > self.size = bbox[2]-bbox[0], bbox[3]-bbox[1] > > + bbox = (0, 0) + self.size > + > self.tile = [("pcx", bbox, self.fp.tell(), (rawmode, planes * > stride))] > > > # -------------------------------------------------------------------- > > > > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig > From fredrik at pythonware.com Mon Aug 9 09:07:08 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon Aug 9 09:05:30 2004 Subject: [Image-SIG] Re: CMYK->RGB [was Re: PCX] References: <47E98E7E-E430-11D8-BAC5-000393B5EFF2@object-craft.com.au> <0333683F-E998-11D8-B98A-000393B5EFF2@object-craft.com.au> Message-ID: Greg Hamilton wrote: > Unfortunately I've found another curious quirk. I have a CMYK Jpeg file > created with Photoshop which I need to convert to RGB. To do this I do > something like: > > Image.open("cmyk_image.jpg").convert("RGB").save("rgb_image.jpg") > > The colour information in the resulting jpeg is wrong. Red is yellow, > green is blue, grey is something akin to teal. Hopefully I'm doing > something wrong. Older versions of Photoshop generated broken CMYK files, and PIL attempts to compensate for this. try commenting out the following lines in PIL/JpegImagePlugin.py, and let me know if it helps: if self.mode == "CMYK" and self.info.has_key("adobe"): rawmode = "CMYK;I" # Photoshop 2.5 is broken! From cthrax at zithora.com Tue Aug 10 00:09:27 2004 From: cthrax at zithora.com (cthrax@zithora.com) Date: Tue Aug 10 00:09:24 2004 Subject: [Image-SIG] Error compiling PIL Message-ID: <38413.64.139.46.240.1092089367.squirrel@s7.hc7.net> Hi everyone, I am having a problem compiling PIL. I think that it is a problem with another program I have, but I am still learning Linux so I could be wrong. Anyway, the error that I am getting is as follows: In file included from _imagingft.c:18: /usr/include/freetype2/freetype/freetype.h:20:2: #error "`ft2build.h' hasn't been included yet!" /usr/include/freetype2/freetype/freetype.h:21:2: #error "Please always use macros to include FreeType header files." /usr/include/freetype2/freetype/freetype.h:22:2: #error "Example:" /usr/include/freetype2/freetype/freetype.h:23:2: #error " #include " /usr/include/freetype2/freetype/freetype.h:24:2: #error " #include FT_FREETYPE_H" error: command 'gcc' failed with exit status 1 I have tried the alternate compile method with a similar lack of success. I'm not sure what more information you need, so if you have any suggestions or need more information please let me know. Thanks, -Myles From jwt at OnJapan.net Tue Aug 10 00:30:31 2004 From: jwt at OnJapan.net (Jim Tittsler) Date: Tue Aug 10 00:29:11 2004 Subject: [Image-SIG] Error compiling PIL In-Reply-To: <38413.64.139.46.240.1092089367.squirrel@s7.hc7.net> References: <38413.64.139.46.240.1092089367.squirrel@s7.hc7.net> Message-ID: <20040809223031.GA11564@server.onjapan.net> On Mon, Aug 09, 2004 at 05:09:27PM -0500, cthrax@zithora.com wrote: > I am having a problem compiling PIL. I think that it is a problem with > another program I have, but I am still learning Linux so I could be wrong. [...] > In file included from _imagingft.c:18: > /usr/include/freetype2/freetype/freetype.h:20:2: #error "`ft2build.h' > hasn't been included yet!" I believe this is a problem with 1.1.4 and recent versions of the freetype library that is covered in on errata note: http://effbot.org/zone/pil-errata-114.htm -- Jim Tittsler http://www.OnJapan.net/ GPG: 0x01159DB6 Python Starship http://Starship.Python.net/ Ringo MUG Tokyo http://www.ringo.net/rss.html From sdahlbac at abo.fi Tue Aug 10 12:08:47 2004 From: sdahlbac at abo.fi (sdahlbac@abo.fi) Date: Tue Aug 10 12:09:35 2004 Subject: [Image-SIG] pattern fill Message-ID: <1092132527.41189eaf1fbe8@webmail.abo.fi> Have I overlooked something simple or is some kind of pattern fill not supported in the ImageDraw module. I'd like to draw some sort of striped pattern(s) but haven't found a (built in) way to do it, of course it is possible to implement such functionality by drawing the stripes myself, but I wanted to check if I missed something simpler first. /Simon From jody.burgess at sewardconsulting.com Tue Aug 10 18:15:58 2004 From: jody.burgess at sewardconsulting.com (Jody Burgess) Date: Tue Aug 10 18:16:24 2004 Subject: [Image-SIG] jpg to PCL Message-ID: Good Morning; I am new to the list and to python in general. I have a question for the list; are there any methods in python to convert either Group3/4 Tiff images or jpg images to PCL or PostScript? I've look among some of the libraries and was not able to determine if it can be done in python or not. Any help with this issue would be greatly appreciated. Jody Burgess ISP Systems Analyst Seward Consulting Ltd. 780.702.5103 jody.burgess@sewardconsulting.com From jody.burgess at sewardconsulting.com Tue Aug 10 19:50:13 2004 From: jody.burgess at sewardconsulting.com (Jody Burgess) Date: Tue Aug 10 19:48:15 2004 Subject: [Image-SIG] poor output results. In-Reply-To: Message-ID: Can any one explain why I can open up a Group 4 Tiff image in the windows picture viewer and print it out and it looks fine. Put when I process the same image through the PIL, it comes out garbled. Has anyone had any experience with processing Group 3 or 4 Tiff files in PIL? Please help. Thanks. Jody Burgess ISP Systems Analyst Seward Consulting Ltd. 780.702.5103 jody.burgess@sewardconsulting.com -----Original Message----- From: Jody Burgess [mailto:jody.burgess@sewardconsulting.com] Sent: Tuesday, August 10, 2004 10:16 AM To: image-sig@python.org Subject: jpg to PCL Importance: High Good Morning; I am new to the list and to python in general. I have a question for the list; are there any methods in python to convert either Group3/4 Tiff images or jpg images to PCL or PostScript? I've look among some of the libraries and was not able to determine if it can be done in python or not. Any help with this issue would be greatly appreciated. Jody Burgess ISP Systems Analyst Seward Consulting Ltd. 780.702.5103 jody.burgess@sewardconsulting.com From milgrom at gmail.com Wed Aug 11 06:33:42 2004 From: milgrom at gmail.com (Alfred Milgrom) Date: Wed Aug 11 06:33:54 2004 Subject: [Image-SIG] Re: Returning Colormap values for an image? In-Reply-To: References: <69AC6CCC-E5B7-11D8-A488-000A9574CFD8@earthlink.net> Message-ID: <50eadd0a04081021335916c37a@mail.gmail.com> Hi: I am having problems in getting the colours for a grabbed image (obtained using ImageGrab under Windows). The following code illustrates my problem: #################################################################### # Test of colour palette returned from ImageGrab from Tkinter import * import ImageGrab import Image import os class GUI (Frame): top = Tk() def __init__(self, parent=top): Frame.__init__(self,parent) self.master.title('Grab Test') self.Board = Canvas(self, width=200 , height=200 , bg="#FFF000") self.Board.pack(side=TOP, padx=10, pady=10) fButtons = Frame(self) self.bGrab = Button(fButtons, width=15, text="Grab", command=self.grabBoard) self.bGrab.pack(side=LEFT, anchor=W, padx=10, pady=2) self.bQuit = Button(fButtons, width=15, text="Quit", command=self.top.destroy) self.bQuit.pack(side=LEFT, anchor=W, padx=10, pady=2) fButtons.pack(side=BOTTOM, fill=X) self.pack() self.Board.create_rectangle(70, 70, 90, 90, fill='white') def colourinfo(self, im): hist = im.histogram() palette = im.palette for item in hist: coloursUsed = [i for i in range(len(hist)) if hist[i]] palettestring = palette.tostring() paletteUsed = [palettestring[3*i:3*i+3] for i in coloursUsed] print "There are %s colours in this image" %len(coloursUsed) print "Grabbed palette is:" for item in paletteUsed: for char in item: print '%x' %ord(char), print def grabBoard(self): x0 = self.Board.winfo_rootx()+2 y0 = self.Board.winfo_rooty()+2 x1 = x0 + 100 y1 = y0 + 100 im = ImageGrab.grab((x0, y0, x1, y1)) im = im.convert('P') print "The grabbed image is in %s mode" %im.mode self.colourinfo(im) path = os.getcwd() im.save(os.path.join(path, 'mytest.gif')) im2 = Image.open(os.path.join(path, 'mytest.gif')) print "\nInformation from saved image:" self.colourinfo(im2) if __name__ == "__main__": board = GUI() #################################################################### Basically I grab an image and use my function colourinfo to tell me how many colours there are and what they are. I then save the image and call colourinfo again. The output is as follows: The grabbed image is in P mode There are 6 colours in this image Grabbed palette is: 0 1 2 3 4 5 9 a b 75 76 77 87 88 89 f4 f5 f6 Information from saved image: There are 6 colours in this image Grabbed palette is: 0 0 0 1 1 1 3 3 3 ff cc 0 ff ff 0 fc fc fc As you can see, the information from the grabbed image is basically garbage data, whereas the saved image has the correct information. How can I get the correct data from the grabbed image without having to save it first? Any help would be appreciated. (Apologies if this has previously been answered. I have posted this problem previously but must have missed the reply) Thanks, Alfred Milgrom On Wed, 4 Aug 2004 10:03:09 +0200, Fredrik Lundh wrote: > "gohaku" wrote: > > > I would like to know if there is a function to return an array of an > > Image's colormap. > > you want the colors in the palette? here's one way to do it: > > http://article.gmane.org/gmane.comp.python.general/347330 > > > > > > > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig > From fredrik at pythonware.com Wed Aug 11 15:28:58 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed Aug 11 15:29:04 2004 Subject: [Image-SIG] Re: jpg to PCL References: Message-ID: Jody Burgess wrote: > I am new to the list and to python in general. I have a question for the > list; are there any methods in python to convert either Group3/4 Tiff images > or jpg images to PCL or PostScript? I've look among some of the libraries > and was not able to determine if it can be done in python or not. Any help > with this issue would be greatly appreciated. the Python Imaging Library can read JPEG files, and generate PostScript. it cannot read TIFF G3/G4 files, nor write PCL. to handle TIFF G3/G4, you can usually use the libtiff utilities to preprocess the images before opening them (e.g. "tifftopnm myfile.tif temp.pbm"). From fredrik at pythonware.com Wed Aug 11 15:34:59 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed Aug 11 15:35:05 2004 Subject: [Image-SIG] Re: Returning Colormap values for an image? References: <69AC6CCC-E5B7-11D8-A488-000A9574CFD8@earthlink.net> <50eadd0a04081021335916c37a@mail.gmail.com> Message-ID: Alfred Milgrom wrote: > How can I get the correct data from the grabbed image without having > to save it first? the palette string may have different formats depending on the data source (the palette.rawmode attribute is used to describe the actual format). instead of peeking into the palette object, use the resize/convert technique described in this message: http://article.gmane.org/gmane.comp.python.general/347330 From milgrom at gmail.com Thu Aug 12 09:07:05 2004 From: milgrom at gmail.com (Alfred Milgrom) Date: Thu Aug 12 09:07:11 2004 Subject: [Image-SIG] Re: Returning Colormap values for an image? In-Reply-To: References: <69AC6CCC-E5B7-11D8-A488-000A9574CFD8@earthlink.net> <50eadd0a04081021335916c37a@mail.gmail.com> Message-ID: <50eadd0a04081200072218c495@mail.gmail.com> Thank you for your prompt answer to my problem. I am sorry to trouble you further. Unfortunately I think I am missing something as far as the resize/convert technique is concerned. Basically I do not understand why all the colours will be preserved if the image is resized, nor why the colours will then be neatly arranged in the lut Image. I have adapted my colourinfo function to use the resize/convert technique, but I only get two different colours in the resulting 256-pixel image instead of 6. I get the same difference in results from either the grabbed image or the saved image. Not only that, but I get different number of colours and colours after I convert the image to P mode. I would be grateful if you could point out what I am doing wrong. Thanks in advance, Alfred Milgrom ######################################################## # Test of colour palette returned from ImageGrab from Tkinter import * import ImageGrab import Image import os class GUI (Frame): top = Tk() def __init__(self, parent=top): Frame.__init__(self,parent) self.master.title('Grab Test') self.Board = Canvas(self, width=200 , height=200 , bg="#FFF000") self.Board.pack(side=TOP, padx=10, pady=10) fButtons = Frame(self) self.bGrab = Button(fButtons, width=15, text="Grab", command=self.grabBoard) self.bGrab.pack(side=LEFT, anchor=W, padx=10, pady=2) self.bQuit = Button(fButtons, width=15, text="Quit", command=self.top.destroy) self.bQuit.pack(side=LEFT, anchor=W, padx=10, pady=2) fButtons.pack(side=BOTTOM, fill=X) self.pack() self.Board.create_rectangle(70, 70, 90, 90, fill='white') def colourinfo(self, im): hist = im.histogram() coloursUsed = len([x for x in hist if x]) print "There are %s colours in this image" %coloursUsed print "Colours using resize/convert colours method:" lut = im.resize((256,1)).convert("RGB").getdata() print [x for x in lut if x not in locals()['_[1]'].__self__] print "Colours using all data" lut = im.convert("RGB").getdata() print [x for x in lut if x not in locals()['_[1]'].__self__] def grabBoard(self): x0 = self.Board.winfo_rootx()+2 y0 = self.Board.winfo_rooty()+2 x1 = x0 + 100 y1 = y0 + 100 im = ImageGrab.grab((x0, y0, x1, y1)) print "The grabbed image is in %s mode" %im.mode self.colourinfo(im) im = im.convert('P') print "\nThe grabbed image is now in %s mode" %im.mode self.colourinfo(im) path = os.getcwd() im.save(os.path.join(path, 'mytest.gif')) im2 = Image.open(os.path.join(path, 'mytest.gif')) print "\nInformation from saved image:" self.colourinfo(im2) if __name__ == "__main__": board = GUI() On Wed, 11 Aug 2004 15:34:59 +0200, Fredrik Lundh wrote: > Alfred Milgrom wrote: > > > How can I get the correct data from the grabbed image without having > > to save it first? > > the palette string may have different formats depending on the > data source (the palette.rawmode attribute is used to describe > the actual format). > > instead of peeking into the palette object, use the resize/convert > technique described in this message: > > > > http://article.gmane.org/gmane.comp.python.general/347330 > > > > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig > From fredrik at pythonware.com Thu Aug 12 10:42:21 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu Aug 12 10:42:26 2004 Subject: [Image-SIG] Re: Returning Colormap values for an image? References: <69AC6CCC-E5B7-11D8-A488-000A9574CFD8@earthlink.net><50eadd0a04081021335916c37a@mail.gmail.com> <50eadd0a04081200072218c495@mail.gmail.com> Message-ID: Alfred Milgrom wrote: > Unfortunately I think I am missing something as far as the > resize/convert technique is concerned. Basically I do not understand > why all the colours will be preserved if the image is resized, nor why > the colours will then be neatly arranged in the lut Image. that's an interesting question: the example is broken, and you're the first one who's noticed. oops! here's how it's supposed to look: lut = im.resize((256, 1)) lut.putdata(range(256)) lut = lut.convert("RGB").getdata() (the resulting lut object is now a 256-item sequence of (r, g, b) tuples; use list(lut) if you want to print it) From milgrom at gmail.com Fri Aug 13 08:50:51 2004 From: milgrom at gmail.com (Alfred Milgrom) Date: Fri Aug 13 08:50:54 2004 Subject: [Image-SIG] Re: Returning Colormap values for an image? In-Reply-To: References: <69AC6CCC-E5B7-11D8-A488-000A9574CFD8@earthlink.net><50eadd0a04081021335916c37a@mail.gmail.com> <50eadd0a04081200072218c495@mail.gmail.com> Message-ID: <50eadd0a0408122350713ad1e0@mail.gmail.com> Hi: Thanks for your reply. It took me a while to understand what was going on, but I have finally figured it out! As I understand it, the resize does not change the palette information, and when you fill the data with range(256) and convert to RGB each value is mapped to the corresponding palette entry. The only problem (if you can call it that?) is that the colours actually used in the original image are not necessarily the first n values in the lut image, and so it is necessary to not only work out how many colours are used initially but also which indices are used. Is there an easier way to get a list of the indices used than something like: hist = im.histogram() coloursUsed = [i for i in range(len(hist)) if hist[i]] Also, if the image I have is an RGB image (such as the result of an ImageGrab), what is the best way to get the colours used? Is converting to 'P' mode and then using the resize/convert method the easiest/fastest? Thanks again, Alfred Milgrom On Thu, 12 Aug 2004 10:42:21 +0200, Fredrik Lundh wrote: > Alfred Milgrom wrote: > > > Unfortunately I think I am missing something as far as the > > resize/convert technique is concerned. Basically I do not understand > > why all the colours will be preserved if the image is resized, nor why > > the colours will then be neatly arranged in the lut Image. > > that's an interesting question: the example is broken, and you're the > first one who's noticed. oops! here's how it's supposed to look: > > lut = im.resize((256, 1)) > lut.putdata(range(256)) > lut = lut.convert("RGB").getdata() > > (the resulting lut object is now a 256-item sequence of (r, g, b) tuples; > use list(lut) if you want to print it) From thomi at thomi.imail.net.nz Sat Aug 14 06:41:40 2004 From: thomi at thomi.imail.net.nz (Thomas Clive Richards) Date: Sat Aug 14 06:41:46 2004 Subject: [Image-SIG] PIL problem Message-ID: <200408141641.40866.thomi@thomi.imail.net.nz> Hi, I'm trying to make a quick script which generates thumbnails for a website. However, I can't get the thumbnail() method to work with PNG files. I'm using python2.2 (and I can't upgrade unfortunately - that's what is being used on the webserver). Here's a quick outline of the problem: >>> import Image >>> im = Image.open("/tmp/pics/title.png") >>> im.thumbnail((128,128)) Traceback (most recent call last): File "", line 1, in ? File "/usr/lib/python2.2/site-packages/PIL/Image.py", line 1264, in thumbnail self.load() File "/usr/lib/python2.2/site-packages/PIL/ImageFile.py", line 192, in load raise IOError(error + " when reading image file") IOError: unknown error when reading image file At this point however, If I repeat the thumbnail() cal, there are no errors. The following block continues from where the above block left off: >>> im.thumbnail((128,128)) >>> im.save('/home/thomi/test_thumb.png','PNG') The saved image seems to be valid (the GIMP will open it), but the contents are garbled, and look NOTHING like the original. This script works fine with GIF, BMP and JPG formats. Does anyone know of an easy fix for this? Thanks, -- Thomi Richards, thomi@once.net.nz From thomi at thomi.imail.net.nz Sun Aug 15 10:09:49 2004 From: thomi at thomi.imail.net.nz (Thomas Clive Richards) Date: Sun Aug 15 10:09:55 2004 Subject: [Image-SIG] PIL problem In-Reply-To: <200408141641.40866.thomi@thomi.imail.net.nz> References: <200408141641.40866.thomi@thomi.imail.net.nz> Message-ID: <200408152009.49535.thomi@thomi.imail.net.nz> On Sat, 14 Aug 2004 4:41 pm, Thomas Clive Richards wrote: > Hi, > > > I'm trying to make a quick script which generates thumbnails for a website. > However, I can't get the thumbnail() method to work with PNG files. > I've discovered further problems when I tried to do this manually. For example: thomi@Julie:/tmp/pics$ python2.2 Python 2.2.3+ (#1, Feb 25 2004, 23:29:31) [GCC 3.3.3 (Debian)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import Image >>> im = Image.open('title.png') >>> im.verify() >>> im2 = im.copy() Traceback (most recent call last): File "", line 1, in ? File "/usr/lib/python2.2/site-packages/PIL/Image.py", line 630, in copy self.load() File "/usr/lib/python2.2/site-packages/PIL/ImageFile.py", line 166, in load self.load_seek(o) File "/usr/lib/python2.2/site-packages/PIL/ImageFile.py", line 217, in load_seek self.fp.seek(pos) AttributeError: 'NoneType' object has no attribute 'seek' That doesn't seem right... I get similar error messages when trying to perform any operations on PNG files. I also tried converting it to a BMP before performing any operations, but that throws an error also. There *must* be a fix for this.. surely someone else has come across this problem? Also, is this package dead? I remember a time when this was one of the most active mailing lists I was subscribed to, now it seems like I'm the only one alive... -- Thomi Richards, thomi@once.net.nz From rjkimble at comcast.net Sun Aug 15 11:05:13 2004 From: rjkimble at comcast.net (rjkimble@comcast.net) Date: Sun Aug 15 11:05:22 2004 Subject: [Image-SIG] PIL problem Message-ID: <081520040905.18078.411F2749000A29160000469E22007614380A040D030705069D@comcast.net> Here's a curiosity. I played around with your example using my AlphaPC running Debian. I get the same results as you with both Python 2.2 and 2.3. However, I noticed a trick. I have no idea what's going on, but maybe it's a workaround. When I run this, everything seems to work OK: import Image im = Image.open('title.png') im2 = im.copy() im2.verify() im3 = im2.copy() I haven't played around much with it, but maybe that can lead to a workaround for you until a real solution gets posted. Regards, .... Bob > On Sat, 14 Aug 2004 4:41 pm, Thomas Clive Richards wrote: > > Hi, > > > > > > I'm trying to make a quick script which generates thumbnails for a website. > > However, I can't get the thumbnail() method to work with PNG files. > > > > I've discovered further problems when I tried to do this manually. For > example: > > thomi@Julie:/tmp/pics$ python2.2 > Python 2.2.3+ (#1, Feb 25 2004, 23:29:31) > [GCC 3.3.3 (Debian)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import Image > >>> im = Image.open('title.png') > >>> im.verify() > >>> im2 = im.copy() > Traceback (most recent call last): > File "", line 1, in ? > File "/usr/lib/python2.2/site-packages/PIL/Image.py", line 630, in copy > self.load() > File "/usr/lib/python2.2/site-packages/PIL/ImageFile.py", line 166, in load > self.load_seek(o) > File "/usr/lib/python2.2/site-packages/PIL/ImageFile.py", line 217, in > load_seek > self.fp.seek(pos) > AttributeError: 'NoneType' object has no attribute 'seek' > > > That doesn't seem right... > > I get similar error messages when trying to perform any operations on PNG > files. > > I also tried converting it to a BMP before performing any operations, but that > throws an error also. > > There *must* be a fix for this.. surely someone else has come across this > problem? > > Also, is this package dead? I remember a time when this was one of the most > active mailing lists I was subscribed to, now it seems like I'm the only one > alive... > > -- > > Thomi Richards, > thomi@once.net.nz > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig From thomi at thomi.imail.net.nz Sun Aug 15 12:58:55 2004 From: thomi at thomi.imail.net.nz (Thomas Clive Richards) Date: Sun Aug 15 12:59:00 2004 Subject: [Image-SIG] PIL problem In-Reply-To: <081520040905.18078.411F2749000A29160000469E22007614380A040D030705069D@comcast.net> References: <081520040905.18078.411F2749000A29160000469E22007614380A040D030705069D@comcast.net> Message-ID: <200408152258.55095.thomi@thomi.imail.net.nz> On Sun, 15 Aug 2004 9:05 pm, rjkimble@comcast.net wrote: > Here's a curiosity. I played around with your example using my AlphaPC > running Debian. I get the same results as you with both Python 2.2 and 2.3. > However, I noticed a trick. I have no idea what's going on, but maybe it's > a workaround. > hmm... Not sure what you mean by this. WHen I try it: Python 2.2.3+ (#1, Feb 25 2004, 23:29:31) [GCC 3.3.3 (Debian)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import Image >>> im = Image.open('title.png') >>> im2 = im.copy() Traceback (most recent call last): File "", line 1, in ? File "/usr/lib/python2.2/site-packages/PIL/Image.py", line 630, in copy self.load() File "/usr/lib/python2.2/site-packages/PIL/ImageFile.py", line 192, in load raise IOError(error + " when reading image file") IOError: unknown error when reading image file The file still exists, permissions seem to be okay... interesting huh? I probably should have mentioned earlier that this script is running on a lean server - imagemagick and other utilities I might be able to use aren't available.. Thanks for the help, I'll see if anyone has any thoughts on this subject over the next week or so... -- Thomi Richards, thomi@once.net.nz From fredrik at pythonware.com Sun Aug 15 15:09:35 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun Aug 15 15:07:53 2004 Subject: [Image-SIG] Re: PIL problem References: <200408141641.40866.thomi@thomi.imail.net.nz> <200408152009.49535.thomi@thomi.imail.net.nz> Message-ID: Thomas Clive Richards wrote: >>>> import Image >>>> im = Image.open('title.png') >>>> im.verify() >>>> im2 = im.copy() > Traceback (most recent call last): > File "", line 1, in ? > File "/usr/lib/python2.2/site-packages/PIL/Image.py", line 630, in copy > self.load() > File "/usr/lib/python2.2/site-packages/PIL/ImageFile.py", line 166, in load > self.load_seek(o) > File "/usr/lib/python2.2/site-packages/PIL/ImageFile.py", line 217, in > load_seek > self.fp.seek(pos) > AttributeError: 'NoneType' object has no attribute 'seek' > > That doesn't seem right... read the documentation: you cannot access the file after you've called "verify"; you need to reopen the file first. > Also, is this package dead? no. From fredrik at pythonware.com Sun Aug 15 15:16:39 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun Aug 15 15:14:58 2004 Subject: [Image-SIG] Re: PIL problem References: <200408141641.40866.thomi@thomi.imail.net.nz> Message-ID: Thomas Clive Richards wrote: > I'm trying to make a quick script which generates thumbnails for a website. > However, I can't get the thumbnail() method to work with PNG files. the documentation mentions two possible causes: Interlaced files are currently not supported. To enable PNG support, you need to build and install the ZLIB compression library before building the Python Imaging Library. to check if the former is the problem, check if there's an "interlace" member in the im.info dictionary >>> import Image >>> im = Image.open("somefile.png") >>> im["interlace"] to check for the latter, check that Image.core has a zip_decoder member: >>> import Image >>> Image.core.zip_decoder From thomi at thomi.imail.net.nz Sun Aug 15 22:36:42 2004 From: thomi at thomi.imail.net.nz (Thomas Clive Richards) Date: Sun Aug 15 22:36:48 2004 Subject: [Image-SIG] Re: PIL problem In-Reply-To: References: <200408141641.40866.thomi@thomi.imail.net.nz> Message-ID: <200408160836.43306.thomi@thomi.imail.net.nz> On Mon, 16 Aug 2004 1:16 am, Fredrik Lundh wrote: > > the documentation mentions two possible causes: > > Interlaced files are currently not supported. > ahhh, okay.. I have no idea what an interlaced png is, but I'm sure I can find out. THanks for your help! The files I am trying to convert are interlaced files. > To enable PNG support, you need to build and install the ZLIB > compression library before building the Python Imaging Library. > > to check if the former is the problem, check if there's an "interlace" > member in the im.info dictionary > > >>> import Image > >>> im = Image.open("somefile.png") > >>> im["interlace"] > > to check for the latter, check that Image.core has a zip_decoder > > member: > >>> import Image > >>> Image.core.zip_decoder > > > > This is what I got: Python 2.2.3+ (#1, Feb 25 2004, 23:29:31) [GCC 3.3.3 (Debian)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import Image >>> im = Image.open('title.png') >>> im["interlace"] Traceback (most recent call last): File "", line 1, in ? AttributeError: PngImageFile instance has no attribute '__getitem__' >>> im.info {'Comment': 'Created with The GIMP by Thomi Richards', 'interlace': 1} >>> Image.core.zip_decoder Are there plans to add support for interlaced png files at any time soon? Thanks again -- Thomi Richards, thomi@once.net.nz From vscan.deisho1 at mumnet.com Mon Aug 16 10:26:33 2004 From: vscan.deisho1 at mumnet.com (vscan.deisho1@mumnet.com) Date: Mon Aug 16 10:15:31 2004 Subject: [Image-SIG] File blocked - ScanMail for Lotus Notes --> photos Message-ID: M&M mail scan has removed an attachment during a real-time scan of the mail traffic. Date: 16.08.2004 10:26:33 Subject: photos Virus: File: photos_arc.exe From: image-sig@python.org To: jimmy@mumnet.com Action: Blocked by Filter Rules; Scanned by ScanMail for Lotus Notes 2.6 SP1 with scanengine 7.000-1004 and pattern version 1.955.00 From postmaster at publicis.fr Mon Aug 16 11:18:01 2004 From: postmaster at publicis.fr (InterScan MSS Notification) Date: Mon Aug 16 11:19:07 2004 Subject: [Image-SIG] InterScan MSS has quarantined a message Message-ID: <20040816091801.9A6A64E3D4@sg1.publicis.fr> Your message has been quarantined by Publicis Antispam/Antivirus Votre message a ?t? filtr? par le serveur Antispam/Antivirus de Publicis For any informations contact Publicis-Technology (+33 149296666) Pour de plus amples information contactez Publicis Technology (+33 149296666) -------------- next part -------------- An embedded message was scrubbed... From: image-sig@python.org Subject: photos Date: Mon, 16 Aug 2004 11:20:18 +0200 Size: 1456 Url: http://mail.python.org/pipermail/image-sig/attachments/20040816/d5e75fcb/attachment.mht From pascor at hotpop.com Wed Aug 18 00:09:25 2004 From: pascor at hotpop.com (Ray Pasco) Date: Wed Aug 18 00:09:17 2004 Subject: [Image-SIG] MSW XP imcompatabilities ? Message-ID: <41228215.3050901@hotpop.com> As a newbie using 2.3.4 and 1.1.4 I'm exploring ways to convert between formats and embed them into wxPython apps. I've found that all JPEG and BMP files that have been copied refuse to be read in at all. Also, using .enhance produces a bogus AttributeError but works correctly. Are there any thoughts about these and are there MSW-tested apps you can send in my direction ? From fredrik at pythonware.com Wed Aug 18 10:01:23 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed Aug 18 09:59:42 2004 Subject: [Image-SIG] Re: MSW XP imcompatabilities ? References: <41228215.3050901@hotpop.com> Message-ID: Ray Pasco wrote: > As a newbie using 2.3.4 and 1.1.4 I'm exploring ways to convert between formats and embed them > into wxPython apps. I've found that all JPEG and BMP files that have been copied refuse to be > read in at all. Also, using .enhance produces a bogus AttributeError but works correctly. afaik, PIL 1.1.4 works just fine on Windows XP (if that's what "MSW XP" means). and I cannot really tell what you're doing from your bug report: - copied from where to where, usíng what command? - read in by what application? - what AttributeError? if you can, post code snippets and complete tracebacks. From francesco.pirotti at unipd.it Fri Aug 20 11:10:54 2004 From: francesco.pirotti at unipd.it (francesco) Date: Fri Aug 20 11:20:06 2004 Subject: [Image-SIG] compiling py2exe windows executable gives "IOerror image type not recognized" in the Image.open() Message-ID: <5.1.1.6.0.20040820110814.00a671d0@mail.unipd.it> Hi, when compiling a windows executable with python 2.3 using the py2exe utility my application cannot access the Image.open function in the PIL library because it says "IOError: cannot identify image file". Does anybody have an idea why? Thank you, Francesco Pirotti From fredrik at pythonware.com Fri Aug 20 13:40:12 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri Aug 20 13:38:32 2004 Subject: [Image-SIG] Re: compiling py2exe windows executable gives "IOerror image type not recognized" in the Image.open() References: <5.1.1.6.0.20040820110814.00a671d0@mail.unipd.it> Message-ID: "francesco" wrote: > when compiling a windows executable with python 2.3 using the py2exe utility my application cannot > access the Image.open function in the PIL library because it says "IOError: cannot identify image > file". > > Does anybody have an idea why? google could have explained this to you in seconds: PIL scans the Python path for image plugins (*ImagePlugin files). to make sure that PY2EXE finds the image plugins you need, you must explicitly import them from your main program. for examples, see: http://mail.python.org/pipermail/python-list/2003-December/199226.html http://mail.python.org/pipermail/python-list/2003-December/199237.html this is also mentioned (twice!) on the PY2EXE home page; both entries point to this page: http://starship.python.net/crew/theller/moin.cgi/PIL_20and_20py2exe From fredrik at pythonware.com Mon Aug 23 13:46:44 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon Aug 23 13:45:02 2004 Subject: [Image-SIG] Re: Returning Colormap values for an image? References: <69AC6CCC-E5B7-11D8-A488-000A9574CFD8@earthlink.net><50eadd0a04081021335916c37a@mail.gmail.com><50eadd0a04081200072218c495@mail.gmail.com> <50eadd0a0408122350713ad1e0@mail.gmail.com> Message-ID: Alfred Milgrom wrote: > The only problem (if you can call it that?) is that the colours > actually used in the original image are not necessarily the first n > values in the lut image, and so it is necessary to not only work out > how many colours are used initially but also which indices are used. > > Is there an easier way to get a list of the indices used than something like: > > hist = im.histogram() > coloursUsed = [i for i in range(len(hist)) if hist[i]] not really: the histogram approach is the only efficient way to find out what colors you have in an L or P-mode image. > Also, if the image I have is an RGB image (such as the result of an > ImageGrab), what is the best way to get the colours used? Is > converting to 'P' mode and then using the resize/convert method the > easiest/fastest? probably, as long as you're aware that you won't get exact results if the image contains more than 256 colors. for best results, use: im = im.convert("P", dither=Image.NONE, palette=Image.ADAPTIVE) (no dithering, adaptive palette. if you need more control over the process, you can use the undocumented quantize method, but you'll have to read the source code to figure out how that works). From fredrik at pythonware.com Mon Aug 23 16:29:49 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon Aug 23 16:28:07 2004 Subject: [Image-SIG] Re: pattern fill References: <1092132527.41189eaf1fbe8@webmail.abo.fi> Message-ID: wrote: > Have I overlooked something simple or is some kind of pattern fill not > supported in the ImageDraw module. > > I'd like to draw some sort of striped pattern(s) but haven't found a > (built in) way to do it, of course it is possible to implement such > functionality by drawing the stripes myself, but I wanted to check if I > missed something simpler first. ImageDraw only supports solid fills. as a workaround, you can create a patterned image, draw the graphics in a separate image memory (the mask), and use im.paste(pattern, (0, 0), mask) to render the patterned object. From andre.kuehne at gmx.net Mon Aug 23 18:09:37 2004 From: andre.kuehne at gmx.net (Andre Kuehne) Date: Mon Aug 23 18:06:23 2004 Subject: [Image-SIG] pattern fill In-Reply-To: <1092132527.41189eaf1fbe8@webmail.abo.fi> References: <1092132527.41189eaf1fbe8@webmail.abo.fi> Message-ID: <20040823160937.GB28292@aku> Hi Here is a code snippet i wrote some time ago for filling a region (box) of an image (img) with a tile (src): def fillRegion(img, box, src): (left,top,right,bottom) = box (srcWidth, srcHeight) = src.size y = top remY = (bottom-top) while remY > 0: x = left remX = (right-left) while remX > 0: if remX >= srcWidth: if remY >= srcHeight: alphaPaste(img,src,(x,y)) putWidth = srcWidth putHeight = srcHeight else: frac = src.crop((0, 0, srcWidth, remY)) alphaPaste(img,frac,(x,y)) putWidth = srcWidth putHeight = remY else: if remY >= srcHeight: frac = src.crop((0, 0, remX, srcHeight)) alphaPaste(img,frac,(x,y)) putWidth = remX putHeight = srcHeight else: frac = src.crop((0, 0, remX, remY)) alphaPaste(img,frac,(x,y)) putWidth = remX putHeight = remY x += putWidth remX -= putWidth y += putHeight remY -= putHeight def alphaPaste(dst, src, box): if src.mode == "RGBA": dst.paste(src, box, src) else: dst.paste(src, box) If someone has a more elegant way to do this, it would be nice to see. regards -- _ _ _/\_| |_( )_ Andre Kuehne From francesco.pirotti at unipd.it Tue Aug 24 17:16:21 2004 From: francesco.pirotti at unipd.it (francesco) Date: Tue Aug 24 17:27:20 2004 Subject: [Image-SIG] assigning commands to a variable Message-ID: <5.1.1.6.0.20040824170540.00a76678@mail.unipd.it> Hi, is it possible to assign a string to a variable and then make python understand that it is not just text but a command? The actual problem is that I want to use the PIL filters, which are called .filter(ImageFilter.) filter_type can be a number of different filter types, like for example "BLUR" or "SMOOTH". My user chooses the filter type and then I have to put it in the function a = "BLUR" and then .filter(ImageFilter.a) but of course that does not work, as "a" is not recognized as a ImageFilter module and also assigning a = "ImageFilter.BLUR" does not work. Is there a trick? (I am obviously not an ace as programmer) Thank you, Francesco Pirotti From chris at cogdon.org Tue Aug 24 17:33:35 2004 From: chris at cogdon.org (Chris Cogdon) Date: Tue Aug 24 17:33:50 2004 Subject: [Image-SIG] assigning commands to a variable In-Reply-To: <5.1.1.6.0.20040824170540.00a76678@mail.unipd.it> References: <5.1.1.6.0.20040824170540.00a76678@mail.unipd.it> Message-ID: On Aug 24, 2004, at 08:16, francesco wrote: > Hi, > is it possible to assign a string to a variable and then make python > understand that it is not just text but a command? > > The actual problem is that I want to use the PIL filters, which are > called > > .filter(ImageFilter.) > > filter_type can be a number of different filter types, like for > example "BLUR" or "SMOOTH". > My user chooses the filter type and then I have to put it in the > function > > a = "BLUR" > and then > > .filter(ImageFilter.a) > > but of course that does not work, as "a" is not recognized as a > ImageFilter module and also assigning > > a = "ImageFilter.BLUR" > > does not work. Is there a trick? (I am obviously not an ace as > programmer) try using getattr. .filter( getattr ( ImageFilter, a ) ) -- ("`-/")_.-'"``-._ Chris Cogdon . . `; -._ )-;-,_`) (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' ((,.-' ((,/ fL From Chris.Barker at noaa.gov Tue Aug 24 18:36:17 2004 From: Chris.Barker at noaa.gov (Chris Barker) Date: Tue Aug 24 18:40:48 2004 Subject: [Image-SIG] assigning commands to a variable In-Reply-To: References: <5.1.1.6.0.20040824170540.00a76678@mail.unipd.it> Message-ID: <412B6E81.1030802@noaa.gov> Chris Cogdon wrote: > On Aug 24, 2004, at 08:16, francesco wrote: > >> Hi, >> is it possible to assign a string to a variable and then make python >> understand that it is not just text but a command? > try using getattr. > > .filter( getattr ( ImageFilter, a ) ) getattr is probably the best option here, but another one is eval: a = eval("ImageFilter.BLUR") .filter(a) (not tested, but something like that would work) -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker@noaa.gov From milgrom at gmail.com Wed Aug 25 11:46:27 2004 From: milgrom at gmail.com (Alfred Milgrom) Date: Wed Aug 25 11:46:35 2004 Subject: [Image-SIG] Re: Returning Colormap values for an image? In-Reply-To: References: <69AC6CCC-E5B7-11D8-A488-000A9574CFD8@earthlink.net><50eadd0a04081021335916c37a@mail.gmail.com><50eadd0a04081200072218c495@mail.gmail.com> <50eadd0a0408122350713ad1e0@mail.gmail.com> Message-ID: <50eadd0a0408250246793428b0@mail.gmail.com> Hi: Thanks for your reply. The use of the additional parameters in im = im.convert("P", dither=Image.NONE, palette=Image.ADAPTIVE) has made all the difference! My original image had only 3 colours, but using the plain vanilla im.convert("P") construct resulted in an image with 6 colours! However, with the additional parameters the conversion is perfect. Thanks again, Alfred Milgrom On Mon, 23 Aug 2004 13:46:44 +0200, Fredrik Lundh wrote: > Alfred Milgrom wrote: > > > The only problem (if you can call it that?) is that the colours > > actually used in the original image are not necessarily the first n > > values in the lut image, and so it is necessary to not only work out > > how many colours are used initially but also which indices are used. > > > > Is there an easier way to get a list of the indices used than something like: > > > > hist = im.histogram() > > coloursUsed = [i for i in range(len(hist)) if hist[i]] > > not really: the histogram approach is the only efficient way to find out > what colors you have in an L or P-mode image. > > > Also, if the image I have is an RGB image (such as the result of an > > ImageGrab), what is the best way to get the colours used? Is > > converting to 'P' mode and then using the resize/convert method the > > easiest/fastest? > > probably, as long as you're aware that you won't get exact results if > the image contains more than 256 colors. > > for best results, use: > > im = im.convert("P", dither=Image.NONE, palette=Image.ADAPTIVE) > > (no dithering, adaptive palette. if you need more control over the > process, you can use the undocumented quantize method, but you'll > have to read the source code to figure out how that works). From str_kbs at sancharnet.in Thu Aug 26 07:55:57 2004 From: str_kbs at sancharnet.in (General Electronics,Phaltan) Date: Thu Aug 26 12:58:44 2004 Subject: [Image-SIG] How can I read JPEG file read text from it References: <20040824100005.49C271E4006@bag.python.org> Message-ID: <000001c48b5d$5f068a20$a062013d@h5e1d0> Hi, Please help me to write application to read JPEG file and convert text to single TXT file i.e. OCR application. Thanks Arvind Sidhaye ----- Original Message ----- From: To: Sent: Tuesday, August 24, 2004 3:30 PM Subject: Image-SIG Digest, Vol 16, Issue 15 > Send Image-SIG mailing list submissions to > image-sig@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.python.org/mailman/listinfo/image-sig > or, via email, send a message with subject or body 'help' to > image-sig-request@python.org > > You can reach the person managing the list at > image-sig-owner@python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Image-SIG digest..." > ---------------------------------------------------------------------------- ---- > Today's Topics: > > 1. Re: Returning Colormap values for an image? (Fredrik Lundh) > 2. Re: pattern fill (Fredrik Lundh) > 3. Re: pattern fill (Andre Kuehne) > From chris at cogdon.org Thu Aug 26 17:38:00 2004 From: chris at cogdon.org (Chris Cogdon) Date: Thu Aug 26 17:38:11 2004 Subject: [Image-SIG] How can I read JPEG file read text from it In-Reply-To: <000001c48b5d$5f068a20$a062013d@h5e1d0> References: <20040824100005.49C271E4006@bag.python.org> <000001c48b5d$5f068a20$a062013d@h5e1d0> Message-ID: On Aug 25, 2004, at 22:55, General Electronics,Phaltan wrote: > Hi, > Please help me to write application to read JPEG file and convert text > to > single TXT file > i.e. OCR application. > Thanks > Arvind Sidhaye http://jocr.sourceforge.net/ Otherwise, you're asking us to dedicate our time to writing an extremely non-trivial application, for which the answer, at least from me, will invariably be 'no'. -- ("`-/")_.-'"``-._ Chris Cogdon . . `; -._ )-;-,_`) (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' ((,.-' ((,/ fL From montalia at vodafone.es Fri Aug 27 10:09:01 2004 From: montalia at vodafone.es (montalia@vodafone.es) Date: Fri Aug 27 10:12:01 2004 Subject: [Image-SIG] Mail System Error - Returned Mail Message-ID: <20040827081200.891EC1E4003@bag.python.org> The original message was included as attachment From oliver60201 at hotmail.com Mon Aug 30 15:49:45 2004 From: oliver60201 at hotmail.com (Oliver M. Haynold) Date: Mon Aug 30 16:00:59 2004 Subject: [Image-SIG] ANN: pytiff 0.1.3 Message-ID: Hello: I have written pytiff, a little library to read and write TIFF files with python. Pytiff also provides some simple filters. It is independent of PIL, but the two can interoperate easily. Here is a simple program that crops all pages of a TIFF file to 200 * 200: import pytiff reader=pytiff.TiffReader('source.tif') writer=pytiff.TiffWriter('dest.tif') for page in reader: writer.append(pytiff.CropFilter(page, (0,0), (200, 200))) Very Pythonic, isn't it? Pytiff is licensed under the GPL and available for download at . Have fun! Oliver -- For an email address I check more regularly, see . From klimek at grc.nasa.gov Mon Aug 30 16:42:52 2004 From: klimek at grc.nasa.gov (Bob Klimek) Date: Mon Aug 30 16:42:08 2004 Subject: [Image-SIG] ANN: pytiff 0.1.3 In-Reply-To: References: Message-ID: <41333CEC.6010401@grc.nasa.gov> Oliver M. Haynold wrote: >Hello: > >I have written pytiff, a little library to read and write TIFF files with >python. Pytiff also provides some simple filters. It is independent of >PIL, but the two can interoperate easily. Here is a simple program that >crops all pages of a TIFF file to 200 * 200: > >import pytiff >reader=pytiff.TiffReader('source.tif') >writer=pytiff.TiffWriter('dest.tif') >for page in reader: > writer.append(pytiff.CropFilter(page, (0,0), (200, 200))) > >Very Pythonic, isn't it? Pytiff is licensed under the GPL and available >for download at >. >Have fun! > > Nice and simple! But there's no mention of what the pixel depth is. Can it read 16-bit grayscale and 48-bit RGB TIFF images? Bob From fredrik at pythonware.com Mon Aug 30 16:48:49 2004 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon Aug 30 16:47:03 2004 Subject: [Image-SIG] Re: pytiff 0.1.3 References: Message-ID: Oliver M. Haynold wrote: > Very Pythonic, isn't it? Pytiff is licensed under the GPL except that the GPL isn't very pythonic, of course. can you perhaps license it under the Python license or at least use the LGPL? From oliver60201 at hotmail.com Mon Aug 30 18:45:46 2004 From: oliver60201 at hotmail.com (Oliver M. Haynold) Date: Mon Aug 30 18:45:51 2004 Subject: [Image-SIG] Re: ANN: pytiff 0.1.3 References: <41333CEC.6010401@grc.nasa.gov> Message-ID: On Mon, 30 Aug 2004 10:42:52 -0400, Bob Klimek wrote: > Nice and simple! But there's no mention of what the pixel depth is. Can > it read 16-bit grayscale and 48-bit RGB TIFF images? Each image has the bits_per_sample and samples_per_pixel attributes, which can assume any positive integer value. Then there's the photometric_interpretation attribute which is a string and currently can be grey (includes b/w), RGB, and RGBA; other values are permissible, but pytiff doesn't know their meaning. Thus pytiff should handle not only 16-bit greyscale and 48-bit RGB, but even oddities like three-bit greyscale (with the pixels not being byte-aligned). For things like cropping and rotating it's sufficient to know how many bits one pixel has and where the data of that pixel is located so that pytiff can handle these things pretty generally. The unit tests right now only check 1-bit b/w, 8-bit greyscale, and 24-bit RGB, though. Presently, the main limitations are that pytiff doesn't handle subdirectories (ignored), separated planes (raises an error), image depth greater than 1 (the z-dimension for pixels registered by SGI--does this really need to be supported?), and assumes all data to be unsigned integers (bad if they're really floats, complex numbers, etc.). These issues will be fixed in a subsequent release. Yours, Oliver -- For an email address I check more regularly, see . From oliver60201 at hotmail.com Mon Aug 30 18:54:08 2004 From: oliver60201 at hotmail.com (Oliver M. Haynold) Date: Mon Aug 30 18:54:12 2004 Subject: [Image-SIG] Re: pytiff 0.1.3 References: Message-ID: On Mon, 30 Aug 2004 16:48:49 +0200, Fredrik Lundh wrote: > except that the GPL isn't very pythonic, of course. can you perhaps > license it under the Python license or at least use the LGPL? [RMS rant about protecting your freedom deleted.] I'll consider it once the library gets more mature. The concept of a 'derivative work' seems to be less clear-cut in Python than linking against a library, but right now I want to think about pytiff itself and not its licensing terms. Yours, Oliver -- For an email address I check more regularly, see . From jchen at parc.com Mon Aug 30 20:03:18 2004 From: jchen at parc.com (JinDong (JD) Chen) Date: Mon Aug 30 20:03:47 2004 Subject: [Image-SIG] ANN: pytiff 0.1.3 In-Reply-To: References: Message-ID: <6.1.2.0.0.20040830110200.02e58b70@thelma.parc.xerox.com> Hi, Oliver, Can pytiff handles G4 compression? Thanks JD At 06:49 AM 08/30/2004, Oliver M. Haynold wrote: >Hello: > >I have written pytiff, a little library to read and write TIFF files with >python. Pytiff also provides some simple filters. It is independent of >PIL, but the two can interoperate easily. Here is a simple program that >crops all pages of a TIFF file to 200 * 200: > >import pytiff >reader=pytiff.TiffReader('source.tif') >writer=pytiff.TiffWriter('dest.tif') >for page in reader: > writer.append(pytiff.CropFilter(page, (0,0), (200, 200))) > >Very Pythonic, isn't it? Pytiff is licensed under the GPL and available >for download at >. >Have fun! > > Oliver >-- >For an email address I check more regularly, see >. > >_______________________________________________ >Image-SIG maillist - Image-SIG@python.org >http://mail.python.org/mailman/listinfo/image-sig From oliver60201 at hotmail.com Tue Aug 31 01:48:13 2004 From: oliver60201 at hotmail.com (Oliver M. Haynold) Date: Tue Aug 31 01:48:18 2004 Subject: [Image-SIG] Re: ANN: pytiff 0.1.3 References: <6.1.2.0.0.20040830110200.02e58b70@thelma.parc.xerox.com> Message-ID: On Mon, 30 Aug 2004 11:03:18 -0700, JinDong (JD) Chen wrote: > Can pytiff handles G4 compression? It uses libtiff for data access and thus supports all compression codecs of your libtiff version, including G4. Yours, Oliver -- For an email address I check more regularly, see .