From pkeeley@insci.com Tue Nov 5 19:31:26 2002 From: pkeeley@insci.com (Paul Keeley) Date: Tue, 5 Nov 2002 14:31:26 -0500 Subject: [Image-SIG] IOError: image file is truncated, 312 bytes left in buffer Message-ID: <7CA4212880CED611BA2200A0C9AB18C704A23D@mercury.insci.com> I am trying to convert a BMP file to TIF as follows: img = Image.open(filename.bmp) img.save(filename.tif) every time it displays the error IOError: image file is truncated, 312 bytes left in buffer If I insert a img.show() between the two lines then sometimes it works and sometimes it does not. Any ideas? Thanks, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Paul Keeley IDS Developer, INSCI Tel: 508-870-4324 Two Westborough Business Park Fax: 508-870-5585 Suite 2000/2001 Westborough MA 01581 mailto: pkeeley@insci.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From robmyroon@yahoo.com Wed Nov 6 16:54:36 2002 From: robmyroon@yahoo.com (Rob Myroon) Date: Wed, 6 Nov 2002 08:54:36 -0800 (PST) Subject: [Image-SIG] Re: how to make transparent background? Message-ID: <20021106165436.15040.qmail@web11405.mail.yahoo.com> Hi Victor, I have a similar problem. I would like to save a .png with a transparent background. I think we are out of luck (unless we modify some PIL code). I did some searching and found these links ... The second link describes how to modify GifImagePlugin.py. http://mail.python.org/pipermail/image-sig/2002-April/001797.html http://mail.python.org/pipermail/image-sig/1999-December/000949.html Rob __________________________________________________ Do you Yahoo!? HotJobs - Search new jobs daily now http://hotjobs.yahoo.com/ From FBorell0264@aol.com Wed Nov 6 01:09:53 2002 From: FBorell0264@aol.com (FBorell0264@aol.com) Date: Tue, 5 Nov 2002 20:09:53 EST Subject: [Image-SIG] IPTC Message-ID: <4b.2605f751.2af9c5e1@aol.com> --part1_4b.2605f751.2af9c5e1_boundary Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Can the freeware or commercial product read / write IPTC header info ? If yes/no, point me in a direction. Thanks in advance, Frank Borell --part1_4b.2605f751.2af9c5e1_boundary Content-Type: text/html; charset="US-ASCII" Content-Transfer-Encoding: 7bit Can the freeware or commercial product read / write IPTC header info ?
If yes/no, point me in a direction.


Thanks in advance,

Frank Borell
--part1_4b.2605f751.2af9c5e1_boundary-- From robmyroon@yahoo.com Wed Nov 6 23:40:26 2002 From: robmyroon@yahoo.com (Rob Myroon) Date: Wed, 6 Nov 2002 15:40:26 -0800 (PST) Subject: [Image-SIG] Re: how to make a transparent background Message-ID: <20021106234026.77447.qmail@web11403.mail.yahoo.com> Hi Victor, I think I solved my problem. Remember ... I want to save .png files with a transparent color. I have modified the PngImagePlugin.py file. There already is code to set a transparent color but it doesn't seem to get executed. My change executes that code. To set a transparent color simply add a "transparency" entry to the image's info dictionary. (Don't do this if you load a transparent gif or a transparent png --- PIL creates a "transparency" entry in the info dictionary.) The image file must be "P" (palette). ("L" might work too but I haven't tried it.) ex. im = Image.open(file.xxx) # ex. 8-bit .bmp im.info["transparency"] = color number in the palette im.save("newfile.png") Here is a section of code and my additions from PngImagePlugin.py def _save(im, fp, filename, chunk=putchunk, check=0): # save an image to disk (called by the save method) . . . chunk(fp, "IHDR", o32(im.size[0]), o32(im.size[1]), # 0: size mode, # 8: depth/type chr(0), # 10: compression chr(0), # 11: filter category chr(0)) # 12: interlace flag if im.mode == "P": chunk(fp, "PLTE", im.im.getpalette("RGB")) # Added by R. Myroon 2002.11.06 if not im.encoderinfo.has_key("transparency"): if im.info.has_key("transparency"): im.encoderinfo["transparency"] = im.info["transparency"] # End code 2002.11.06 if im.encoderinfo.has_key("transparency"): if im.mode == "P": transparency = max(0, min(255, im.encoderinfo["transparency"])) chunk(fp, "tRNS", chr(255) * transparency + chr(0)) elif im.mode == "L": transparency = max(0, min(65535, im.encoderinfo["transparency"])) chunk(fp, "tRNS", o16(transparency)) else: raise IOError, "cannot use transparency for this mode" __________________________________________________ Do you Yahoo!? HotJobs - Search new jobs daily now http://hotjobs.yahoo.com/ From thomi@thomi.imail.net.nz Sun Nov 10 23:12:18 2002 From: thomi@thomi.imail.net.nz (Thomi Richards) Date: Mon, 11 Nov 2002 12:12:18 +1300 Subject: [Image-SIG] PIL palettes question.. Message-ID: <20021111121218.7e1bbb7a.thomi@thomi.imail.net.nz> Hey there.. I'm new to this list, but i hope yo can help me with a small problem i am having: I have a picture, which is a 256 color bitmap, I have opened it with PIL, and it shows up as being type "P". So, i can do things like: >>>print im.palette.data and i get a whole screen of wierd things... what i want to do, is to apply that palette to another bitmap picture i have, which is a normal, true color bitmap. obviously, some of the colors will have to go, but I'm hoping that there is some sort of error correction?? Thanks for reading :-) -- DOS: n., A small annoying boot virus that causes random spontaneous system crashes, usually just before saving a massive project. Easily cured by UNIX. See also MS-DOS, IBM-DOS, DR-DOS. (from David Vicker's .plan) Thomi Richards, thomi@imail.net.nz From robmyroon@yahoo.com Tue Nov 12 20:38:26 2002 From: robmyroon@yahoo.com (Rob Myroon) Date: Tue, 12 Nov 2002 12:38:26 -0800 (PST) Subject: [Image-SIG] BMP Palettes Message-ID: <20021112203826.73688.qmail@web11407.mail.yahoo.com> Hi Thomi, I am not an expert at this but I don't think PIL can convert an 8 bit bmp to a 24 bit bmp. (Never mind the part about giving one bmp another bmp's palette.) Also, the 8-bit bmp has a palette of colors. The 24 bit bmp does not have a palette. The 24 bit bmp stores the color of each pixel. If you use Windows ... I know of a program called nconvert.exe that will convert 24 bit bmps to 8 bit bmps and keep all of the colors intact. If you try this in mspaint it won't keep the proper colors. I can send you my copy of nconvert.exe if you want. Or you could write Python code to create an 8 bit bmp yourself. The bmp format is not complicated. Check out the source of BmpImagePlugin.py. Rob Myroon __________________________________________________ Do you Yahoo!? U2 on LAUNCH - Exclusive greatest hits videos http://launch.yahoo.com/u2 From robmyroon@yahoo.com Tue Nov 12 21:03:00 2002 From: robmyroon@yahoo.com (Rob Myroon) Date: Tue, 12 Nov 2002 13:03:00 -0800 (PST) Subject: [Image-SIG] BMP Palettes In-Reply-To: <20021112203826.73688.qmail@web11407.mail.yahoo.com> Message-ID: <20021112210300.90020.qmail@web11405.mail.yahoo.com> --- Rob Myroon wrote: > Hi Thomi, > > I am not an expert at this but I don't think PIL can > convert an 8 bit bmp to a 24 bit bmp. (Never mind > the > part about giving one bmp another bmp's palette.) > Ooops! I said I wasn't an expert! :) I believe you can use the convert() method to convert a 24 bit bmp to an 8 bit bmp. im = Image.open("x.bmp") # open 24 bit bmp im2 = im.convert("P") # convert to P mode (8 bit) im2.save("newbmp.bmp") # save new 8 bit bmp # new image im2 is 8 bit But this doesn't solve your problem about using another bmp's palette. Rob __________________________________________________ Do you Yahoo!? U2 on LAUNCH - Exclusive greatest hits videos http://launch.yahoo.com/u2 From thomi@thomi.imail.net.nz Tue Nov 12 23:18:58 2002 From: thomi@thomi.imail.net.nz (Thomi Richards) Date: Wed, 13 Nov 2002 12:18:58 +1300 Subject: [Image-SIG] BMP Palettes In-Reply-To: <20021112210300.90020.qmail@web11405.mail.yahoo.com> References: <20021112203826.73688.qmail@web11407.mail.yahoo.com> <20021112210300.90020.qmail@web11405.mail.yahoo.com> Message-ID: <20021113121858.64a59496.thomi@thomi.imail.net.nz> > I believe you can use the convert() method to convert > a 24 bit bmp to an 8 bit bmp. > > im = Image.open("x.bmp") # open 24 bit bmp > im2 = im.convert("P") # convert to P mode (8 bit) > im2.save("newbmp.bmp") # save new 8 bit bmp > > # new image im2 is 8 bit > > But this doesn't solve your problem about using > another bmp's palette. you can actually do this: inimage = Image.open('palette.bmp') outimage = Image.open('convert.bmp') outim = outimage.convert('P') outim.palette = inimage.palette outim.save('converted.bmp') the only problam with this is that it doesn't do it very well. I decided to read every pixel in the file to convert, and used my own algorithm to convert the colors. I'll let you know how i get on :-) -- Lord, what fools these mortals be! -- midsummer nights dream. Thomi Richards, thomi@imail.net.nz From torresj@apb.es Mon Nov 18 15:48:35 2002 From: torresj@apb.es (Joan Torres) Date: Mon, 18 Nov 2002 16:48:35 +0100 (MET) Subject: [Image-SIG] MemoryError. Please help !! Message-ID: <200211181548.QAA22900@osona.apb.es> image-sig@python.org Hi, I'm using PIL-1.1.3 with Python2.1 on a UNIX Solaris 2.6 Can anyone explain me the following error ? What can I do? >>> from PIL import Image >>> Image.core.new('RGB',(3000,5000)) Traceback (most recent call last): File "", line 1, in ? MemoryError >>> Thanks J. Torres Port Authority of Barcelona From fredrik@pythonware.com Mon Nov 18 16:55:23 2002 From: fredrik@pythonware.com (Fredrik Lundh) Date: Mon, 18 Nov 2002 17:55:23 +0100 Subject: [Image-SIG] MemoryError. Please help !! References: <200211181548.QAA22900@osona.apb.es> Message-ID: <04b901c28f23$59815270$ced241d5@hagrid> Joan Torres wrote: > I'm using PIL-1.1.3 with Python2.1 on a UNIX Solaris 2.6 > Can anyone explain me the following error ? > What can I do? > >>> from PIL import Image > >>> Image.core.new('RGB',(3000,5000)) > Traceback (most recent call last): > File "", line 1, in ? > MemoryError > >>> the error message means that your platform won't let you allocate the ~60 megs needed to hold this image (PIL allocates four bytes per pixel for RGB images). From fredrik@pythonware.com Mon Nov 18 18:08:24 2002 From: fredrik@pythonware.com (Fredrik Lundh) Date: Mon, 18 Nov 2002 19:08:24 +0100 Subject: [Image-SIG] ANN: PIL 1.1.4 alpha 1 Message-ID: <05b701c28f2e$c9b67240$ced241d5@hagrid> just fyi, I just uploaded a sneak release of PIL 1.1.4 alpha 1 to effbot.org: http://effbot.org/downloads For source code, get the the Imaging-1.1.4a1.tar.gz tarball. There's also a Windows executable for Python 2.1. a (somewhat incomplete) list of changes can be found here: http://effbot.org/zone/pil-changes-114.htm The final release will be released by Secret Labs AB, as usual. We expect to release the final 1.1.4 version before the end of the year. Report bugs to this list or directly to me, as usual. enjoy /F From gregc@cgl.ucsf.EDU Tue Nov 19 01:21:05 2002 From: gregc@cgl.ucsf.EDU (Greg Couch) Date: Mon, 18 Nov 2002 17:21:05 -0800 (PST) Subject: [Image-SIG] patch: TiffImagePlugin.py Message-ID: <200211190121.gAJ1L5Dg808396@adenine.cgl.ucsf.edu> Adobe Illustrator will not open a tiff file that is missing the compression tag. If tiff compression support is added (say when the lzw patent expires), then this will have to be modified. The fix is enclosed below. Greg Couch UCSF Computer Graphics Lab *** TiffImagePlugin.py 2002/11/18 22:35:22 1.1 --- TiffImagePlugin.py 2002/11/19 00:50:03 *************** *** 656,661 **** --- 656,662 ---- ifd[ROWSPERSTRIP] = im.size[1] ifd[STRIPBYTECOUNTS] = stride * im.size[1] ifd[STRIPOFFSETS] = 0 # this is adjusted by IFD writer + ifd[COMPRESSION] = 1 # COMPRESSION_INFO[?] = "raw" (same as _save below) offset = ifd.save(fp) From schutte@fel.tno.nl Tue Nov 19 10:04:00 2002 From: schutte@fel.tno.nl (K Schutte) Date: Tue, 19 Nov 2002 11:04:00 +0100 Subject: [Image-SIG] ANN: PIL 1.1.4 alpha 1 References: <05b701c28f2e$c9b67240$ced241d5@hagrid> Message-ID: <3DDA0C90.E3634B2C@fel.tno.nl> This is a multi-part message in MIME format. --------------2C63C82A07ECD0BD94B0E735 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Please find attached updated diffs I sent around earlier for version 1.1.3, which enable reading 16 bit unsigned TIFFs. It fixes bugs in the TIFF reader and adds (some) functionality to handle 16 bit unsigned images. Why wasn't this added to the 1.1.4 version? Klamer PS: The 1.1.4 version compiled and seem to work for me (RedHat 7.2, python2.1) Old description of what has been changed: What is changed in the sources: - ability to read 16 bit unsigned TIFF files using Image.open - ability to use Image.show (by adding convert to 'L' mode (uint8)) - ability to use Image.getextrema and Image.point Image.show, Image.getextrema and Image.point all work similar to the 32 int cases; so something like: import Image im16 = Image.open('img.tif') min,max = im16.getextrema() scale = 255.0 / (max - min) offset = - min * scale im16c = im16.point(lambda i: i * scale + offset) im16c.show() will show a strechted image (sorry, typed from memory). Other PIL functions are not (yet ?) converted for 16 int use. Note that im16.convert('I') will give a 32 bit int image, which is better supported in PIL; or use im16c.convert('L') and have an 8 bit image. Fredrik Lundh wrote: > > just fyi, > > I just uploaded a sneak release of PIL 1.1.4 alpha 1 to > effbot.org: > > http://effbot.org/downloads > > For source code, get the the Imaging-1.1.4a1.tar.gz tarball. > There's also a Windows executable for Python 2.1. > > a (somewhat incomplete) list of changes can be found here: > > http://effbot.org/zone/pil-changes-114.htm > > The final release will be released by Secret Labs AB, as usual. > We expect to release the final 1.1.4 version before the end of > the year. > > Report bugs to this list or directly to me, as usual. > > enjoy /F > > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig -- Klamer Schutte, E-mail: Schutte@fel.tno.nl Electro-Optical Systems, TNO Physics and Electronics Laboratory Tel: +31-70-3740469 -- Fax: +31-70-3740654 -- Mobile: +31-6-51316671 --------------2C63C82A07ECD0BD94B0E735 Content-Type: text/plain; charset=us-ascii; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" diff -ur Imaging-1.1.4a1/PIL/Image.py Imaging-1.1.4a1-KS/PIL/Image.py --- Imaging-1.1.4a1/PIL/Image.py Mon Nov 18 14:05:55 2002 +++ Imaging-1.1.4a1-KS/PIL/Image.py Tue Nov 19 09:33:29 2002 @@ -160,6 +160,7 @@ # official modes "1": ("L", "L", ("1",)), "L": ("L", "L", ("L",)), + "I;16" : ("L", "I;16", ("I;16",)), "I": ("L", "I", ("I",)), "F": ("L", "F", ("F",)), "P": ("RGB", "L", ("P",)), @@ -878,7 +879,7 @@ def point(self, lut, mode=None): "Map image through lookup table" - if self.mode in ("I", "F"): + if self.mode in ("I", "I;16", "F"): # floating point; lut must be a valid expression scale, offset = _getscaleoffset(lut) self.load() diff -ur Imaging-1.1.4a1/PIL/TiffImagePlugin.py Imaging-1.1.4a1-KS/PIL/TiffImagePlugin.py --- Imaging-1.1.4a1/PIL/TiffImagePlugin.py Sun Mar 10 17:57:39 2002 +++ Imaging-1.1.4a1-KS/PIL/TiffImagePlugin.py Tue Nov 19 09:33:29 2002 @@ -1,6 +1,6 @@ # # The Python Imaging Library. -# $Id: //modules/pil/PIL/TiffImagePlugin.py#5 $ +# $Id: TiffImagePlugin.py,v 1.1 2002/08/21 20:11:01 klamer Exp $ # # TIFF file handling # @@ -106,7 +106,8 @@ (0, 1, (8,), ()): ("L", "L;I"), (1, 1, (1,), ()): ("1", "1"), (1, 1, (8,), ()): ("L", "L"), - (1, 2, (16,), ()): ("I;16", "I;16"), + (1, 1, (16,), ()): ("I;16", "I;16"), + (1, 2, (16,), ()): ("I;16S", "I;16S"), (1, 2, (32,), ()): ("I", "I;32S"), (1, 3, (32,), ()): ("F", "F;32F"), (2, 1, (8,8,8), ()): ("RGB", "RGB"), @@ -331,6 +332,7 @@ elif tag in (X_RESOLUTION, Y_RESOLUTION): # identify rational data fields typ = 5 + continue else: typ = 3 for v in value: @@ -568,7 +570,8 @@ "L": ("L", 1, 1, (8,), None), "P": ("P", 3, 1, (8,), None), "I": ("I;32S", 1, 2, (32,), None), - "I;16": ("I;16", 1, 2, (16,), None), + "I;16": ("I;16", 1, 1, (16,), None), + "I;16S": ("I;16S", 1, 2, (16,), None), "F": ("F;32F", 1, 3, (32,), None), "RGB": ("RGB", 2, 1, (8,8,8), None), "RGBX": ("RGBX", 2, 1, (8,8,8,8), 0), diff -ur Imaging-1.1.4a1/_imaging.c Imaging-1.1.4a1-KS/_imaging.c --- Imaging-1.1.4a1/_imaging.c Mon Nov 18 13:49:47 2002 +++ Imaging-1.1.4a1-KS/_imaging.c Tue Nov 19 09:33:29 2002 @@ -1473,6 +1473,7 @@ union { UINT8 u[2]; INT32 i[2]; + UINT16 i16[2]; FLOAT32 f[2]; } extrema; int status; @@ -1489,6 +1490,9 @@ return Py_BuildValue("ii", extrema.i[0], extrema.i[1]); case IMAGING_TYPE_FLOAT32: return Py_BuildValue("dd", extrema.f[0], extrema.f[1]); + case 3: + if (strcmp(self->image->mode, "I;16") == 0) + return Py_BuildValue("ii", extrema.i16[0], extrema.i16[1]); } Py_INCREF(Py_None); diff -ur Imaging-1.1.4a1/libImaging/Convert.c Imaging-1.1.4a1-KS/libImaging/Convert.c --- Imaging-1.1.4a1/libImaging/Convert.c Sun Mar 10 17:57:40 2002 +++ Imaging-1.1.4a1-KS/libImaging/Convert.c Tue Nov 19 09:33:29 2002 @@ -1,6 +1,6 @@ /* * The Python Imaging Library - * $Id: //modules/pil/libImaging/Convert.c#3 $ + * $Id: Convert.c,v 1.1 2002/08/21 20:13:39 klamer Exp $ * * convert images * @@ -408,6 +408,16 @@ } static void +l2i16(UINT8* out, const UINT8* in, int xsize) +{ + int x; + for (x = 0; x < xsize; x++, in++) { + *out++ = *in; + *out++ = 0; + } +} + +static void i2i16b(UINT8* out, const UINT8* in_, int xsize) { int x, v; @@ -429,6 +439,17 @@ } static void +i162l(UINT8* out, const UINT8* in, int xsize) +{ + int x; + for (x = 0; x < xsize; x++, in += 2) + if (in[1] != 0) + *out++ = 255; + else + *out++ = in[0]; +} + +static void i16b2i(UINT8* out_, const UINT8* in, int xsize) { int x; @@ -510,6 +531,9 @@ { "I", "I;16B", i2i16b }, { "I;16B", "I", i16b2i }, + { "L", "I;16", l2i16 }, + { "I;16", "L", i162l }, + { NULL } }; @@ -905,7 +929,15 @@ } if (!convert) +#ifdef notdef return (Imaging) ImagingError_ValueError("conversion not supported"); +#else + { + static char buf[256]; + sprintf(buf, "conversion from %s to %s not supported", imIn->mode, mode); + return (Imaging) ImagingError_ValueError(buf); + } +#endif imOut = ImagingNew2(mode, imOut, imIn); if (!imOut) diff -ur Imaging-1.1.4a1/libImaging/GetBBox.c Imaging-1.1.4a1-KS/libImaging/GetBBox.c --- Imaging-1.1.4a1/libImaging/GetBBox.c Sun Mar 10 17:57:40 2002 +++ Imaging-1.1.4a1-KS/libImaging/GetBBox.c Tue Nov 19 09:33:29 2002 @@ -1,6 +1,6 @@ /* * The Python Imaging Library - * $Id: //modules/pil/libImaging/GetBBox.c#2 $ + * $Id: GetBBox.c,v 1.1 2002/08/21 20:14:29 klamer Exp $ * * get bounding box for image * @@ -163,6 +163,24 @@ ((FLOAT32*) extrema)[0] = fmin; ((FLOAT32*) extrema)[1] = fmax; break; + case IMAGING_TYPE_SPECIAL: + if (strcmp(im->mode,"I;16") == 0) + { + imin = imax = ((UINT16*)im->image8[0])[0]; + for (y = 0; y < im->ysize; y++) { + UINT16* in = (UINT16 *)im->image[y]; + for (x = 0; x < im->xsize; x++) { + if (imin > in[x]) + imin = in[x]; + else if (imax < in[x]) + imax = in[x]; + } + } + ((UINT16*) extrema)[0] = (UINT16) imin; + ((UINT16*) extrema)[1] = (UINT16) imax; + break; + } + /* FALL THROUGH */ default: ImagingError_ModeError(); return -1; diff -ur Imaging-1.1.4a1/libImaging/Point.c Imaging-1.1.4a1-KS/libImaging/Point.c --- Imaging-1.1.4a1/libImaging/Point.c Sun Mar 10 17:57:40 2002 +++ Imaging-1.1.4a1-KS/libImaging/Point.c Tue Nov 19 09:33:29 2002 @@ -1,6 +1,6 @@ /* * The Python Imaging Library - * $Id: //modules/pil/libImaging/Point.c#2 $ + * $Id: Point.c,v 1.1 2002/08/21 20:15:22 klamer Exp $ * * point (pixel) translation * @@ -113,7 +113,9 @@ Imaging imOut; int x, y; - if (!imIn || strcmp(imIn->mode, "I") != 0 && strcmp(imIn->mode, "F") != 0) + if (!imIn || (strcmp(imIn->mode, "I") != 0) && + (strcmp(imIn->mode, "I;16") != 0) && + (strcmp(imIn->mode, "F") != 0)) return (Imaging) ImagingError_ModeError(); imOut = ImagingNew(imIn->mode, imIn->xsize, imIn->ysize); @@ -140,6 +142,19 @@ out[x] = in[x] * scale + offset; } break; + case IMAGING_TYPE_SPECIAL: + if (strcmp(imIn->mode,"I;16") == 0) + { + for (y = 0; y < imIn->ysize; y++) { + UINT16* in = (UINT16 *)imIn->image[y]; + UINT16* out = (UINT16 *)imOut->image[y]; + /* FIXME: add clipping? */ + for (x = 0; x < imIn->xsize; x++) + out[x] = in[x] * scale + offset; + } + break; + } + /* FALL THROUGH */ default: ImagingDelete(imOut); return (Imaging) ImagingError_ValueError("internal error"); --------------2C63C82A07ECD0BD94B0E735-- From jlawhead@nvisionsolutions.com Tue Nov 19 19:08:01 2002 From: jlawhead@nvisionsolutions.com (Joel Lawhead) Date: Tue, 19 Nov 2002 13:08:01 -0600 Subject: [Image-SIG] PIL and GeoTiffs (QuickBird) Message-ID: <002901c28ffe$fc987430$c3633ed0@NV5> Hi, I use PIL to work with satellite images often. But I recently tried to open a DigitalGlobe Quickbird image (www.digitalglobe.com) and got the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\Python22\PIL\Image.py", line 1504, in open raise IOError("cannot identify image file") IOError: cannot identify image file Supposedly Digital Globe distributes their images as GeoTiffs and ERDAS Imagine confirms this when I open the image I'm trying to open with Python. So the file isn't corrupt. I've also had the same result with other quickbird images I've tried since. I also tried forcing Python to use TiffImagePlugin with the following: >>> import Image >>> import TiffImagePlugin >>> Image._initialized = 1 I still get the same error. I've started looking through TiffImagePlugin.py to see if I can troubleshoot but before I get to deep into this I wanted to see if anybody knows if this is a simple issue of the tags being different between standard and Geo tiff format or if there's a bigger problem. If I or someone who is deeper into this package than I can hack a simple filter to get at the geotiff image data through PIL that would be great. I don't care about the tags in the geotiff. All I want is the capability to resample the image to a small jpeg thumbnail. Of course there are workarounds to get the job done. I have ERDAS, ENVI, and ArcGIS or I could use another library capable of dealing with this image but I'd really like to be able to do this in Python and PIL for many different reasons. Any input? Thanks, Joel Joel Lawhead, Web Application Developer NVision Solutions Inc, www.nvisionsolutions.com Phone: 228-688-2212, Fax: 228-688-3843 E-mail: jlawhead@nvisionsolutions.com From jlawhead@nvisionsolutions.com Tue Nov 19 23:03:09 2002 From: jlawhead@nvisionsolutions.com (Joel Lawhead) Date: Tue, 19 Nov 2002 17:03:09 -0600 Subject: [Image-SIG] More on QuickBird Tiffs Message-ID: <002d01c2901f$d81b02f0$c3633ed0@NV5> Here's the output from tiffinfo on the QuickBird GeoTiff I'm trying to work with in PIL. Does anyone see anything that would stump PIL? I've tried opening the image using PIL 1.1.2 through 1.1.4a1. I currently have 1.1.4a1 installed on a Windows 2000 Pro machine with Python 2.2. Everything seems to work fine but these GeoTiffs from Digital Globe. I think the planar configuration may not be typical. Does PIL support separate plane tiffs? TIFF Directory at offset 0x8000018 Image Width: 4096 Image Length: 4096 Bits/Sample: 16 Sample Format: unsigned integer Compression Scheme: None Photometric Interpretation: RGB color Extra Samples: 1 Date & Time: "2002:04:18 17:49:41" Copyright: "(C) COPYRIGHT 2002 EarthWatch Incorporated, Longmont CO USA 80501-6700" Image Description: "{\n bandList = \n [\n 1;\n 2;\n 3;\n 4;\n ]\n}" Orientation: row 0 top, col 0 lhs Samples/Pixel: 4 Rows/Strip: 128 Planar Configuration: separate image planes Thanks, Joel From bob@iplicity.com Tue Nov 19 23:40:49 2002 From: bob@iplicity.com (Bob Kimble) Date: Tue, 19 Nov 2002 18:40:49 -0500 Subject: [Image-SIG] PIL and GeoTiffs (QuickBird) In-Reply-To: <002901c28ffe$fc987430$c3633ed0@NV5> References: <002901c28ffe$fc987430$c3633ed0@NV5> Message-ID: <200211191840.49158.bob@iplicity.com> I've had problems dealing with some images in PIL as well. I've found tha= t=20 running an image through ImageMagick's convert program usually fixes what= ever=20 PIL doesn't like about the original. Regards, =2E... Bob From schutte@fel.tno.nl Wed Nov 20 07:52:34 2002 From: schutte@fel.tno.nl (K Schutte) Date: Wed, 20 Nov 2002 08:52:34 +0100 Subject: [Image-SIG] More on QuickBird Tiffs References: <002d01c2901f$d81b02f0$c3633ed0@NV5> Message-ID: <3DDB3F42.4A979ED2@fel.tno.nl> I see two problem areas: - the image file has 16 bit samples, and standard PIL doesn't like that - there are 4 samples per pixel; PIL (probably) only likes 1 (grayscale) or 3 (RGB) PIL based solution (probably requires coding): - make PIL handle 16 bit unsigned integer TIFFs (see my patches of yesterday) - make PIL read each color plane at a time, and combine later to RGB, or - make PIL ignore the fourth color plane (if current PIL can handle separate image planes.) Good luck, Klamer PS: trying to convert to 'standard' formats with 'standard' utilities will not work, as there are few 'standard' utilities which properly support 16 bit unsigned integers as pixel type... Joel Lawhead wrote: > > Here's the output from tiffinfo on the QuickBird GeoTiff I'm trying to > work with in PIL. Does anyone see anything that would stump PIL? I've > tried opening the image using PIL 1.1.2 through 1.1.4a1. I currently > have 1.1.4a1 installed on a Windows 2000 Pro machine with Python 2.2. > Everything seems to work fine but these GeoTiffs from Digital Globe. I > think the planar configuration may not be typical. Does PIL support > separate plane tiffs? > > TIFF Directory at offset 0x8000018 > Image Width: 4096 Image Length: 4096 > Bits/Sample: 16 > Sample Format: unsigned integer > Compression Scheme: None > Photometric Interpretation: RGB color > Extra Samples: 1 > Date & Time: "2002:04:18 17:49:41" > Copyright: "(C) COPYRIGHT 2002 EarthWatch Incorporated, Longmont CO > USA 80501-6700" > Image Description: "{\n bandList = \n [\n 1;\n 2;\n 3;\n > 4;\n ]\n}" > Orientation: row 0 top, col 0 lhs > Samples/Pixel: 4 > Rows/Strip: 128 > Planar Configuration: separate image planes > > Thanks, > Joel > > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig -- Klamer Schutte, E-mail: Schutte@fel.tno.nl Electro-Optical Systems, TNO Physics and Electronics Laboratory Tel: +31-70-3740469 -- Fax: +31-70-3740654 -- Mobile: +31-6-51316671 From bob@iplicity.com Wed Nov 20 08:23:25 2002 From: bob@iplicity.com (Bob Kimble) Date: Wed, 20 Nov 2002 03:23:25 -0500 Subject: [Image-SIG] More on QuickBird Tiffs In-Reply-To: <3DDB3F42.4A979ED2@fel.tno.nl> References: <002d01c2901f$d81b02f0$c3633ed0@NV5> <3DDB3F42.4A979ED2@fel.tno.nl> Message-ID: <200211200323.25492.bob@iplicity.com> On Wednesday 20 November 2002 02:52 am, K Schutte wrote: > I see two problem areas: > > - the image file has 16 bit samples, and standard PIL doesn't like that > - there are 4 samples per pixel; PIL (probably) only likes 1 (grayscale= ) or > 3 (RGB) > > PIL based solution (probably requires coding): > > - make PIL handle 16 bit unsigned integer TIFFs (see my patches of > yesterday) - make PIL read each color plane at a time, and combine late= r to > RGB, or - make PIL ignore the fourth color plane (if current PIL can ha= ndle > separate image planes.) > > Good luck, > > Klamer > > PS: trying to convert to 'standard' formats with 'standard' utilities w= ill > not work, as there are few 'standard' utilities which properly support = 16 > bit unsigned integers as pixel type... I tried downloading and opening a sample QuickBird GeoTiff image using=20 ImageMagick and the GIMP, and both failed. I guess that means that my ear= lier=20 idea will not work here. > Joel Lawhead wrote: > > Here's the output from tiffinfo on the QuickBird GeoTiff I'm trying t= o > > work with in PIL. Does anyone see anything that would stump PIL? I've > > tried opening the image using PIL 1.1.2 through 1.1.4a1. I currently > > have 1.1.4a1 installed on a Windows 2000 Pro machine with Python 2.2. > > Everything seems to work fine but these GeoTiffs from Digital Globe. = I > > think the planar configuration may not be typical. Does PIL support > > separate plane tiffs? > > > > TIFF Directory at offset 0x8000018 > > Image Width: 4096 Image Length: 4096 > > Bits/Sample: 16 > > Sample Format: unsigned integer > > Compression Scheme: None > > Photometric Interpretation: RGB color > > Extra Samples: 1 > > Date & Time: "2002:04:18 17:49:41" > > Copyright: "(C) COPYRIGHT 2002 EarthWatch Incorporated, Longmont CO > > USA 80501-6700" > > Image Description: "{\n bandList =3D \n [\n 1;\n 2;\n 3;= \n > > 4;\n ]\n}" > > Orientation: row 0 top, col 0 lhs > > Samples/Pixel: 4 > > Rows/Strip: 128 > > Planar Configuration: separate image planes > > > > Thanks, > > Joel > > > > _______________________________________________ > > Image-SIG maillist - Image-SIG@python.org > > http://mail.python.org/mailman/listinfo/image-sig From fredrik@pythonware.com Fri Nov 22 12:02:20 2002 From: fredrik@pythonware.com (Fredrik Lundh) Date: Fri, 22 Nov 2002 13:02:20 +0100 Subject: [Image-SIG] ANN: PIL 1.1.4 alpha 1 References: <05b701c28f2e$c9b67240$ced241d5@hagrid> <3DDA0C90.E3634B2C@fel.tno.nl> Message-ID: <024201c2921f$04d1e060$0900a8c0@spiff> klamer wrote: > Please find attached updated diffs I sent around earlier for version = 1.1.3, > which enable reading 16 bit unsigned TIFFs. It fixes bugs in the TIFF > reader and adds (some) functionality to handle 16 bit unsigned images. > Why wasn't this added to the 1.1.4 version? this will be in 1.1.4 alpha 2. (generally, the larger the patch, the more time it takes to merge it. = in this case, the patch caused extensive breakage to a related test suite, and = no- body had time to figure out if it was a problem with the patch or the = test suite. I've now fixed the test suite...) thanks /F From fredrik@pythonware.com Sat Nov 23 15:51:25 2002 From: fredrik@pythonware.com (Fredrik Lundh) Date: Sat, 23 Nov 2002 16:51:25 +0100 Subject: [Image-SIG] IOError: image file is truncated, 312 bytes left in buffer References: <7CA4212880CED611BA2200A0C9AB18C704A23D@mercury.insci.com> Message-ID: <00f301c29308$c3ce3dd0$ced241d5@hagrid> Paul Keeley wrote: > I am trying to convert a BMP file to TIF as follows: > > img = Image.open(filename.bmp) > img.save(filename.tif) > > every time it displays the error > IOError: image file is truncated, 312 bytes left in buffer > > If I insert a img.show() between the two lines then sometimes it works and > sometimes it does not. are you using the same file, or do you mean that it works for some files and not for others? when PIL succeeds, does the output image look right? (the "image file is truncated, 312 bytes left in buffer" error message means that there is 312 bytes left in the input buffer, but that's not enough to fill an entire row of pixels) From fredrik@pythonware.com Sun Nov 24 10:40:22 2002 From: fredrik@pythonware.com (Fredrik Lundh) Date: Sun, 24 Nov 2002 11:40:22 +0100 Subject: [Image-SIG] ANN: PIL 1.1.4 alpha 2 Message-ID: <007301c293a5$eb0a8fa0$ced241d5@hagrid> A PIL 1.1.4 alpha 2 tarball is now available from effbot.org: http://effbot.org/downloads (look for Imaging-1.1.4a2.tar.gz) A list of changes can be found here: http://effbot.org/zone/pil-changes-114.htm ...and a draft handbook can be found here: http://effbot.org/books/imagingbook/ The final release will be released by Secret Labs AB, as usual. We expect to release the final 1.1.4 version before the end of the year. Report bugs to this list or directly to me, as usual. enjoy /F From jeff-img@corrt.com Sun Nov 24 18:12:03 2002 From: jeff-img@corrt.com (Jeff Kunce) Date: Sun, 24 Nov 2002 12:12:03 -0600 Subject: [Image-SIG] saving JPEG EXIF data Message-ID: <5.1.0.14.0.20021124121036.00a049d0@wheresmymailserver.com> Hi, Is there a way to get PIL to save "application markers" along with a JPEG image? PIL reads that data (including EXIF data from digital cameras) and puts it in the "app" attribute of an image. But if you save the PIL image, that data is lost. Thanks. --Jeff From pkeeley@insci.com Mon Nov 25 14:31:37 2002 From: pkeeley@insci.com (Paul Keeley) Date: Mon, 25 Nov 2002 09:31:37 -0500 Subject: [Image-SIG] IOError: image file is truncated, 312 bytes left in buffer Message-ID: <7CA4212880CED611BA2200A0C9AB18C704A3E3@mercury.insci.com> I am using the same file. If I do img = Image.open("original.bmp") img.save("newfile.tif") it generates the error. If I do img = Image.open("original.bmp") img.show() img.save("newfile.tif") it does not. When the conversion is finished the image does seem to be correct. Thanks, Paul > -----Original Message----- > From: Fredrik Lundh [SMTP:fredrik@pythonware.com] > Sent: Saturday, November 23, 2002 10:51 AM > To: Paul Keeley; image-sig@python.org > Subject: Re: [Image-SIG] IOError: image file is truncated, 312 bytes > left in buffer > > Paul Keeley wrote: > > > I am trying to convert a BMP file to TIF as follows: > > > > img = Image.open(filename.bmp) > > img.save(filename.tif) > > > > every time it displays the error > > IOError: image file is truncated, 312 bytes left in buffer > > > > If I insert a img.show() between the two lines then sometimes it works > and > > sometimes it does not. > > are you using the same file, or do you mean that it works for some files > and > not for others? > > when PIL succeeds, does the output image look right? > > (the "image file is truncated, 312 bytes left in buffer" error message > means > that there is 312 bytes left in the input buffer, but that's not enough to > fill > an entire row of pixels) > > From schutte@fel.tno.nl Tue Nov 26 08:53:12 2002 From: schutte@fel.tno.nl (K Schutte) Date: Tue, 26 Nov 2002 09:53:12 +0100 Subject: [Image-SIG] ANN: PIL 1.1.4 alpha 2 References: <007301c293a5$eb0a8fa0$ced241d5@hagrid> Message-ID: <3DE33678.BEFD9175@fel.tno.nl> Thanks, 16 bit support now works. However, one problem seen: show() doesn't work on a 16 bit image; this is as Frederik choose to delete the line below from the 'standard' modes: *** Imaging-1.1.4a2/PIL/Image.py.org Tue Nov 26 08:26:51 2002 --- Imaging-1.1.4a2/PIL/Image.py Tue Nov 26 08:31:28 2002 *************** *** 161,168 **** # official modes "1": ("L", "L", ("1",)), "L": ("L", "L", ("L",)), ! # @PIL88 ! # "I;16" : ("L", "I;16", ("I;16",)), "I": ("L", "I", ("I",)), "F": ("L", "F", ("F",)), "P": ("RGB", "L", ("P",)), --- 161,167 ---- # official modes "1": ("L", "L", ("1",)), "L": ("L", "L", ("L",)), ! "I;16" : ("L", "I;16", ("I;16",)), "I": ("L", "I", ("I",)), "F": ("L", "F", ("F",)), "P": ("RGB", "L", ("P",)), This means that for the example given earlier to work you have to type: import Image im16 = Image.open('img.tif') min,max = im16.getextrema() scale = 255.0 / (max - min) offset = - min * scale im16c = im16.point(lambda i: i * scale + offset) im8c = im16c.convert('L') im8c.show() Remark: I just found out that the 16 bit image should be written in the same endian mode as the computer itself. A quick test also revealed this to be true for the (standard builtin) 32 bit support! Klamer Fredrik Lundh wrote: > Report bugs to this list or directly to me, as usual. -- Klamer Schutte, E-mail: Schutte@fel.tno.nl Electro-Optical Systems, TNO Physics and Electronics Laboratory Tel: +31-70-3740469 -- Fax: +31-70-3740654 -- Mobile: +31-6-51316671 From klimek@grc.nasa.gov Tue Nov 26 09:27:32 2002 From: klimek@grc.nasa.gov (Robert Klimek) Date: Tue, 26 Nov 2002 09:27:32 +0000 Subject: [Image-SIG] ANN: PIL 1.1.4 alpha 2 In-Reply-To: <3DE33678.BEFD9175@fel.tno.nl> References: <007301c293a5$eb0a8fa0$ced241d5@hagrid> <3DE33678.BEFD9175@fel.tno.nl> Message-ID: <200211260927.32907.klimek@grc.nasa.gov> Klamer, Thanks for the good work! I plan to use the 16-bit capabilities soon. Bob On Tuesday November 26 2002 8:53 am, K Schutte wrote: > Thanks, 16 bit support now works. > > However, one problem seen: show() doesn't work on a 16 bit image; this = is > as Frederik choose to delete the line below from the 'standard' modes: > > *** Imaging-1.1.4a2/PIL/Image.py.org Tue Nov 26 08:26:51 2002 > --- Imaging-1.1.4a2/PIL/Image.py Tue Nov 26 08:31:28 2002 > *************** > *** 161,168 **** > # official modes > "1": ("L", "L", ("1",)), > "L": ("L", "L", ("L",)), > ! # @PIL88 > ! # "I;16" : ("L", "I;16", ("I;16",)), > "I": ("L", "I", ("I",)), > "F": ("L", "F", ("F",)), > "P": ("RGB", "L", ("P",)), > --- 161,167 ---- > # official modes > "1": ("L", "L", ("1",)), > "L": ("L", "L", ("L",)), > ! "I;16" : ("L", "I;16", ("I;16",)), > "I": ("L", "I", ("I",)), > "F": ("L", "F", ("F",)), > "P": ("RGB", "L", ("P",)), > > This means that for the example given earlier to work you have to type: > > import Image > im16 =3D Image.open('img.tif') > min,max =3D im16.getextrema() > scale =3D 255.0 / (max - min) > offset =3D - min * scale > im16c =3D im16.point(lambda i: i * scale + offset) > im8c =3D im16c.convert('L') > im8c.show() > > Remark: I just found out that the 16 bit image should be written in the > same endian mode as the computer itself. A quick test also revealed thi= s to > be true for the (standard builtin) 32 bit support! > > Klamer > > Fredrik Lundh wrote: > > Report bugs to this list or directly to me, as usual. From photo#nms@otdel-1.org Wed Nov 27 13:05:56 2002 From: photo#nms@otdel-1.org (Nikolai SAOUKH) Date: Wed, 27 Nov 2002 16:05:56 +0300 Subject: [Image-SIG] PIL 1.1.4 alpha 2 -- small patches for win32/tk8.4.1/... Message-ID: <20021127130556.GA70291@otdel1.org> --DocE+STaALJfprDB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Attached patches allows: - compile PIL with MS Visual C (makefile.win & Dib.c) - compile PIL against tk-8.4.1 - fix jpeg libname when platform == win32 (setup.py) - move common directory path to separate variable (makefile.win & setup.py) I would not insist on that patches. Better ones are welcomed ;-) --DocE+STaALJfprDB Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=0 --- Tk/tkImaging.c.orig Fri Nov 22 14:08:30 2002 +++ Tk/tkImaging.c Tue Nov 26 23:09:06 2002 @@ -40,6 +40,8 @@ #include +#define USE_COMPOSITELESS_PHOTO_PUT_BLOCK 1 + #include "tk.h" #include "Imaging.h" --- libImaging/Dib.c.orig Fri Nov 22 14:08:32 2002 +++ libImaging/Dib.c Tue Nov 26 22:09:58 2002 @@ -24,6 +24,9 @@ #ifdef WIN32 +#undef INT32 +#undef UINT32 + #include "ImDib.h" --- libImaging/Makefile.win.orig Fri Nov 22 14:08:32 2002 +++ libImaging/Makefile.win Tue Nov 26 22:10:58 2002 @@ -17,9 +17,10 @@ all: imaging.lib -JPEGINCLUDE= -I../../../kits/jpeg-6b -TIFFINCLUDE= -I../../../kits/tifflib -ZLIBINCLUDE= -I../../../kits/zlib-1.1.4 +TOPDIR=../.. +JPEGINCLUDE= -I$(TOPDIR)/jpeg-6b +TIFFINCLUDE= -I$(TOPDIR)/tiff-v3.5.7 +ZLIBINCLUDE= -I$(TOPDIR)/zlib-1.1.4 CC= cl.exe CFLAGS= -W3 -Ox -O2 -c -MD -nologo $(JPEGINCLUDE) \ $(TIFFINCLUDE) $(ZLIBINCLUDE) @@ -90,8 +91,8 @@ $(CPP) -MD -o coretest.exe coretest.c $(OUTLIB) clean: - del *.obj - del $(OUTLIB) + -del *.obj + -del $(OUTLIB) -test: +test: coretest.exe coretest --- setup.py.orig Fri Nov 22 14:08:32 2002 +++ setup.py Wed Nov 27 15:57:31 2002 @@ -23,9 +23,10 @@ # on windows, the build script expects to find both library files and # include files in the directories below. tweak as necessary. -JPEGDIR = "../../kits/jpeg-6b" -ZLIBDIR = "../../kits/zlib-1.1.4" -FREETYPEDIR = "../../kits/freetype-2.0" +TOPDIR="../" +JPEGDIR = TOPDIR + "jpeg-6b" +ZLIBDIR = TOPDIR + "zlib-1.1.4" +FREETYPEDIR = TOPDIR + "freetype-2.1.3" # on windows, the following is used to control how and where to search # for Tcl/Tk files. None enables automatic searching; to override, set @@ -57,7 +58,7 @@ if lib == "JPEG": HAVE_LIBJPEG = 1 if sys.platform == "win32": - LIBRARIES.append("jpeg") + LIBRARIES.append("libjpeg") INCLUDE_DIRS.append(JPEGDIR) LIBRARY_DIRS.append(JPEGDIR) else: --DocE+STaALJfprDB-- From daniel@cri.ensmp.fr Wed Nov 27 14:22:12 2002 From: daniel@cri.ensmp.fr (daniel) Date: Wed, 27 Nov 2002 15:22:12 +0100 Subject: [Image-SIG] reading JPG metadata with python Message-ID: <3DE4D514.303@cri.ensmp.fr> Having the Pil Handbook not having found any hint; I'm wondering : U might know Perl's Image::Info, anything of the kind in python ? Thanks L=E9o From kent@springfed.com Wed Nov 27 22:31:08 2002 From: kent@springfed.com (kent@springfed.com) Date: Wed, 27 Nov 2002 16:31:08 -0600 Subject: [Image-SIG] IPTC and EXIF in PIL Message-ID: <20021127223046.40358218839@sa-3.airstreamcomm.net> Howdy, What is the current capability of PIL in handling imbedded data; [ ] destroys it [ ] reads [ ] writes [ ] other Thanks, Kent From cjensen@formpath.com Fri Nov 29 21:29:13 2002 From: cjensen@formpath.com (Christian M. Jensen) Date: Fri, 29 Nov 2002 15:29:13 -0600 Subject: [Image-SIG] Group 4 TIFF Message-ID: Hello All, This is my first post. I have a need to convert FAX Group IV images over to nice little JPGs and have run into the issue of PIL having a limited set of (de)compression formats available to it. I know I could do this on a command line but... rather be able to do it in PIL, yea, I know I am stubborn. Yes, I have read the archives and source... to a point. So, this letter is to the brains that be... can you give me a general outline how I would start? What stubs(API), what CVS... I have no problem dropping in these functions but just need a little start in the right direction. I have used LibTIFF and it would probably be where I start, unless you guys (and girls) think otherwise. Regards, Christian Jensen From cjensen@formpath.com Fri Nov 29 21:31:54 2002 From: cjensen@formpath.com (Christian M. Jensen) Date: Fri, 29 Nov 2002 15:31:54 -0600 Subject: [Image-SIG] PS Type 1 Renderer Message-ID: Anyone know what is up with the Renderer? Where it stands developmentally speaking? From lightstone@acm.org Sat Nov 30 01:07:22 2002 From: lightstone@acm.org (lightstone@acm.org) Date: Fri, 29 Nov 2002 17:07:22 -0800 Subject: [Image-SIG] Using ImageTk with Pmw.Blt Message-ID: <3DE79ECA.3310.1CB4403@localhost> I am trying to use the .snap() method of Pmw.Blt to get a graph image which I can then convert using PIL to "something" (PDF or DIB or ??). I can't seem to use the ImageTk.PhotoImage() method since apparently Pmw.Blt doesn't find the PhotoImage part of the object to pass to Blt. The piddle method also doesn't work for the same reason that an Image object is used and Blt/Tcl *needs* a PhotoImage object. What should I be doing here? I want to get some of these graph objects annotated and printed (on a Windows machine). =============test program============================== from Tkinter import * # The Tk package import Pmw # The Python MegaWidget package import DebugWin DebugWin.Take_all() # trap stdout/stderr so I can see errors import piddle,Image,ImageTk from piddlePIL import * master = Tk() # build Tk-environment g = Pmw.Blt.Graph(master) g.pack(expand=1, fill='both') g.line_create('Line',xdata=(0,10),ydata=(0,5),symbol='') ################## snap ################################ def showSnap(): img = ImageTk.PhotoImage() g.snap(img.__photo) img.__photo.write('file.gif') ## img = PhotoImage(name="image", master=master) ## g.snap(img) # take snapshot ## img.write("file.gif") # and save it to file. print "Snapshot taken an written to file: file.gif" pc=PILCanvas(img) # make row of buttons buttons = Pmw.ButtonBox(master, labelpos='n', label_text='Options') buttons.pack(fill='y', expand=1, padx=10, pady=10) buttons.add('Snap', command=showSnap) buttons.add('Quit', command=master.quit) master.mainloop() Howard Lightstone