From list@LISTME.COM Sun Mar 1 03:46:37 1998 From: list@LISTME.COM (list@LISTME.COM) Date: Sat, 28 Feb 1998 22:46:37 -0500 (EST) Subject: [IMAGE-SIG] OK to send e-mail? Message-ID: <199803010346.WAA19325@ns.LISTME.COM> OK to send an e-mail to image-sig@python.org? _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From dougal@gunters.org Wed Mar 4 02:25:50 1998 From: dougal@gunters.org (Dougal Campbell) Date: Tue, 3 Mar 1998 20:25:50 -0600 Subject: [IMAGE-SIG] OK to send e-mail? Message-ID: <002701bd4714$e2af4fe0$a5f210d1@londo> Sure, if you want to talk about image processing using the Python programming language. But I suspect that's not the case since I saw this exact message sent to my company's billing department earlier today, which makes me think that you're a spammer trying to trick people into giving you permission to mail them, avoiding any possible legal consequences of sending unsolicited email. Dougal Campbell dougal@gunters.org http://www.gunters.org/ "Don't be afraid of the dark" -----Original Message----- From: list@LISTME.COM To: image-sig@python.org Date: Sunday, March 01, 1998 5:08 AM Subject: [IMAGE-SIG] OK to send e-mail? >OK to send an e-mail to image-sig@python.org? > >_______________ >IMAGE-SIG - SIG on Image Processing with Python > >send messages to: image-sig@python.org >administrivia to: image-sig-request@python.org >_______________ > _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From skip@calendar.com (Skip Montanaro) Sun Mar 8 18:20:12 1998 From: skip@calendar.com (Skip Montanaro) (Skip Montanaro) Date: Sun, 8 Mar 1998 13:20:12 -0500 (EST) Subject: [IMAGE-SIG] split() problem? Message-ID: <199803081820.NAA07748@dolphin.automatrix.com> I'm using PIL 0.3a1 w/ Python 1.5. In the following code def geterror(im1, im2): if im1.mode != "RGB": im1 = im1.convert("RGB") if im2.mode != "RGB": im2 = im2.convert("RGB") ssplit = im1.split() osplit = im2.split() ... I get a traceback: exceptions.AttributeError, palette /usr/local/bin/optimage:831 in main opt = orig.optimize() /usr/local/bin/optimage:101 in optimize return self._optimize() /usr/local/bin/optimage:370 in _optimize errt = self.original.geterror(opt) /usr/local/bin/optimage:159 in geterror errterms.append(geterror(selfim.crop(box), /usr/local/bin/optimage:742 in geterror ssplit = im1.split() /usr/local/lib/python1.5/Imaging/Lib/Image.py:541 in split ims.append(self._makeself(self.im.getband(i))) /usr/local/lib/python1.5/Imaging/Lib/Image.py:219 in _makeself new.palette = self.palette I'm in the midst of upgrading to 0.3a3, but I didn't see anything in the CHANGES file that would suggest any errors in this code had been fixed, so I thought I'd mention the problem. Seems to me an RGB image should not have a palette... Skip Montanaro | Musi-Cal: http://concerts.calendar.com/ skip@calendar.com | Python Support: http://www.pythonpros.com/ (518)372-5583 | XEmacs: http://www.automatrix.com/~skip/xemacs/tip.html _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From skip@calendar.com (Skip Montanaro) Sun Mar 8 22:07:30 1998 From: skip@calendar.com (Skip Montanaro) (Skip Montanaro) Date: Sun, 8 Mar 1998 17:07:30 -0500 (EST) Subject: [IMAGE-SIG] Re: split() problem? Message-ID: <199803082207.RAA11351@dolphin.automatrix.com> I was getting a traceback: exceptions.AttributeError, palette ... /usr/local/lib/python1.5/Imaging/Lib/Image.py:541 in split ims.append(self._makeself(self.im.getband(i))) /usr/local/lib/python1.5/Imaging/Lib/Image.py:219 in _makeself new.palette = self.palette Upgrading to 0.3a3 didn't help. The object being split turned out to be an Image._ImageCrop instance, which is a subclass of Image.Image. The _ImageCrop __init__ method doesn't call the Image __init__ method, so it's missing a number of instance variables. Adding Image.__init__(self) as the first line of Image._ImageCrop.__init__ seems to solve the problem. Skip Montanaro | Musi-Cal: http://concerts.calendar.com/ skip@calendar.com | Python Support: http://www.pythonpros.com/ (518)372-5583 | XEmacs: http://www.automatrix.com/~skip/xemacs/tip.html _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From singer@itl.atr.co.jp Tue Mar 10 07:19:57 1998 From: singer@itl.atr.co.jp (Harald Singer) Date: Tue, 10 Mar 1998 16:19:57 +0900 Subject: [IMAGE-SIG] [FYI & Q] Problems installing PIL and spectrogram Message-ID: <3504E99D.AE9E90ED@itl.atr.co.jp> Hi, Some minor (and major) problems when installing PIL with PIL0.3a3, Python1.5, Linux2.0.32, Tk8.0p2 (+Japanese Patch 3) [1] spell miss? Lib/Image.py: from Types import IntType, StringType, TupleType Shouldn't this be types? I couldn't find any Types.py in Python1.5. [2] Then type (assuming a standard shell): $ cd test $ PYTHONPATH=..:../Lib ; export PYTHONPATH $ python >>> import _imaging >>> import Image I couldn't find any test directory. I then did mkdir test; cd test etc cp _imagingmodule.so /usr/local/lib/python1.5/site-packages cp -r Imaging/Lib /usr/local/lib/python1.5/Imaging export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python1.5/Imaging It seemed to work (don't know what I should expect, though). [3] I then followed the instructions to recompile tkinter but gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -DWITH_APPINIT -I/usr/local/include -c ./tkImaging.c ./tkImaging.c:44: Imaging.h: No such file or directory I then looked at the Modules/Setup file more closely. It is already prepared for PIL! I uncommented the PIL line in Modules/Setup and mv ../Extensions/Imaging-0.3a3 ../Extensions/Imaging However, then I get gcc -g -O2 -I./../Include -I.. -DHAVE_CONFIG_H -DWITH_APPINIT -I/usr/local/include -DWITH_PIL -I../Extensions/Imaging/libImaging -c ./tkImaging.c ./tkImaging.c: In function `PyImagingPhoto': ./tkImaging.c:76: warning: passing arg 1 of `Tk_FindPhoto' from incompatible pointer type ./tkImaging.c:76: too few arguments to function `Tk_FindPhoto' make: *** [tkImaging.o] Error 1 Looking at /usr/local/lib/tk.h #define TK_MAJOR_VERSION 8 #define TK_MINOR_VERSION 0 #define TK_RELEASE_LEVEL 2 #define TK_RELEASE_SERIAL 2 #define TK_VERSION "8.0" #define TK_PATCH_LEVEL "8.0p2" ... EXTERN Tk_PhotoHandle Tk_FindPhoto _ANSI_ARGS_((Tcl_Interp *interp, char *imageName)); ... I then changed in tkImaging.c photo = Tk_FindPhoto(argv[1]); to photo = Tk_FindPhoto(interp,argv[1]); and it compiled/linked! The following also worked bash$ cd Extension/Imaging/Scripts bash$ python1.5 viewer.py ../Images/lena.jpg worked. [4] now my major problem: I am trying to plot a spectrogram and I get this error: File "specgram.py", line 300, in __init__ photo = ImageTk.PhotoImage(image) File "/usr/local/lib/python1.5/Imaging/ImageTk.py", line 65, in __init__ mode = image.palette.mode AttributeError: attribute-less object if hasattr(image, "mode") and hasattr(image, "size"): # got an image instead of a mode mode = image.mode if mode == "P": # palette mapped data image.load() ==> mode = image.palette.mode size = image.size kw["width"], kw["height"] = size else: mode = image image = None If I change the offending line to mode = 'RGB' it somehow works, at least this works photo = ImageTk.PhotoImage(image) Tkinter.Button(self,image=photo, command=self.quit).pack() but this just shows a blank buttong Tkinter.Button(self,image=ImageTk.PhotoImage(image), command=self.quit).pack() BTW, to create this image I did something like # create a PIL image of palette type image = Image.new("P",(fftorder/2,yyy.shape[0])) image.im.putpalette("RGB", Colormap2Palette()) image.fromstring(yyy.tostring()) (if it is of interest I can post the complete source code for creating a colorful spectrogram, but I would rather find a fix before doing that) -- Harald Singer, ATR ITL, tel +81-7749-5-1389 singer@itl.atr.co.jp _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From singer@itl.atr.co.jp Tue Mar 17 02:43:24 1998 From: singer@itl.atr.co.jp (Harald Singer) Date: Tue, 17 Mar 1998 11:43:24 +0900 Subject: [IMAGE-SIG] [FYI & Q] Problems installing PIL and spectrogram References: <01bd4e4e$b1d53ec0$f29b12c2@panik.pythonware.com> Message-ID: <350DE34C.693308BF@itl.atr.co.jp> Fredrik Lundh wrote: > > Oh, you obviously missed the patch kit and Skip's fixes to the > palette attribute error posted to the image sig not long ago... > > I've attached the patches, but you might as well wait until > after the weekend: 0.3b1 (or maybe it's 0.3a4) will ship > on Saturday or Sunday. [1] Thanks for the info. I just noticed that http://www.pythonware.com/downloads.htm doesn't contain any mentioning of patch files. Do you have a public place for patches? [2] my palette problem was that I used image = Image.new("P",(128,64)) image.im.putpalette("RGB", Colormap2Palette()) instead of image = Image.new("P",(128,64)) image.putpalette(Colormap2Palette(),"RGB") It looks like my old version of PIL did not support image.putpalette, so now I have to do try: # 0.3a3 and later image.putpalette(Colormap2Palette(),"RGB") except: # before 0.3a3, but needs patch of ImageTk.py image.im.putpalette("RGB", Colormap2Palette()) [3] I still have a very serious problem: I am trying to put an image onto a tk button/label but the button/label stays grey. # this just gives me a grey button. why???? Tkinter.Button(self,image=ImageTk.PhotoImage(image),command=self.quit).pack() # this (sometimes) works x = ImageTk.PhotoImage(image) Tkinter.Button(self,image=x,command=self.quit).pack() However, when I use the same technique in a real program it doesn't work, i.e. always grey. No warning messages and image.show(), i.e. using xv, always works. Is this a timing problem?? Or do I make some fundamental mistake using PIL with tcl/tk? (tcl/tk8.0p2, python1.5 on Linux 2.0.32 slackware). I had no problem with tcl7.4/tk4.2 :-( [4] Here is the complete test script #!/bin/sh """:" exec python $0 ${1+"$@"} """ """ H. Singer, DEC97, ATR ITL preparation for spectrogram display for speech files requires PIL """ import string,os import Image, ImageDraw, ImageTk # from PIL # a colormap colormapjet = """ 0 0 0.5625 0 0 0.6250 0 0 0.6875 0 0 0.7500 0 0 0.8125 0 0 0.8750 0 0 0.9375 0 0 1.0000 0 0.0625 1.0000 0 0.1250 1.0000 0 0.1875 1.0000 0 0.2500 1.0000 0 0.3125 1.0000 0 0.3750 1.0000 0 0.4375 1.0000 0 0.5000 1.0000 0 0.5625 1.0000 0 0.6250 1.0000 0 0.6875 1.0000 0 0.7500 1.0000 0 0.8125 1.0000 0 0.8750 1.0000 0 0.9375 1.0000 0 1.0000 1.0000 0.0625 1.0000 1.0000 0.1250 1.0000 0.9375 0.1875 1.0000 0.8750 0.2500 1.0000 0.8125 0.3125 1.0000 0.7500 0.3750 1.0000 0.6875 0.4375 1.0000 0.6250 0.5000 1.0000 0.5625 0.5625 1.0000 0.5000 0.6250 1.0000 0.4375 0.6875 1.0000 0.3750 0.7500 1.0000 0.3125 0.8125 1.0000 0.2500 0.8750 1.0000 0.1875 0.9375 1.0000 0.1250 1.0000 1.0000 0.0625 1.0000 1.0000 0 1.0000 0.9375 0 1.0000 0.8750 0 1.0000 0.8125 0 1.0000 0.7500 0 1.0000 0.6875 0 1.0000 0.6250 0 1.0000 0.5625 0 1.0000 0.5000 0 1.0000 0.4375 0 1.0000 0.3750 0 1.0000 0.3125 0 1.0000 0.2500 0 1.0000 0.1875 0 1.0000 0.1250 0 1.0000 0.0625 0 1.0000 0 0 0.9375 0 0 0.8750 0 0 0.8125 0 0 0.7500 0 0 0.6875 0 0 0.6250 0 0 0.5625 0 0 """ def Colormap2Palette(colormap=colormapjet): """ convert a matlab type colormap to a PIL palette """ x = map(lambda x,colormap=colormap: int(string.atof(x)*255), string.split(colormap)) palette = [(0,0,0)] * 256 for i in range(len(x)/3): palette[i] = (x[i*3], x[i*3+1], x[i*3+2]) palette = map(lambda a: chr(a[0])+chr(a[1])+chr(a[2]), palette) palette = string.join(palette, "") return palette def _test(xvPreview=1): """ display the range of values in the palette """ image = Image.new("P",(128,64)) image.putpalette(Colormap2Palette(),"RGB") # create some data between 0 and 63 data = map(lambda x: chr(x), range(0,64)) data = string.join(data,'') data = data * 128 image.fromstring(data) out = image.transpose(Image.ROTATE_90) if xvPreview: out.show() return out import Tkinter class Test(Tkinter.Frame): def __init__(self): Tkinter.Frame.__init__(self) Tkinter.Pack.config(self) image = _test() # this just gives me a grey button. why???? # Tkinter.Button(self,image=ImageTk.PhotoImage(image),command=self.quit).pack() # this works x = ImageTk.PhotoImage(image) Tkinter.Button(self,image=x,command=self.quit).pack() self.mainloop() if __name__ == '__main__': Test() ### EOF -- Harald Singer, ATR ITL, tel +81-7749-5-1389 singer@itl.atr.co.jp _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From fredrik@pythonware.com Tue Mar 17 11:42:57 1998 From: fredrik@pythonware.com (Fredrik Lundh) Date: Tue, 17 Mar 1998 12:42:57 +0100 Subject: [IMAGE-SIG] [FYI & Q] Problems installing PIL and spectrogram Message-ID: <01bd5199$d4f4c8a0$f29b12c2@panik.pythonware.com> >Thanks for the info. I just noticed that > http://www.pythonware.com/downloads.htm >doesn't contain any mentioning of patch files. Do you have a public >place for patches? http://www.findmail.com/listsaver/image-sig/ And yes, I just upload 0.3a4 to that pythonware address... >[3] I still have a very serious problem: I am trying to put >an image onto a tk button/label but the button/label stays grey. > > # this just gives me a grey button. why???? > Tkinter.Button(self,image=ImageTk.PhotoImage(image),command=self.quit).pack() > > # this (sometimes) works > x = ImageTk.PhotoImage(image) > Tkinter.Button(self,image=x,command=self.quit).pack() This is the infamous "image reference" problem; quoting myself from a comp.lang.python post: > I thought Button() would already increment the ref count of > the object. Well, the Tk button widget keeps a reference to the internal photoimage object, but Tkinter does not. So when the last Python reference goes away, Tkinter tells Tk to release the photoimage. But since the image is in use by a widget, Tk doesn't destroy it. Not completely. It just blanks the image, making it completely transparent... And yes, there was a bug in the keyword argument handling in 1.4 that kept an extra reference around in some cases. And when Guido fixed that bug in 1.5, he broke quite a few Tkinter programs... To solve this, always make sure you keep your own reference to the photo object. Here's one way to do it: x = ImageTk.PhotoImage(image) w = Tkinter.Button(self,image=x,command=self.quit) w.image = x w.pack() Cheers /F fredrik@pythonware.com http://www.pythonware.com _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From khilman@equator.com Thu Mar 19 20:43:59 1998 From: khilman@equator.com (Kevin Hilman) Date: 19 Mar 1998 12:43:59 -0800 Subject: [IMAGE-SIG] Animations with PIL Message-ID: Is there a way to display a sequence of images in the same window? It looks like PIL uses xv, and I don't think it's possible that way. Basically I'd like to display images as fast as they can be read from disk, but they need to be displayed in the same window. -- Kevin Hilman _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From cgw@pgt.com Thu Mar 19 21:04:16 1998 From: cgw@pgt.com (Charles G Waldman) Date: Thu, 19 Mar 1998 16:04:16 -0500 (EST) Subject: [IMAGE-SIG] Animations with PIL Message-ID: <199803192104.QAA11660@reactor.pgt.com> >Is there a way to display a sequence of images in the >same window? One approach to this (it's a bit unusual but it works) is to use server-push to create the animation in a Netscape window. I mention this because I've recently been writing some Python scripts to do exactly this. Alternately you could use Tk and TkImage and create your own little animation frame. _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From fredrik@pythonware.com Fri Mar 20 08:13:20 1998 From: fredrik@pythonware.com (Fredrik Lundh) Date: Fri, 20 Mar 1998 09:13:20 +0100 Subject: [IMAGE-SIG] Animations with PIL Message-ID: <01bd53d8$0ba5d2a0$f29b12c2@panik.pythonware.com> >Is there a way to display a sequence of images in the >same window? It looks like PIL uses xv, and I don't think >it's possible that way. The show method uses xv. If you wish to do something else, you have to hack it yourself using your favourite GUI. See the ImageTk and ImageWin sections on: http://www.pythonware.com/library/pil/handbook/index.htm for interface modules for Tk(inter) and Win32. If you prefer another GUI, you have to roll your own interface. For a complete Tk example, see the Scripts/player.py utility shipped with PIL. Cheers /F fredrik@pythonware.com http://www.pythonware.com _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From fredrik@pythonware.com Fri Mar 20 08:16:51 1998 From: fredrik@pythonware.com (Fredrik Lundh) Date: Fri, 20 Mar 1998 09:16:51 +0100 Subject: [IMAGE-SIG] ImageFont problems Message-ID: <01bd53d8$8943b880$f29b12c2@panik.pythonware.com> (caught by the spam filter /F) Date: Thu, 19 Mar 1998 20:21:41 -0500 (EST) From: cgw@pgt.com (Charles G Waldman) Message-Id: <199803200121.UAA22846@reactor.pgt.com> To: image-sig@python.org Subject: Help with ImageFont I have Imaging-0.3a4 and pilfont-970826 I'm not sure where ".pil" fonts are supposed to come from; I ran "pilfont.py /usr/X11R6/lib/X11/fonts/75dpi/lutRS12.pcf" which produced for me the file "lutRS12.pil". So far so good. (I'm proceeding by guesswork, since I can't find docs for ImageFont anywhere...) Now, I do >>> import Image, ImageFont >>> x = ImageFont.load("lutRS12.pil") Traceback (innermost last): File "", line 1, in ? File "ImageFont.py", line 105, in load f._load_pilfont(filename) File "ImageFont.py", line 76, in _load_pilfont self.image = Image.open(os.path.splitext(filename)[0] + ".pbm") File "/usr/local/lib/python1.5/Imaging/Image.py", line 736, in open fp = __builtin__.open(fp, "rb") IOError: (2, 'No such file or directory') Apparently, it's not the ".pil" file it's having trouble finding but some ".pbm" file. Where is this supposed to be coming from? What am I doing wrong? Thanks. _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From rob@zeus.hud.ac.uk Fri Mar 27 10:23:05 1998 From: rob@zeus.hud.ac.uk (R Fisher) Date: Fri, 27 Mar 1998 10:23:05 GMT Subject: [Image-SIG] problems with PIL Message-ID: <199803271023.KAA24644@ares.ac.uk> Hi, I'm trying to build PIL with TkInter support into Python1.5, under Solaris 2.5. I have unpacked the distribution into Python-1.5/Extensions/Imaging, built the core library and _imagingmodule.so, and have edited Modules/Setup to include TkInter (compilation is fine with this alone enabled) and PIL. When I do a make, it fails with: making Makefile in subdirectory Modules `Makefile' is up to date. cd Parser ; make OPT="-g -O2" VERSION="1.5" \ prefix="/usr/local" exec_prefix="/usr/local" all cd Objects ; make OPT="-g -O2" VERSION="1.5" \ prefix="/usr/local" exec_prefix="/usr/local" all cd Python ; make OPT="-g -O2" VERSION="1.5" \ prefix="/usr/local" exec_prefix="/usr/local" all cd Modules ; make OPT="-g -O2" VERSION="1.5" \ prefix="/usr/local" exec_prefix="/usr/local" all make: Fatal error: Don't know how to make target `tkImaging.c' Current working directory /home/staff2/rob/tmp/Python-1.5/Modules *** Error code 1 make: Fatal error: Command failed for target `Modules' I've tried everything I can think of, but I can't get the thing to build. Any ideas? Thanks, Rob