From edcjones@erols.com Wed Aug 5 09:34:42 1998 From: edcjones@erols.com (Edward C. Jones) Date: Wed, 05 Aug 1998 04:34:42 -0400 Subject: [Image-SIG] Is blend broken? Message-ID: <35C81922.303F80CE@erols.com> Is Image.blend broken or did I make an error installing PIL? -------------------------------------------------------- #! /usr/bin/python import string, Image, zlib x = Image.open('/home/edcjones/imagedb/dallas1.jpg') z = Image.blend(x, x, .5) print z.size --------------------------------------------------------- Traceback (innermost last): File "./test.py", line 6, in ? z = Image.blend(x, x, .5) File "/usr/lib/python1.5/site-packages/PIL/Image.py", line 835, in blend return Image()._makeself(core.blend(im1.im, im2.im, alpha)) TypeError: argument 1: expected ImagingCore, None From louisb@ix.netcom.com Tue Aug 11 13:03:05 1998 From: louisb@ix.netcom.com (louisb@ix.netcom.com) Date: Tue, 11 Aug 1998 07:03:05 -0500 (CDT) Subject: [Image-SIG] Basic problem Message-ID: <199881172213341@ix.netcom.com> Looking for comments ... I seem to have neglected some initial setup task. I get the following error regardless of what image file I attempt to open. (lena.gif, lena.ppm, lena.jpg) "test.bmp" was made from the Microsoft Paint program. >>> import Image >>> im = Image.open('c:/proj/wavelet/test.bmp') Traceback (innermost last): File "", line 1, in ? File "C:\Python\modules\pil\imaging\Image.py", line 731, in open raise IOError, "cannot identify image file" IOError: cannot identify image file >>> I'm using Win95 with Pyth151.exe and pil.zip from the same download page. I can't seem to fault the "preinit()" function in Image.py. From fredrik@pythonware.com Tue Aug 11 14:24:50 1998 From: fredrik@pythonware.com (Fredrik Lundh) Date: Tue, 11 Aug 1998 14:24:50 +0100 Subject: [Image-SIG] Basic problem Message-ID: <011501bdc52b$73b52980$f29b12c2@pythonware.com> >I seem to have neglected some initial setup task. I get the following error >regardless of what image file I attempt to open. (lena.gif, lena.ppm, lena.jpg) > >"test.bmp" was made from the Microsoft Paint program. > >>>> import Image >>>> im = Image.open('c:/proj/wavelet/test.bmp') >Traceback (innermost last): > File "", line 1, in ? > File "C:\Python\modules\pil\imaging\Image.py", line 731, in open > raise IOError, "cannot identify image file" >IOError: cannot identify image file >>>> > >I'm using Win95 with Pyth151.exe and pil.zip from the same download page. try this: >>> import Image >>> Image.init() >>> Image.OPEN {'PNG': (, ), ... lots of similar items in random order ... })} if the dictionary is empty, you must make sure that the image drivers (the *ImagePlugin.py files) are in a directory along the Python search path. Cheers /F fredrik@pythonware.com http://www.pythonware.com From doko@cs.tu-berlin.de Tue Aug 11 13:52:06 1998 From: doko@cs.tu-berlin.de (Matthias Klose) Date: Tue, 11 Aug 1998 14:52:06 +0200 (MET DST) Subject: [Image-SIG] PIL as loadable Tcl module (0.3b2) Message-ID: <13776.15416.89012.102115@gargleblaster> Attached is a patch to build a dynamically loadable Pil Tcl module, such that no recompilation of the Tkinter module is needed. This is tested on Linux glibc2 and Solaris2.6. In the Makefile INCLUDES, LIBDIRS and LIBS need to edited by hand ... The two file PIL.so and pkgIndex.tcl need to be installed in a subdirectory of $tcl_pkgPath --- pil-0.3b2.orig/PIL/ImageTk.py +++ pil-0.3b2/PIL/ImageTk.py @@ -110,6 +110,7 @@ block = image.new_block(self.__mode, im.size) image.convert2(block, image) # convert directly between buffers + self.__photo.tk.call("package", "require", "Pil") self.__photo.tk.call("PyImagingPhoto", self.__photo, block.id) --- pil-0.3b2.orig/Tk/tkImaging.c +++ pil-0.3b2/Tk/tkImaging.c @@ -183,9 +183,22 @@ } +#ifdef PIL_MODULE +int +Pil_Init(Tcl_Interp* interp) +{ + Tcl_CreateCommand(interp, "PyImagingPhoto", PyImagingPhoto, + (ClientData) 0, (Tcl_CmdDeleteProc*) NULL); + if (Tcl_PkgProvide(interp, "Pil", "0.3") != TCL_OK) { + return TCL_ERROR; + } + return TCL_OK; +} +#else void TkImaging_Init(Tcl_Interp* interp) { Tcl_CreateCommand(interp, "PyImagingPhoto", PyImagingPhoto, (ClientData) 0, (Tcl_CmdDeleteProc*) NULL); } +#endif --- pil-0.3b2.orig/Tk/Makefile +++ pil-0.3b2/Tk/Makefile @@ -0,0 +1,50 @@ +# The C compiler: +CC = cc + +# Compiler options: +COPTS = -O2 -fpic -DPIL_MODULE + +# Name for the shared lib: +SH_LIB = PIL.so + +# Shared library linker command: +SHLINK = cc -shared + +# Where to find tcl.h, tk.h +INCLUDES = + +# Where to find libtcl.a, libtk.a +LIBDIRS = + +# Libraries to link with (-ldl for Linux only?): +LIBS = -ltk8.0 -ltcl8.0 -lm -lc -ldl + +TK_FLAGS = + + +#### Shouldn't have to change anything beyond this point #### + + +CFLAGS = $(COPTS) $(INCLUDES) $(TK_FLAGS) + +LFLAGS = $(LIBDIRS) + +all: shared pkgIndex.tcl + +shared: $(SH_LIB) + +tkImaging.o: tkImaging.c + $(CC) -c -I../libImaging $(CFLAGS) tkImaging.c + + +$(SH_LIB): tkImaging.o + $(SHLINK) $(LFLAGS) $(LIBS) tkImaging.o -o $@ + +pkgIndex.tcl: $(SH_LIB) + echo pkg_mkIndex . $(SH_LIB) | tclsh8.0 + +clean: + -rm -f *.o *~ core pkgIndex.tcl + +realclean: + -rm -f *.o *~ core *.so pkgIndex.tcl From Brian_Adams@brown.edu Mon Aug 24 21:24:16 1998 From: Brian_Adams@brown.edu (Brian Adams) Date: Mon, 24 Aug 1998 16:24:16 -0400 Subject: [Image-SIG] PIL and 16 bit Images Message-ID: <35E1CBF0.DD85AA67@brown.edu> Does PIL handle 16 bit images? I have some 16 bit greyscale raw data images that I am trying to display using PIL. The only way I can get it to look "right" is if I scale all the data to 8 bit before creating the image using "fromstring". I would like to be able to view it in 16 bit, not 8. Any suggestions as to a better way to do this, or even a solution? Thanks, Brian Brian_Adams@brown.edu From R.Hooft@EuroMail.com Tue Aug 25 12:39:21 1998 From: R.Hooft@EuroMail.com (Rob Hooft) Date: Tue, 25 Aug 1998 13:39:21 +0200 (MZT) Subject: [Image-SIG] PIL and 16 bit Images In-Reply-To: <35E1CBF0.DD85AA67@brown.edu> References: <35E1CBF0.DD85AA67@brown.edu> Message-ID: <13794.41577.611314.76436@schol.chem.uu.nl> >>>>> "BA" == Brian Adams writes: BA> Does PIL handle 16 bit images? I have some 16 bit greyscale raw BA> data images that I am trying to display using PIL. The only way I BA> can get it to look "right" is if I scale all the data to 8 bit BA> before creating the image using "fromstring". I would like to be BA> able to view it in 16 bit, not 8. I have the same kind of data (from 16 bit CCD's). A real problem is that displays do not have 16 bit grey-scales: I think the best you can get is 8 bit (maybe 12 somewhere). Even if the display can show more than 8 bit, you eyes can't see the difference. What I did is create a few classes that clip (upper and lower limits) and scale (currently I have logarithmic and linear, but histogram equality is another nice possibility) the 16 bit data into 8 bit images using 'Numeric'. This gives me the flexibility to look at any set of "consecutive bits" out of the 16. Regards, -- ===== R.Hooft@EuroMail.com http://www.Sander.EMBL-Heidelberg.DE/rob/ == ===== R&D, Nonius BV, Delft http://www.nonius.com/ == ===== PGPid 0xFA19277D ========================== Use Linux! ================== From edcjones@erols.com Wed Aug 26 04:32:47 1998 From: edcjones@erols.com (Edward C. Jones) Date: Tue, 25 Aug 1998 23:32:47 -0400 Subject: [Image-SIG] What are plans for PIL / NumPy / Engelmann? Message-ID: <35E381DF.1D0747FB@erols.com> What are the development plans for PIL and its relationship to SWIG, NumPy, and the work by Engelmann? Suppose I write in C some image processing routine which works with one of the standard 2-dim C arrays. Is there a Standard Operating Procedure (SOP) for integrating my routine with PIL and/or NumPy? Are the irritating inconsistencies in PIL, at both the user and code levels, going to be FIXUPed? From fredrik@pythonware.com Wed Aug 26 10:30:09 1998 From: fredrik@pythonware.com (Fredrik Lundh) Date: Wed, 26 Aug 1998 10:30:09 +0100 Subject: [Image-SIG] What are plans for PIL / NumPy / Engelmann? Message-ID: <03de01bdd0d4$889badb0$f29b12c2@pythonware.com> >Are the irritating inconsistencies in PIL, at both the user and >code levels, going to be FIXUPed? What are the irritating inconsistencies in PIL (both at the user and code levels) ? /F From piet@cs.uu.nl Wed Aug 26 11:59:09 1998 From: piet@cs.uu.nl (Piet van Oostrum) Date: 26 Aug 1998 12:59:09 +0200 Subject: [Image-SIG] Problems installing PIL Message-ID: I am trying to install the Python Imaging Library version 0.3b2 on Solaris (SunOS 5.6) and get the following compilation error: gcc -O -I./. -I/sw/include -DHAVE_CONFIG_H -c JpegDecode.c JpegDecode.c:111: conflicting types for `ImagingJpegDecode' Imaging.h:299: previous declaration of `ImagingJpegDecode' JpegDecode.c: In function `ImagingJpegDecode': JpegDecode.c:136: warning: assignment from incompatible pointer type JpegDecode.c:143: invalid operands to binary - JpegDecode.c:216: warning: passing arg 1 from incompatible pointer type JpegDecode.c:237: invalid operands to binary - *** Error code 1 make: Fatal error: Command failed for target `JpegDecode.o' /sw/include contains the include files for zlib jpeg etc. The strange thing is that the two declarations mentioned are the same: JpegDecode.c:111: int ImagingJpegDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) { Imaging.h:299: extern int ImagingJpegDecode(Imaging im, ImagingCodecState state, UINT8* buffer, int bytes); Unless something is redeclared in the meantime. Does anybody have a clue? The warnings can probably be ignored. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: Piet.van.Oostrum@gironet.nl From fredrik@pythonware.com Wed Aug 26 16:01:42 1998 From: fredrik@pythonware.com (Fredrik Lundh) Date: Wed, 26 Aug 1998 16:01:42 +0100 Subject: [Image-SIG] Problems installing PIL Message-ID: <002b01bdd102$74c8d320$f29b12c2@pythonware.com> >JpegDecode.c:111: >int >ImagingJpegDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) >{ >Imaging.h:299: >extern int ImagingJpegDecode(Imaging im, ImagingCodecState state, > UINT8* buffer, int bytes); > >Unless something is redeclared in the meantime. What JPEG lib do you use? Could it be a conflict between a UINT8 typedef and a UINT8 define (PIL uses the latter)? >Does anybody have a clue? Not really... I've built 0.3b2 on a number of platforms, but haven't seen anything like this. Cheers /F fredrik@pythonware.com http://www.pythonware.com From piet@cs.uu.nl Wed Aug 26 16:31:32 1998 From: piet@cs.uu.nl (Piet van Oostrum) Date: Wed, 26 Aug 1998 17:31:32 +0200 (MDT) Subject: [Image-SIG] Problems installing PIL In-Reply-To: <002b01bdd102$74c8d320$f29b12c2@pythonware.com> References: <002b01bdd102$74c8d320$f29b12c2@pythonware.com> Message-ID: <13796.10836.620565.887756@kemmel.cs.uu.nl> >>>>> "Fredrik Lundh" (FL) writes: FL> What JPEG lib do you use? Could it be a conflict between a UINT8 FL> typedef and a UINT8 define (PIL uses the latter)? jpeg-6.a as distributed with gimp. And yes, further experimentation shows that UINT8 is the culprit. It is defined in the various jpeg .h files as unsigned char/char or unsigned int (in an emergency case). It is such a twisted maze of #ifdef CHAR_UNSIGNED/CHAR_IS_UNSIGNED/HAS_UNSIGNED_CHAR and maybe more that I can't resolve which definition is actually used. I have now added this line to ImPlatform.h #define HAVE_UNSIGNED_CHAR and it solves the problem, but I have a slight feeling that there should be a better solution. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: Piet.van.Oostrum@gironet.nl From edcjones@erols.com Fri Aug 28 04:05:25 1998 From: edcjones@erols.com (Edward C. Jones) Date: Thu, 27 Aug 1998 23:05:25 -0400 Subject: [Image-SIG] Re: What are plans for PIL, ... Message-ID: <35E61E75.775DFD4C@erols.com> I have a need to manage and analyse a collection of images. I use Python as a top level language because it is easy to read and write. I use C as a low level language because I know it and it is fast. I would like to use PIL primarily to hide from me the nasty details of image formats. As an example of what I need, suppose I have created a Python module that does median filters. Suppose the module name is "MedianFilter". I write the module in C using one of the standard ways of representing two dimensional arrays in C. (I tend to prefer a pointer to an array of pointers to rows.) The module is to be integrated using SWIG. I would like the python program to look something like: import Image, MedianFilter im = Image.open('pic.jpg', 'r') im2 = MedianFilter.medianfilter(im, (11, 11) ) or perhaps even: import Image, MedianFilter im = Image.open('pic.jpg', 'r') ptrim = im.pointertoimage() im2 = MedianFilter.medianfilter(ptrim, (11, 11) ) What do I put in my module to allow this to happen? How do I use SWIG in this case? 1. Which parts of PIL support 32 bit images? When should the C programmer use "image", "image8", "image32", "UINT8", "UINT32", "FLOAT32", etc.? See Fill.c, Blend.c, GetBBox.c, and ImagingGetExtrema. 2. In "Image.py" is the comment "fix to handle multiband images since _imaging doesn't". When is this fix needed? 3. Documentation. a. Some functions are listed in the user documentation without any explanation. Examples include "putdata" and "tostring". b. Some functions are undocumented including "and", "or', "xor", and "GetExtrema". c. Each function in the code needs a few lines of overview documentation explaining what the code does and how it is used. For example, what does "ImagingNewPrologue" do? d. An overview of how variables are named should be given. It took me a while to figure out "getbbox", "GetBBox", "ImagingGetBBox", etc. e. An overview of the design of PIL is needed. So far, I have added things to PIL by stumbling across somethng that works and imitating it blindly. Include a description of how errors are handled. f. Certain operations currently cannot be done on certain images. As a beginner I assumed that any problem was my fault. When an operation is impossible or unimplemented, it should be clearly stated. 4. What is "delayed operation" or "delayed evaluation", how is it implemented, and when should the C programmer use it? 5. What is the format of the string returned by "tostring"? 6. The error messages need to be more precise and detailed. If I give "Image.merge" images of different sizes I get "wrong number of bands". If images mismatch, the nature of the mismatch should be in the error message. It took me a while to internalize the idea that while all images are opened with Image.open, they are not all alike, and not every operation is possible. 7. Input images are often not perfect. PIL needs capabilities for fixing broken images. Currently I use the following poor piece of code: # Two ugly kludges. if string.lower(ext) == '.jpg': # jpegtran works on truncated images. # For consistency, use it on all jpg's. string1 = 'jpegtran -copy none ' string2 = ' > tmp.jpg' os.system(string1 + file + string2) im = Image.open('tmp.jpg') os.unlink('tmp.jpg') elif string.lower(ext) == '.gif': try: # Any truncation error shows up only when the opened # file is used. Filters don't work on mode 'P'. # Need to convert to 'RGB'. im = Image.open(file).convert('RGB') except IOError, x: if string.find(str(x), 'truncated') != -1: print 'Truncated gif' line = 'giffix -q ' + file + ' > tmp.gif' os.system(line) im = Image.open('tmp.gif').convert('RGB') os.unlink('tmp.gif') else: print file, 'IOError:', x continue else: # An unusual format or a non-image file. try: im = Image.open(file).convert('RGB') except IOError: print 'Unusual format or non-image file.' continue From jhaile@ida.net Fri Aug 28 05:22:20 1998 From: jhaile@ida.net (Jed Haile) Date: Fri, 28 Aug 1998 00:22:20 -0400 Subject: [Image-SIG] invalid command name "PyImagingPhoto" Message-ID: <35E6307C.544F06B4@ida.net> I just installed Imaging-0.3b2 on RH5.1 with python1.5.1. I didn't notice any real errors during compiling. When I try to run the script viewer.py in the Scripts directory I get: Traceback (innermost last): File "viewer.py", line 44, in ? UI(root, im).pack() File "viewer.py", line 23, in __init__ self.image = ImageTk.PhotoImage(im) File "/usr/local/lib/python1.5/ImageTk.py", line 83, in __init__ self.paste(image) File "/usr/local/lib/python1.5/ImageTk.py", line 113, in paste self.__photo.tk.call("PyImagingPhoto", self.__photo, block.id) TclError: invalid command name "PyImagingPhoto" I get similiar errors from the other scripts. I did the tk install stuff. thanks, Jed Haile From fredrik@pythonware.com Fri Aug 28 09:15:29 1998 From: fredrik@pythonware.com (Fredrik Lundh) Date: Fri, 28 Aug 1998 09:15:29 +0100 Subject: [Image-SIG] invalid command name "PyImagingPhoto" Message-ID: <009201bdd25c$a4200cf0$f29b12c2@pythonware.com> >TclError: invalid command name "PyImagingPhoto" > >I get similiar errors from the other scripts. I did the tk install >stuff. Better doublecheck your installation. This error means that the _tkinter.so you're using doesn't include the PIL extension... (and yes, the need for a special _tkinter.so will be eliminated in a future release, but it's still there in 0.3b2...) /F