From tommy@kerner.com Tue Apr 1 21:48:20 1997 From: tommy@kerner.com (Tommy Burnette) Date: Tue, 1 Apr 1997 13:48:20 -0800 Subject: [PYTHON IMAGE-SIG] extending PIL? Message-ID: <199704012148.NAA13060@derlin.kerner.com> Hey there, Just wondering if anyone can get me started on how I would add my own image format to PIL. It seems like it is set up to make this pretty easy, but a little template/sample code would help immensely. I looked for a FAQ in the sig pages of python.org and found none. Any help would be greatly appreciated- Thanks, Tommy. _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From fredrik_lundh@ivab.se Wed Apr 2 14:37:01 1997 From: fredrik_lundh@ivab.se (Fredrik Lundh) Date: Wed, 2 Apr 1997 16:37:01 +0200 Subject: [PYTHON IMAGE-SIG] extending PIL? In-Reply-To: <199704012148.NAA13060@derlin.kerner.com> (message from Tommy Burnette on Tue, 1 Apr 1997 13:48:20 -0800) Message-ID: <9704021437.AA13658@arnold.image.ivab.se> > Just wondering if anyone can get me started on how I would add my > own image format to PIL. It seems like it is set up to make this > pretty easy, but a little template/sample code would help immensely. > I looked for a FAQ in the sig pages of python.org and found none. > Any help would be greatly appreciated. The closest you can get to a PIL FAQ is the material available via: http://hem1.passagen.se/eff/pil For your convenience, I just added some material on file format handlers to the "PIL Notes" section. Cheers /F (http://hem1.passagen.se/eff) _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From fdrake@CNRI.Reston.Va.US Thu Apr 3 20:29:15 1997 From: fdrake@CNRI.Reston.Va.US (Fred L. Drake) Date: Thu, 3 Apr 1997 15:29:15 -0500 (EST) Subject: [PYTHON IMAGE-SIG] tkImaging.c Message-ID: <199704032029.PAA19908@weyr.CNRI.Reston.Va.US> Fredrik, I've got a question / suggestion / requirement for PIL & the Tk interface. The current model for Tk with PIL is to build a separate version of _tkinter; this can be highly problematic in some situations, such as when you need to know that your Python installation is pristine (as is the case here at CNRI). I'd like to suggest another alternative. The only reason that _tkinter needs to be rebuilt is to add a new type of photo image, at least as far as I can tell. Is there any reason that this must be done during the "app init" phase of Tcl/Tk initialization and not after? If not, then a new module, _tkimaging perhaps, can be built and imported by ImageTk. The initialization of this new module should proceed as follows: 1. import _tkinter using the Python C API. 2. import _imaging using the Python C API. 3. create the new photo image handler using the Tk C API. Performing the imports before installing the new image type should be sufficient since the image type does not require a Tcl interpreter to be associated with. Do you think this is a reasonable and feasible approach? I'd be glad to help out with coding / testing if you think this would work. -Fred -- Fred L. Drake, Jr. fdrake@cnri.reston.va.us Corporation for National Research Initiatives 1895 Preston White Drive Reston, VA 20191-5434 _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From fdrake@CNRI.Reston.Va.US Fri Apr 4 19:19:47 1997 From: fdrake@CNRI.Reston.Va.US (Fred L. Drake) Date: Fri, 4 Apr 1997 14:19:47 -0500 (EST) Subject: [PYTHON IMAGE-SIG] GIF animations in Grail Message-ID: <199704041919.OAA23251@weyr.CNRI.Reston.Va.US> Here's a filetype handler for Grail that does GIF animations for GIF files loaded as documents; this doesn't handle "in-line" GIFs. (Sorry!) Save this as ~/.grail/filetypes/image_gif.py, and make sure the file Grail/pil_interface.py from the PIL distribution is available for Grail (it can be placed in the same directory). -Fred -- Fred L. Drake, Jr. fdrake@cnri.reston.va.us Corporation for National Research Initiatives 1895 Preston White Drive Reston, VA 20191-5434 =========================================================================== # Grail interface to PIL, with support for animated GIFs. import grailutil import Image import ImageTk import pil_interface import string import StringIO import sys import Tkinter class parse_image_gif(pil_interface.pil_interface): im = None currentpos = 0 duration = 0 loop = 0 def close(self): if self.buf: try: self.label.config(text="") self.label.update_idletasks() self.buf = string.joinfields(self.buf, "") self.im = im = Image.open(StringIO.StringIO(self.buf)) im.load() # benchmark decoding self.tkim = tkim = ImageTk.PhotoImage(im.mode, im.size) tkim.paste(im) self.label.image = tkim.image self.label.config(image=self.label.image) if im.info.has_key("duration"): self.duration = im.info["duration"] if im.info.has_key("loop"): self.duration = self.duration or 100 self.loop = im.info["loop"] if self.duration or self.loop: self.viewer.register_reset_interest(self.cancel_loop) self.after_id = self.label.after(self.duration, self.next_image) except: self.broken = 1 stdout = sys.stdout try: sys.stdout = sys.stderr print "Error decoding image:" print sys.exc_type + ":", sys.exc_value finally: sys.stdout = stdout if self.broken: self.label.image = Tkinter.PhotoImage( file=grailutil.which(ERROR_FILE)) self.label.config(image = self.label.image) self.viewer.text.insert(Tkinter.END, '\nBroken Image!') def next_image(self): newpos = self.currentpos + 1 try: self.im.seek(newpos) except (ValueError, EOFError): self.viewer.unregister_reset_interest(self.cancel_loop) return # ignore looping for now.... self.currentpos = newpos self.tkim.paste(self.im) self.after_id = self.label.after(self.duration, self.next_image) def cancel_loop(self, *args): self.viewer.unregister_reset_interest(self.cancel_loop) self.label.after_cancel(self.after_id) _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From fredrik_lundh@ivab.se Fri Apr 4 19:40:53 1997 From: fredrik_lundh@ivab.se (Fredrik Lundh) Date: Fri, 4 Apr 1997 21:40:53 +0200 Subject: [PYTHON IMAGE-SIG] GIF animations in Grail In-Reply-To: <199704041919.OAA23251@weyr.CNRI.Reston.Va.US> (fdrake@CNRI.Reston.Va.US) Message-ID: <9704041940.AA32434@arnold.image.ivab.se> > Here's a filetype handler for Grail that does GIF animations for GIF > files loaded as documents. Cool! > This doesn't handle "in-line" GIFs. (Sorry!) In 0.3b4, perhaps? Cheers /F (http://hem1.passagen.se/eff) _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From fdrake@CNRI.Reston.Va.US Fri Apr 4 19:48:30 1997 From: fdrake@CNRI.Reston.Va.US (Fred L. Drake) Date: Fri, 4 Apr 1997 14:48:30 -0500 (EST) Subject: [PYTHON IMAGE-SIG] GIF animations in Grail In-Reply-To: <9704041940.AA32434@arnold.image.ivab.se> from "Fredrik Lundh" at Apr 4, 97 09:40:53 pm Message-ID: <199704041948.OAA23354@weyr.CNRI.Reston.Va.US> Fredrik Lundh wrote: > > This doesn't handle "in-line" GIFs. (Sorry!) > > In 0.3b4, perhaps? We're really hoping 0.3 will be the next release; I'm not aware of any plans for another 0.3 beta. The extension module I just posted is not part of Grail. Unlike Grail, it *requires* PIL. Perhaps I'll have something like it in Grail 0.4, but I can't promise the lawyers will ever let us release such a beast. ;-) But I will try to get a reasonable version of this stuff into 0.4. The only things going into 0.3 at this point are bug fixes. You are, however, welcome to distribute that module in the Grail/ directory of PIL! -Fred -- Fred L. Drake, Jr. fdrake@cnri.reston.va.us Corporation for National Research Initiatives 1895 Preston White Drive Reston, VA 20191-5434 _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From fredrik_lundh@ivab.se Fri Apr 4 20:10:31 1997 From: fredrik_lundh@ivab.se (Fredrik Lundh) Date: Fri, 4 Apr 1997 22:10:31 +0200 Subject: [PYTHON IMAGE-SIG] GIF animations in Grail In-Reply-To: <199704041948.OAA23354@weyr.CNRI.Reston.Va.US> (fdrake@CNRI.Reston.VA.US) Message-ID: <9704042010.AA00317@arnold.image.ivab.se> > The extension module I just posted is not part of Grail. Unlike > Grail, it *requires* PIL. Perhaps I'll have something like it in > Grail 0.4, but I can't promise the lawyers will ever let us release > such a beast. Maybe you could tweak things so that in-line and extension document types can be handled by the same driver. > You are, however, welcome to distribute that module in the Grail/ > directory of PIL! I'll ship it with 0.2b5 (anyday soon ;-) Cheers /F (http://hem1.passagen.se/eff) _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From fdrake@CNRI.Reston.Va.US Fri Apr 18 22:34:36 1997 From: fdrake@CNRI.Reston.Va.US (Fred L. Drake) Date: Fri, 18 Apr 1997 17:34:36 -0400 (EDT) Subject: [PYTHON IMAGE-SIG] Saving as "compressed" EPS? Message-ID: <199704182134.RAA18984@weyr.CNRI.Reston.Va.US> Has anyone worked on saving images as EPS with compressed image data? A single image with uncompressed data may not be too bad, but I'm converting a large document from an HTML tree to a PostScript file, and large images are causing the size to really jump up (to 51MB!). Compressed data in the EPS would be really helpful. ;-) -Fred -- Fred L. Drake, Jr. fdrake@cnri.reston.va.us Corporation for National Research Initiatives 1895 Preston White Drive Reston, VA 20191-5434 _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From kent@eaenki.nde.swri.edu Mon Apr 21 15:31:50 1997 From: kent@eaenki.nde.swri.edu (Kent Polk) Date: Mon, 21 Apr 1997 14:31:50 Subject: [PYTHON IMAGE-SIG] new PIL user? Message-ID: <244f3b54.89Ute7.452cb-kent@eaenki.nde.swri.edu> I have a few questions regarding PIL. First, why am I interested? I work at Southwest Research Institute as a general-purpose research scientist. Somewhat specialize in computer data acquisition and data analysis applications, but do everything from building automated movable incore monitoring systems to GIS database and WWW data and information-handling applications. As to GIS applications, I often do a lot of work for one of our geologic analysis GIS groups, building custom and ARC/Info databases from raw data and images, etc. So I am very interested in potential PIL applications to the GIS field. Particulary that of automating the building geo-referenced data sets including sparse matrix image sets. However, what caused me to build PIL locally was the mention of WMF read support. I am building a custom group document-development WWW application in which I need to convert microsoft Word and PowerPoint files to HTML on a Solaris www server. :^( Tackling the problem on piece at a time, I need to be able to convert wmf files to something else under unix. I talked to Fredrik Lundh about the wmf support (after reading his announcement disclaimer). I've also taken a look at the PIL drawing library somewhat. I noticed from the limited information about wmf that I have found (does anyone have up-to-date information about the WMF format?) that the drawing methods are almost 1-1 like the Ghostscript drawing primitives. PIL still appears somewhat primitive in this area unless I completely missed something. Has anyone considered using the ghostscript drawing library (bypassing postscript) to render images for PIL? Thanks Kent Polk: Southwest Research Institute Internet : kent@eaenki.nde.swri.edu _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From vorlon@iglou.com Tue Apr 22 19:43:45 1997 From: vorlon@iglou.com (Jimmy Mckinney) Date: Tue, 22 Apr 1997 14:43:45 -0400 Subject: [PYTHON IMAGE-SIG] PIL formats Message-ID: Any plans to support amiga IFF ILBM and HAM formats? _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From kent@eaenki.nde.swri.edu Tue Apr 22 17:00:19 1997 From: kent@eaenki.nde.swri.edu (Kent Polk) Date: Tue, 22 Apr 1997 16:00:19 Subject: [PYTHON IMAGE-SIG] PIL formats In-Reply-To: (from Jimmy Mckinney ) (at Tue, 22 Apr 1997 14:43:45 -0400) Message-ID: <2450a187.89Ute7.c762c-kent@eaenki.nde.swri.edu> Hi Jimmy (Jimmy Mckinney), in on Apr 22 you wrote: > Any plans to support amiga IFF ILBM and HAM formats? I believe that Ty Sarna (tsarna@endicor.com) mentioned that he had translated the iffparse library to Python. Maybe he'll respond... Kent Polk: Southwest Research Institute Internet : kent@eaenki.nde.swri.edu _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From tsarna@endicor.com Tue Apr 22 22:55:45 1997 From: tsarna@endicor.com (Ty Sarna) Date: Tue, 22 Apr 1997 16:55:45 -0500 (CDT) Subject: [PYTHON IMAGE-SIG] PIL formats In-Reply-To: <2450a187.89Ute7.c762c-kent@eaenki.nde.swri.edu> from "Kent Polk" at Apr 22, 97 04:00:19 pm Message-ID: <199704222155.QAA14571@lotharon.endicor.com> Kent Polk wrote: > > Hi Jimmy (Jimmy Mckinney), in on Apr 22 you wrote: > > > Any plans to support amiga IFF ILBM and HAM formats? > > I believe that Ty Sarna (tsarna@endicor.com) mentioned that he > had translated the iffparse library to Python. Maybe he'll > respond... Just the IFF writing part. And you'd still need all the code to handle the actual ILBM chunks. I think you'd want to do that in C for reasonable speed... you don't want to use Python for chunky<->planar conversions unless you have a _lot_ of time on your hands! NetPBM's ilbmtoppm is slow enough in C. _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From kent@eaenki.nde.swri.edu Wed Apr 23 17:22:14 1997 From: kent@eaenki.nde.swri.edu (Kent Polk) Date: Wed, 23 Apr 1997 16:22:14 Subject: [PYTHON IMAGE-SIG] PIL questions: Message-ID: <2451f82e.89Ute7.c3510-kent@eaenki.nde.swri.edu> 1) Why am I having trouble saving jpegs? : imput file type: File "pp2jpg.py", line 42, in ? out.save(newfile,'JPEG') File "/usr/local/lib/python1.4/Image.py", line 356, in save SAVE[string.upper(format)](self, fp, filename) File "/usr/local/lib/python1.4/JpegImagePlugin.py", line 285, in _save ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, im.mode)]) File "/usr/local/lib/python1.4/ImageFile.py", line 229, in _save e = _getencoder(e, b, a, im.encoderconfig) File "/usr/local/lib/python1.4/ImageFile.py", line 63, in _getencoder raise IOError, "encoder %s not available" % d IOError: encoder jpeg not available or: Traceback (innermost last): File "pp2jpg.py", line 42, in ? out.save(newfile,'JFIF') File "/usr/local/lib/python1.4/Image.py", line 358, in save raise IOError, "cannot save %s files" % v IOError: cannot save JFIF files yet: ld -G _imagingmodule.o decode.o encode.o display.o path.o libImaging/libImaging.a /usr/local/lib/libjpeg.a /usr/local/lib/libz.a -o _imagingmodule.so /usr/local/lib/libjpeg.a is valid... 2) How to convert from 'RGB' (PPM 425x550) to 'P' (GIF)? I read the point method which I presume one could use to affect the conversion, but how does know how to build the table? Thanks _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________