From dereks@realloc.net Thu May 1 00:09:19 2003 From: dereks@realloc.net (Derek Simkowiak) Date: Wed, 30 Apr 2003 16:09:19 -0700 Subject: [Image-SIG] Re: Image.putpalette() bug In-Reply-To: <3EB04774.2060908@realloc.net> References: <3EB04774.2060908@realloc.net> Message-ID: <3EB0579F.1060306@realloc.net> Derek Simkowiak wrote: > [dereks@localhost src]$ ./wal_test.py > Traceback (most recent call last): > File "./wal_test.py", line 7, in ? > wal_image.show() > File "/usr/lib/python2.2/site-packages/PIL/Image.py", line 770, in show > _showxv(self, title, command) > File "/usr/lib/python2.2/site-packages/PIL/Image.py", line 1079, in > _showxv > file = self.convert(base)._dump(format=format) > File "/usr/lib/python2.2/site-packages/PIL/Image.py", line 345, in _dump > self.load() > File "/usr/lib/python2.2/site-packages/PIL/Image.py", line 414, in load > self.im.putpalette(self.palette.rawmode, self.palette.data) > ValueError: unrecognized image mode > [dereks@localhost src]$ On the trail of this bug, I may have found some more clues (but I don't know how to fix it). I think the problem of trying to do a "putpalette()" on an image that has self->image->mode set to "RGB" occurs here: > File "/usr/lib/python2.2/site-packages/PIL/Image.py", line 1079, in > _showxv > file = self.convert(base)._dump(format=format) In _imaging.c the function "convert()" does this near line 873: ----------------------- if (!mode) { /* Map palette image to full depth */ if (!imIn->palette) return (Imaging) ImagingError_ModeError(); mode = imIn->palette->mode; } [...] ----------------------- I think that "mode" is in fact NULL at this point, because of the fact that line 1079 of Image.py above calls "convert() without a "mode" argument, and it has a default value of "None". So, back in the C code, I think "mode" gets set to "imIn->palette->mode" in the code above, which is "RGB" because the mode of the palette is RGB. Then, with "mode" set to "RGB", we get to: if (strcmp(imIn->mode, "P") == 0) return frompalette(imOut, imIn, mode); Since our imIn is our Image with mode "P", frompalette() gets called, and does this: imOut = ImagingNew2(mode, imOut, imIn); [...] return imOut; That is, our call to convert() results in a call to frompalette() which returns a new Image that has "mode" set to "RGB". Then, back at line 1079 of Image.py: > File "/usr/lib/python2.2/site-packages/PIL/Image.py", line 1079, in > _showxv > file = self.convert(base)._dump(format=format) ...we call _dump() on the result of that convert(). _dump() eventually tries to self.load() the returned Image (which is the new Image with mode "RGB"), where it tries the putpalette() that dies because we're calling putpalette() on an image with mode "RGB" (instead of "P" or "L"). I have not verified this hypothesis, but it might be worth checking out. Another note is that at the very beginning of ImagingNew2() there is this test: if (imOut) { /* make sure images match */ if (strcmp(imOut->mode, mode) != 0 || imOut->xsize != imIn->xsize || imOut->ysize != imIn->ysize) { ImagingError_Mismatch(); return NULL; } } [...] This looks to me like the test should be: if (strcmp(imOut->mode, inIn->mode) != 0 || imOut->xsize != imIn->xsize || imOut->ysize != imIn->ysize) { ImagingError_Mismatch(); return NULL; } That is, shouldn't it be a comparison between the Image modes, and not the output Image the passed-in mode? Or am I totally on the wrong track? Anyway, as a hack if nothing else, the following change made it so my test script "wal_test.py" works: [dereks@localhost PIL]$ diff ./Image.py Image-dist.py 414,415c414 < if self.mode != "RGB": < self.im.putpalette(self.palette.data, self.palette.rawmode) --- > self.im.putpalette(self.palette.rawmode, self.palette.data) I do not know if this is the "correct" fix for the problem or not. Thank You, Derek Simkowiak From dereks@realloc.net Thu May 1 00:47:34 2003 From: dereks@realloc.net (Derek Simkowiak) Date: Wed, 30 Apr 2003 16:47:34 -0700 Subject: [Image-SIG] Simple Question: Adding an alpha layer? Message-ID: <3EB06096.9070907@realloc.net> I have my new "WalImagePlugin.py" which load the WAL file with a default palette. But one of the flags in the header can set the transparency of the image to either 33% or 66%. So my newbie question is: give a new Image with mode "P", what is the best way to add a uniform alpha transparency of either 171 (which is 255 * 67% = 170.85) or else 87 (which is 255 * 34% = 86.7)? It seems like the thing to do is convert self.palette from "RGB" mode to "RGBA", and then somehow add the alpha data. I see "putalpha(band)" but I don't know what a "band" is. Thank You, Derek Simkowiak From fredrik@pythonware.com Thu May 1 13:09:13 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Thu, 1 May 2003 14:09:13 +0200 Subject: [Image-SIG] Re: Image.putpalette() bug References: <3EB04774.2060908@realloc.net> Message-ID: "Derek Simkowiak" wrote: > I was testing my WalImagePlugin.py file, and got a strange > message when I tried to "show()" it: > class WalImageFile(ImageFile.ImageFile): > > format = "WAL" > format_description = "Id Software Quake WAL texture map" > > def _open(self): > ... > > Image.register_open("WAL", WalImageFile) > Image.register_extension("WAL", ".wal") this won't work: PIL requires file plugins to be able to identify a file by looking at the contents, and there's no identifying information in a WAL file. why not just use the WalImageFile module from 1.1.4b1? (which is pretty much identical to the one I posted, and appears to work with all WAL samples I've checked). in your program, you could do something like: def image_open(filename): if filename.endswith(".wal"): im = WalImageFile.open(filename) ... get transparency setting ... if transparency is not None: im = im.convert("RGBA") im.putalpha(Image.new("L", im.size, 255*transparency) return im else: return Image.open(filename) From mvanderheijden@fininfo.fr Fri May 2 07:43:34 2003 From: mvanderheijden@fininfo.fr (VAN DER HEIJDEN Maarten) Date: Fri, 2 May 2003 08:43:34 +0200 Subject: [Image-SIG] Image Draw, line width Message-ID: <59720C230F8BC54098777277F5E10688988CC6@fininfomail.fininfo.grp> Hello, I would like to set the line width when using the method ImageDraw.Line() How is this possible ? This message and any attachments (the "message") is intended solely for the addressees and is confidential. If you receive this message in error, please delete it and immediately notify the sender. Any use not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval. Neither FININFO (nor any of its subsidiaries or affiliates) shall be liable for the message if modified, altered, falsified, edited or diffused without authorization. From larryl@imail.EECS.Berkeley.EDU Sun May 4 10:28:49 2003 From: larryl@imail.EECS.Berkeley.EDU (Lawrence W. Leung) Date: Sun, 4 May 2003 02:28:49 -0700 (PDT) Subject: [Image-SIG] fully working PIL binary? Message-ID: Hi, I've been using PIL to save JPEGs and the code I have crashes 1.1.2 on save and causes a return code of -2 on 1.4.1b1's save. (I can't get 1.1.3 compiled properly) I've been using the python 2.2.2 windows build (official build from the website) and the official binaries of PIL. Anyone know how I can solve this problem? Are the official PIL win32 binaries incompatible with 2.2.2? Are there better PIL binaries to use? (Perhaps a compiled version of 1.1.3?) thanks, -------------- -Larry From haase@msg.ucsf.edu Sun May 4 21:50:35 2003 From: haase@msg.ucsf.edu (Sebastian Haase) Date: Sun, 04 May 2003 13:50:35 -0700 Subject: [Image-SIG] 16bit PNG read/write supported ? Message-ID: Hi all, I am about to start using PIL. We (BioChemistry department at UCSF) are dealing with grayscale images that are 16 bits per pixel (if not floating point). I read that the latest (beta) version of PIL should now support 16bit TIFF images ... What is the status regarding 16bit gray images with PNG ? Thanks for PIL, Sebastian Haase UC, SanFrancisco From fredrik@pythonware.com Mon May 5 12:35:01 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Mon, 5 May 2003 13:35:01 +0200 Subject: [Image-SIG] Re: fully working PIL binary? References: Message-ID: Lawrence W. Leung wrote > I've been using PIL to save JPEGs and the code I have crashes 1.1.2 on > save and causes a return code of -2 on 1.4.1b1's save. (I can't get > 1.1.3 compiled properly) I've been using > the python 2.2.2 windows build (official build from the website) and the > official binaries of PIL. > > Anyone know how I can solve this problem? are you using the "optimize" flag? the JPEG encoder may fail during optimization in some circumstances, due to lack of buffer space. possible workarounds (use both, to be on the safe side): - set the ImageFile.MAXBLOCK value to a bigger value (larger than the largest JPEG file you plan to write, but not larger than the amount of memory you have on your computer): import ImageFile ImageFile.MAXBLOCK = 16777216 - fall back on non-optimized writing if save-with-optimize fails: try: im.save(filename, optimize=1) except IOError: # retry w/o optimization im.save(filename) (if you're saving to an output stream, use a StringIO buffer to avoid writing partial files to the stream). Message-ID: "VAN DER HEIJDEN Maarten" wrote: > I would like to set the line width when using the > method ImageDraw.Line() > > How is this possible ? you cannot; the draw.line primitive only supports single-pixel widths. here's a stupid little hack that add a "width" option to the line primitive, but only supports widths 0 (thin), 1 and 2. # file: ImageDraw2.py import ImageDraw, ImagePath class Draw(ImageDraw.Draw): def line(self, xy, fill=None, width=0): ink, fill = self._getink(fill) if ink is None: return if width <= 1: self.draw.draw_lines(xy, ink) else: # hackelihack! xy = ImagePath.Path(xy) self.draw.draw_lines(xy, ink) xy.transform((1, 0, -1, 0, 1, 0)) self.draw.draw_lines(xy, ink) xy.transform((1, 0, 0, 0, 1, -1)) self.draw.draw_lines(xy, ink) xy.transform((1, 0, 1, 0, 1, 0)) self.draw.draw_lines(xy, ink) usage: import Image, ImageDraw2, random im = Image.new("L", (600, 600), "white") d = ImageDraw2.Draw(im) xy0 = None for i in range(20): xy1 = random.randrange(0, 600), random.randrange(0, 600) if xy0: d.line(xy0 + xy1, fill="black", width=2) xy0 = xy1 im.show() to draw arbitrarily wide lines, the correct approach would be to convert the line to a polygon, and use the polygon primitive to render it. contributions are welcome. From Philip.Cooper@openvest.org Mon May 5 22:29:36 2003 From: Philip.Cooper@openvest.org (Philip Cooper) Date: Mon, 5 May 2003 15:29:36 -0600 Subject: [Image-SIG] PIL 1.1.3 Win binaries for 2.2 Message-ID: <20030505212936.GB10501@sioux.openvest.org> Don't know if this will show up on the proper thread. I just subsrcibed and am responding to a recent posting. The respone to the subject was that downloading PIL binary for python 2.1 and installing manually seemed to work without any testing. Just opening a file appeared to work. As the FAQ at pythonware says the Image.py(c) may work and be bale to open an image file and perform some tasks. This does not imply a working PIL. _imaging.pyd is accessed for other functions (like drawing or modifying an image as I and I suspect the original poster were attempting). This dll does not load and work well with python 2.2 . Pythonware says this on thier site, and the recent posting of the orginal and subsequent (May 4) postings indicate, that no working binary has surfaced yet. I've seen some posts on compile tips but has anyone seen or posted a working binary for the PIL 1.3 Python 2.2 compo under windows. (Linux is my primary production environment but I need the windoz verions for mobility reasons ;-) Cheers -- Phil From lbates@syscononline.com Tue May 6 17:35:57 2003 From: lbates@syscononline.com (Larry Bates) Date: Tue, 6 May 2003 11:35:57 -0500 Subject: FW: [Image-SIG] PIL 1.1.3 Win binaries for 2.2 Message-ID: <00fe01c313ed$926fc040$9500a8c0@larrywxp> ActiveState is a good source for binaries. PIL 1.1.3 is available at: http://ppm.activestate.com/PPMPackages/PyPPM/2.2+/packages/PIL-1.1.3.win32.2 .2.zip Regards, Larry Bates -----Original Message----- From: image-sig-admin@python.org [mailto:image-sig-admin@python.org]On Behalf Of Philip Cooper Sent: Monday, May 05, 2003 4:30 PM To: image-sig@python.org Subject: [Image-SIG] PIL 1.1.3 Win binaries for 2.2 Don't know if this will show up on the proper thread. I just subsrcibed and am responding to a recent posting. The respone to the subject was that downloading PIL binary for python 2.1 and installing manually seemed to work without any testing. Just opening a file appeared to work. As the FAQ at pythonware says the Image.py(c) may work and be bale to open an image file and perform some tasks. This does not imply a working PIL. _imaging.pyd is accessed for other functions (like drawing or modifying an image as I and I suspect the original poster were attempting). This dll does not load and work well with python 2.2 . Pythonware says this on thier site, and the recent posting of the orginal and subsequent (May 4) postings indicate, that no working binary has surfaced yet. I've seen some posts on compile tips but has anyone seen or posted a working binary for the PIL 1.3 Python 2.2 compo under windows. (Linux is my primary production environment but I need the windoz verions for mobility reasons ;-) Cheers -- Phil From fredrik@pythonware.com Tue May 6 21:57:58 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Tue, 6 May 2003 22:57:58 +0200 Subject: [Image-SIG] ANN: PIL 1.1.4 beta 2 (source) Message-ID: the PIL 1.1.4 beta 2 source kit are now available from: http://effbot.org/downloads#imaging consider this as a release candidate; if I don't hear anything, and we don't find any problems in our internal testing, this will be released as 1.1.4 final in a not too distant future. enjoy /F From Jack.Jansen@cwi.nl Wed May 7 13:00:06 2003 From: Jack.Jansen@cwi.nl (Jack Jansen) Date: Wed, 7 May 2003 14:00:06 +0200 Subject: [Image-SIG] ANN: PIL 1.1.4 beta 2 (source) In-Reply-To: Message-ID: <71AEC400-8083-11D7-A6E2-0030655234CE@cwi.nl> On Tuesday, May 6, 2003, at 22:57 Europe/Amsterdam, Fredrik Lundh wrote: > the PIL 1.1.4 beta 2 source kit are now available from: > > http://effbot.org/downloads#imaging > > consider this as a release candidate; if I don't hear anything, and we > don't find any problems in our internal testing, this will be released > as > 1.1.4 final in a not too distant future. Fredrik, builds and installs flawlessly, I've already added it to the MacPython 2.3b1 Package Manager. I do have one more feature request, though (or maybe this is in there and I'm not looking at the right place): I would like to be able to get the version number. Package Manager also notices if you have an outdated version installed, but I can't seem to find the version number in PIL. Could you add an __version__="1.1.4" to the __init__.py or something? -- Jack Jansen, , http://www.cwi.nl/~jack If I can't dance I don't want to be part of your revolution -- Emma Goldman From fredrik@pythonware.com Wed May 7 13:03:37 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Wed, 7 May 2003 14:03:37 +0200 Subject: [Image-SIG] Re: ANN: PIL 1.1.4 beta 2 (source) References: <71AEC400-8083-11D7-A6E2-0030655234CE@cwi.nl> Message-ID: Jack Jansen wrote: > builds and installs flawlessly, I've already added it to the MacPython > 2.3b1 Package Manager. excellent! > I do have one more feature request, though (or maybe this is in there > and I'm not looking at the right place): I would like to be able to get > the version number. > > Package Manager also notices if you have an outdated version installed, > but I can't seem to find the version number in PIL. hint: >>> import Image >>> Image.VERSION '1.1.4b2' From fredrik@pythonware.com Thu May 8 08:45:40 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Thu, 8 May 2003 09:45:40 +0200 Subject: [Image-SIG] Re: PIL 1.1.3 Win binaries for 2.2 References: <20030505212936.GB10501@sioux.openvest.org> Message-ID: Philip Cooper wrote: > Pythonware says this on thier site, and the recent posting of the > orginal and subsequent (May 4) postings indicate, that no working > binary has surfaced yet. at this point, I (speaking for both PythonWare and myself) recommend the 1.1.4b2 release, which is available for 2.1, 2.2, and 2.3b1. From fredrik@pythonware.com Thu May 8 11:02:11 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Thu, 8 May 2003 12:02:11 +0200 Subject: [Image-SIG] Re: 16bit PNG read/write supported ? References: Message-ID: Sebastian Haase wrote: > I am about to start using PIL. We (BioChemistry department > at UCSF) are dealing with grayscale images that are 16 > bits per pixel (if not floating point). > I read that the latest (beta) version of PIL should now > support 16bit TIFF images ... > > What is the status regarding 16bit gray images with PNG ? if I remember correctly, and interpret the code correctly, PIL reads 16-bit monochrome PNG files as mode "I" images (that is, it uses 32- bit internal storage). I don't have any 16-bit samples on this box (and no time to google for them), but roundtripping sure seems to work: >>> import Image >>> im = Image.new("I", (100, 100)) >>> im.putdata(range(10000)) >>> im.getpixel((50, 50)) 5050 >>> im.save("out.png") >>> im = Image.open("out.png") >>> im.mode 'I' >>> im.size (100, 100) >>> im.getpixel((50, 50)) 5050 From fredrik@pythonware.com Thu May 8 12:19:59 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Thu, 8 May 2003 13:19:59 +0200 Subject: [Image-SIG] Re: Question about file decoder References: <01CC2FBB7C2E3A4C8B26849617E27EED0559A5@inte_fin> Message-ID: Volker Dobler wrote: > I wrote a file decoder for a simple image format > (header followed by 16bit data) by subclassing > ImageFile, providing a _open() method and using > a the apropriate raw decodeer. It works. > > Now my question: The 16bit data is scaled by a > factor and should be rescaled to the "real" values > during reading. The scaling factor can be found > in the header and is extracted during _open(). > How can I do this rescaling during the reading of > the file. > > Of course a can save the scaling factor and do a > img.point( lambda z: z*scaling + 0 ) afterwards, > but I want to implement this step into the reading > of the data. you can override the "load_end" method in your ImagePlugin, and replace or manipulate the pixel storage in there. this method is called when the pixel data has been loaded (which is usually done when the data is first accessed), but before any other function gets around to access the data. something like this should work: class MyImagePlugin(ImageFile): def _open(self): ... self.scale = getscale() def load_end(self): new = Image.point(lambda z: z*self.scale + 0) self.im = new.im # replace storage alternatively, you can use (undocumented, inofficial) methods on the storage object: def load_end(self): self.im = self.im.point_transform(self.scale, 0) From haase@msg.ucsf.edu Thu May 8 17:34:03 2003 From: haase@msg.ucsf.edu (Sebastian Haase) Date: Thu, 8 May 2003 09:34:03 -0700 Subject: [Image-SIG] Re: 16bit PNG read/write supported ? References: Message-ID: <00a101c3157f$a318b080$421ee6a9@rodan> Thanks for the reply. That PIL reads 16bit PNG is nice to hear! Can it also _write_ 16bit PNG ? And since I have VERY large images I probably would need to have them loaded to / written from "unsigned short" arrays instead of "signed long". Does it make sence for me to look into the PIL source code and where can I get it ? Which _file_ should I look at? Thanks again, - Sebastian > Sebastian Haase wrote: > > > I am about to start using PIL. We (BioChemistry department > > at UCSF) are dealing with grayscale images that are 16 > > bits per pixel (if not floating point). > > I read that the latest (beta) version of PIL should now > > support 16bit TIFF images ... > > > > What is the status regarding 16bit gray images with PNG ? > > if I remember correctly, and interpret the code correctly, PIL reads > 16-bit monochrome PNG files as mode "I" images (that is, it uses 32- > bit internal storage). > > I don't have any 16-bit samples on this box (and no time to google > for them), but roundtripping sure seems to work: > > >>> import Image > >>> im = Image.new("I", (100, 100)) > >>> im.putdata(range(10000)) > >>> im.getpixel((50, 50)) > 5050 > >>> im.save("out.png") > > >>> im = Image.open("out.png") > >>> im.mode > 'I' > >>> im.size > (100, 100) > >>> im.getpixel((50, 50)) > 5050 > > > > > > > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig > From fredrik@pythonware.com Thu May 8 22:29:24 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Thu, 8 May 2003 23:29:24 +0200 Subject: [Image-SIG] Re: Re: 16bit PNG read/write supported ? References: <00a101c3157f$a318b080$421ee6a9@rodan> Message-ID: Sebastian Haase wrote: > That PIL reads 16bit PNG is nice to hear! Can it also > _write_ 16bit PNG ? that's what my example tried to illustrate (it created an image with 16-bit values in it, saved it, and read it back). > And since I have VERY large images I probably would need to have them loaded > to / written from "unsigned short" arrays instead of "signed long". > Does it make sence for me to look into the PIL source code and where can I > get it ? http://www.pythonware.com/products/pil > Which _file_ should I look at? start by tweaking the _MODES and _OUTMODES tables in PIL/PngImagePlugin.py. From feix@rutchem.rutgers.edu Fri May 9 15:59:12 2003 From: feix@rutchem.rutgers.edu (Fei Xu) Date: Fri, 9 May 2003 10:59:12 -0400 Subject: [Image-SIG] write text on a picture In-Reply-To: <20030407211849.287178c5.nieder@mail.ru> Message-ID: HI! Riardo: When I had my system adminstrator to install the fonts file, we could not download it from http://effbot.org/pil/pilfonts.zip, because the webpage has changed much. We also tried to find the fonts file on web but failed. Would you like to tell me other links from which I can download the fonts file? Or sent the fonts file to me by email, if you'd like. I really appreciate your help. Fei On Mon, 7 Apr 2003, Ricardo Niederberger Cabral wrote: > On Mon, 7 Apr 2003 18:49:32 -0400 > Fei Xu wrote: > > > HI! Everyone: I am using pytohn image library to draw a picture with some > > text on it. I can draw things like circles, etc, which means my python > > library works well. But I can't write text on it. > > >>>write.text((0, 0, 100,100), 'red') Traceback (most recent call last): > > Try something like: > > ifo=ImageFont.load("courB12.pil") > draw.text((0,0),caption,(100,100,100),font=ifo) > > where: > (0,0) is the text coordinate > (100,100,100) is the text color RGB triple > caption is a string > "courB12.pil" is the filename of an existing pil font file. (you may need to include full path if not in current dir) > (I believe a corresponding courB12.pbm must also exist at the same path) > > You can get some pil fonts at http://effbot.org/pil/pilfonts.zip > > Best regards, > --- > rnc > From fredrik@pythonware.com Fri May 9 16:13:01 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Fri, 9 May 2003 17:13:01 +0200 Subject: [Image-SIG] Re: write text on a picture References: <20030407211849.287178c5.nieder@mail.ru> Message-ID: Fei Xu wrote: > When I had my system adminstrator to install the fonts file, we could not > download it from http://effbot.org/pil/pilfonts.zip, because the webpage > has changed much. We also tried to find the fonts file on web but failed. if you search for "pilfonts.zip" on google, the second hit is: http://effbot.org/downloads#pilfonts.zip From feix@rutchem.rutgers.edu Fri May 9 16:42:45 2003 From: feix@rutchem.rutgers.edu (Fei Xu) Date: Fri, 9 May 2003 11:42:45 -0400 Subject: [Image-SIG] resize a image Message-ID: HI! Everyone: I tried to resize an image but failed. The script and error messages are shown as below: >>> import Image >>> im = Image.open('pd0001_contype.jpeg').resize((400,400),'NEAREST').save('pd0001_contype.thumnail', "JPEG") Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.2/site-packages/PIL/Image.py", line 684, in resize raise ValueError("unknown resampling filter") ValueError: unknown resampling filter The filter argument can be nearest, bilinear or bicubic. I tried and got same message. What should I do? Thanks a lot! Fei From fredrik@pythonware.com Fri May 9 16:40:38 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Fri, 9 May 2003 17:40:38 +0200 Subject: [Image-SIG] ANN: PIL 1.1.4 (sneak release) Message-ID: PIL 1.1.4 final is now available from: http://effbot.org/downloads#imaging (it's a day early, so don't tell anyone about it ;-) enjoy /F From fredrik@pythonware.com Fri May 9 17:04:03 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Fri, 9 May 2003 18:04:03 +0200 Subject: [Image-SIG] Re: resize a image References: Message-ID: > I tried to resize an image but failed. The script and error > messages are shown as below: > ValueError: unknown resampling filter > The filter argument can be nearest, bilinear or bicubic. I tried and got > same message. the filter argument must be one the constants defined in the Image module: im = im.resize((400,400), Image.NEAREST) also note that NEAREST is the default, and that im.thumbnail is usually a much faster way to create a thumbnail, especially when the input files are large JPEG files...: im = Image.open('pd0001_contype.jpeg') im.thumbnail((400,400),'NEAREST') im.save('pd0001_contype.thumbnail', "JPEG") From fredrik@pythonware.com Fri May 9 17:33:55 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Fri, 9 May 2003 18:33:55 +0200 Subject: [Image-SIG] Re: resize a image References: Message-ID: > im = Image.open('pd0001_contype.jpeg') > im.thumbnail((400,400),'NEAREST') > im.save('pd0001_contype.thumbnail', "JPEG") oops. better make that: im = Image.open('pd0001_contype.jpeg') im.thumbnail((400,400)) im.save('pd0001_contype.thumbnail', "JPEG") From lbates@syscononline.com Fri May 9 17:49:09 2003 From: lbates@syscononline.com (Larry Bates) Date: Fri, 9 May 2003 11:49:09 -0500 Subject: [Image-SIG] write text on a picture (PIL fonts) In-Reply-To: Message-ID: <007501c3164a$ea2414d0$9500a8c0@larrywxp> Over the years I've located several different collections of PIL fonts. I've uploaded them to temporary location at: 5Mb http://www.syscononline.com/PILfonts/ARIAL_300.ZIP 2Mb http://www.syscononline.com/PILfonts/COURIER_NEW_300.ZIP 3Mb http://www.syscononline.com/PILfonts/PIL_BASEFONTS_72DPI.ZIP 4.5Mb http://www.syscononline.com/PILfonts/PIL_BASEFONTS_100DPI.ZIP 10Mb http://www.syscononline.com/PILfonts/PIL_BASEFONTS_200DPI.ZIP 16Mb http://www.syscononline.com/PILfonts/PIL_BASEFONTS_300DPI.ZIP 27Mb http://www.syscononline.com/PILfonts/PIL_BASEFONTS_400DPI.ZIP 1Mb http://www.syscononline.com//PILfonts/pilfonts.zip 2Mb http://www.syscononline.com/PILfonts/SCRIPT_FONTS_300.ZIP 2.5Mb http://www.syscononline.com/PILfonts/SYMBOL_FONTS_300.ZIP 3Mb http://www.syscononline.com/PILfonts/TIMES_NEW_ROMAN_300.ZIP I think most of the files are self-explanatory. I haven't tested these extensively, just saved them when I came across them. I have used the COURIER NEW 300 on one project that I did back last year. Fredrik - While I'm sure you have most/all of these, if not maybe you would have someone download them and put them on your Pythonware site. I found them extremely difficult to find and others would benefit I'm sure. Just a suggestion. Regards, Larry -----Original Message----- From: image-sig-admin@python.org [mailto:image-sig-admin@python.org]On Behalf Of Fei Xu Sent: Friday, May 09, 2003 9:59 AM To: Ricardo Niederberger Cabral Cc: image-sig@python.org Subject: Re: [Image-SIG] write text on a picture HI! Riardo: When I had my system adminstrator to install the fonts file, we could not download it from http://effbot.org/pil/pilfonts.zip, because the webpage has changed much. We also tried to find the fonts file on web but failed. Would you like to tell me other links from which I can download the fonts file? Or sent the fonts file to me by email, if you'd like. I really appreciate your help. Fei On Mon, 7 Apr 2003, Ricardo Niederberger Cabral wrote: > On Mon, 7 Apr 2003 18:49:32 -0400 > Fei Xu wrote: > > > HI! Everyone: I am using pytohn image library to draw a picture with some > > text on it. I can draw things like circles, etc, which means my python > > library works well. But I can't write text on it. > > >>>write.text((0, 0, 100,100), 'red') Traceback (most recent call last): > > Try something like: > > ifo=ImageFont.load("courB12.pil") > draw.text((0,0),caption,(100,100,100),font=ifo) > > where: > (0,0) is the text coordinate > (100,100,100) is the text color RGB triple > caption is a string > "courB12.pil" is the filename of an existing pil font file. (you may need to include full path if not in current dir) > (I believe a corresponding courB12.pbm must also exist at the same path) > > You can get some pil fonts at http://effbot.org/pil/pilfonts.zip > > Best regards, > --- > rnc > From gillet@scripps.edu Fri May 9 21:05:09 2003 From: gillet@scripps.edu (Alexandre Gillet) Date: Fri, 09 May 2003 13:05:09 -0700 Subject: [Image-SIG] problem with building _imagingtk on Irix Message-ID: <3EBC09F5.7040901@scripps.edu> Hi I am trying to build and use _imagingtk.so on a SGI irix6.5.for python2.3 I am able to build the module but when I import it I get the folowing error: ImportError: 841717:python2.3: rld: Fatal Error: unresolvable symbol in ./_imagingtk.so: jpeg_resync_to_restart I did build libImaging with jpeg and zlib configure. I am using libjpeg version6 Any idea where I could have gone wrong? The output of compiling the library libImaging.a: ar cr libImaging.a Storage.o Access.o Except.o Antialias.o Bands.o Blend.o Chops.o Convert.o ConvertYCbCr.o Copy.o Crop.o Crc32.o Dib.o Draw.o Effects.o File.o Fill.o Filter.o Geometry.o GetBBox.o Histo.o Matrix.o Negative.o Offset.o Pack.o Palette.o Paste.o Point.o Quant.o QuantHash.o QuantHeap.o RankFilter.o Unpack.o UnpackYCC.o BitDecode.o EpsEncode.o FliDecode.o GifDecode.o GifEncode.o HexDecode.o JpegDecode.o JpegEncode.o LzwDecode.o MspDecode.o PackDecode.o PcdDecode.o PcxDecode.o PcxEncode.o RawDecode.o RawEncode.o SunRleDecode.o TgaRleDecode.o XbmDecode.o XbmEncode.o ZipDecode.o ZipEncode.o ranlib libImaging.a cc -o coretest coretest.o libImaging.a -lz -ljpeg -lm ld32: WARNING 84 : /usr/lib32/libz.so is not used for resolving any symbol. ld32: WARNING 84 : /usr/lib32/libjpeg.so is not used for resolving any symbol. Output of building _imagingtk.so building '_imagingtk' extension creating build/temp.irix64-6.5-2.3/Tk cc -OPT:Olimit=0 -DNDEBUG -O -IlibImaging -I/mgl/prog/share/include -I/mgl/python/share/include/python2.3 -I/mgl/python/sgi4DIRIX646/include/python2.3 -c _imagingtk.c -o build/temp.irix64-6.5-2.3/_imagingtk.o cc -OPT:Olimit=0 -DNDEBUG -O -IlibImaging -I/mgl/prog/share/include -I/mgl/python/share/include/python2.3 -I/mgl/python/sgi4DIRIX646/include/python2.3 -c Tk/tkImaging.c -o build/temp.irix64-6.5-2.3/Tk/tkImaging.o cc-1164 cc: WARNING File = Tk/tkImaging.c, Line = 197 Argument of type "int (*)(ClientData, Tcl_Interp *, int, char **)" is incompatible with parameter of type "Tcl_CmdProc *". Tcl_CreateCommand(interp, "PyImagingPhoto", PyImagingPhoto, ^ ld -shared -all build/temp.irix64-6.5-2.3/_imagingtk.o build/temp.irix64-6.5-2.3/Tk/tkImaging.o -LlibImaging -L/mgl/prog/sgi4DIRIX646/lib -lImaging -ltk8.4 -ltcl8.4 -o build/lib.irix64-6.5-2.3/_imagingtk.so Thanks Alex -- o Alexandre Gillet email: gillet@scripps.edu / The Scripps Research Institute, o Dept. Molecular Biology, MB-5, \ 10550 North Torrey Pines Road, o La Jolla, CA 92037-1000, USA. / tel: (858) 784-2053 o fax: (858) 784-2860 From kevin@cazabon.com Sat May 10 19:00:13 2003 From: kevin@cazabon.com (kevin@cazabon.com) Date: Sat, 10 May 2003 11:00:13 -0700 Subject: [Image-SIG] write text on a picture (PIL fonts) References: <007501c3164a$ea2414d0$9500a8c0@larrywxp> Message-ID: <01ba01c3171e$028f7680$33ff0fac@782FV4Z> I think his major concern is copyright... not all the fonts in all those packages are "free", and unless you own the right to use them in some other format it is not legal for you to use them in PIL. Now, the chances of it becomming an issue are small, but I'm sure Fred needs to be on the safe side of that, right? :) Kevin. ----- Original Message ----- From: "Larry Bates" To: "'Fei Xu'" Cc: Sent: Friday, May 09, 2003 9:49 AM Subject: RE: [Image-SIG] write text on a picture (PIL fonts) > Over the years I've located several different collections > of PIL fonts. I've uploaded them to temporary location at: > > 5Mb http://www.syscononline.com/PILfonts/ARIAL_300.ZIP > > 2Mb http://www.syscononline.com/PILfonts/COURIER_NEW_300.ZIP > > 3Mb http://www.syscononline.com/PILfonts/PIL_BASEFONTS_72DPI.ZIP > > 4.5Mb http://www.syscononline.com/PILfonts/PIL_BASEFONTS_100DPI.ZIP > > 10Mb http://www.syscononline.com/PILfonts/PIL_BASEFONTS_200DPI.ZIP > > 16Mb http://www.syscononline.com/PILfonts/PIL_BASEFONTS_300DPI.ZIP > > 27Mb http://www.syscononline.com/PILfonts/PIL_BASEFONTS_400DPI.ZIP > > 1Mb http://www.syscononline.com//PILfonts/pilfonts.zip > > 2Mb http://www.syscononline.com/PILfonts/SCRIPT_FONTS_300.ZIP > > 2.5Mb http://www.syscononline.com/PILfonts/SYMBOL_FONTS_300.ZIP > > 3Mb http://www.syscononline.com/PILfonts/TIMES_NEW_ROMAN_300.ZIP > > I think most of the files are self-explanatory. I haven't > tested these extensively, just saved them when I came across > them. I have used the COURIER NEW 300 on one project that I > did back last year. > > Fredrik - While I'm sure you have most/all of these, if not > maybe you would have someone download them and put them on > your Pythonware site. I found them extremely difficult to > find and others would benefit I'm sure. Just a suggestion. > > Regards, Larry > > -----Original Message----- > From: image-sig-admin@python.org [mailto:image-sig-admin@python.org]On > Behalf Of Fei Xu > Sent: Friday, May 09, 2003 9:59 AM > To: Ricardo Niederberger Cabral > Cc: image-sig@python.org > Subject: Re: [Image-SIG] write text on a picture > > > HI! Riardo: > When I had my system adminstrator to install the fonts file, we could not > download it from http://effbot.org/pil/pilfonts.zip, because the webpage > has changed much. We also tried to find the fonts file on web but failed. > Would you like to tell me other links from which I can download the fonts > file? Or sent the fonts file to me by email, if you'd like. > I really appreciate your help. > Fei > > On Mon, 7 Apr 2003, Ricardo Niederberger Cabral wrote: > > > On Mon, 7 Apr 2003 18:49:32 -0400 > > Fei Xu wrote: > > > > > HI! Everyone: I am using pytohn image library to draw a picture with > some > > > text on it. I can draw things like circles, etc, which means my python > > > library works well. But I can't write text on it. > > > >>>write.text((0, 0, 100,100), 'red') Traceback (most recent call last): > > > > Try something like: > > > > ifo=ImageFont.load("courB12.pil") > > draw.text((0,0),caption,(100,100,100),font=ifo) > > > > where: > > (0,0) is the text coordinate > > (100,100,100) is the text color RGB triple > > caption is a string > > "courB12.pil" is the filename of an existing pil font file. (you may need > to include full path if not in current dir) > > (I believe a corresponding courB12.pbm must also exist at the same path) > > > > You can get some pil fonts at http://effbot.org/pil/pilfonts.zip > > > > Best regards, > > --- > > rnc > > > > > > > > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig > > From fredrik@pythonware.com Sun May 11 09:58:38 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Sun, 11 May 2003 10:58:38 +0200 Subject: [Image-SIG] Re: write text on a picture (PIL fonts) References: <007501c3164a$ea2414d0$9500a8c0@larrywxp> <01ba01c3171e$028f7680$33ff0fac@782FV4Z> Message-ID: kevin wrote: > I think his major concern is copyright... not all the fonts in all those > packages are "free", and unless you own the right to use them in some > other format it is not legal for you to use them in PIL. three concerns, in fact: - copyright issues - server disk space - now that 1.1.4 supports truetype fonts (using the freetype renderer), there should be less need for prebuilt raster fonts From fredrik@pythonware.com Sun May 11 20:53:05 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Sun, 11 May 2003 21:53:05 +0200 Subject: [Image-SIG] Re: problem with building _imagingtk on Irix References: <3EBC09F5.7040901@scripps.edu> Message-ID: Alexandre Gillet wrote: > I am trying to build and use _imagingtk.so on a SGI irix6.5.for python2.3 > I am able to build the module but when I import it I get the folowing error: > ImportError: 841717:python2.3: rld: Fatal Error: unresolvable symbol in > ./_imagingtk.so: jpeg_resync_to_restart I don't know much about SGI build issues, but the "jpeg_resync_to_restart" symbol is defined by the JPEG library -- which shouldn't be needed by the Tk interface... guessing wildly, you could try changing this part of setup.py try: import _tkinter TCL_VERSION = _tkinter.TCL_VERSION[ except (ImportError, AttributeError): pass else: INCLUDE_DIRS = ["libImaging"] LIBRARY_DIRS = ["libImaging"] LIBRARIES = ["Imaging"] to read try: import _tkinter TCL_VERSION = _tkinter.TCL_VERSION[ except (ImportError, AttributeError): pass else: INCLUDE_DIRS += ["libImaging"] LIBRARY_DIRS += ["libImaging"] LIBRARIES += ["Imaging"] From gillet@scripps.edu Mon May 12 18:06:45 2003 From: gillet@scripps.edu (Alexandre Gillet) Date: Mon, 12 May 2003 10:06:45 -0700 Subject: [Image-SIG] bug building _imagingtk.so on Irix Message-ID: <3EBFD4A5.2070803@scripps.edu> Hi, I build _imagigntk.so on Irix 6.5 but when I import the module I get the following error: Python 2.3b1 (#2, Apr 28 2003, 16:32:12) [C] on irix646 Type "help", "copyright", "credits" or "license" for more information. >>> import _imagingtk Traceback (most recent call last): File "", line 1, in ? ImportError: 855209:python2.3: rld: Fatal Error: unresolvable symbol in ./_imagingtk.so: jpeg_resync_to_restart My module is not link to any of jpeg or zlib library.The setup.py don't do it.I did not have any problem building libImaging. I have libjpeg and libz install. I did relink _imagingtk.so with libjpeg and libz and I do not have the problem anymore. Is it a bug in the setup.py that you do not link _imagingtk with jpeg or zlib? It is done for building _imaging.so! Thanks -- o Alexandre Gillet email: gillet@scripps.edu / The Scripps Research Institute, o Dept. Molecular Biology, MB-5, \ 10550 North Torrey Pines Road, o La Jolla, CA 92037-1000, USA. / tel: (858) 784-2053 o fax: (858) 784-2860 From gillet@scripps.edu Mon May 12 18:16:56 2003 From: gillet@scripps.edu (Alexandre Gillet) Date: Mon, 12 May 2003 10:16:56 -0700 Subject: [Image-SIG] Re:Re:problem with building _imagingtk on Irix Message-ID: <3EBFD708.2040301@scripps.edu> Hi, Sorry I did post my problem twice, and I forgot to check the answer for the previous post. Too much installation and bug reporting done the last few day.:-) Thanks Fredrik, your email help me. It fix the building problem on Irix. Alex > I am trying to build and use _imagingtk.so on a SGI irix6.5.for >python2.3 > I am able to build the module but when I import it I get the folowing >error: > ImportError: 841717:python2.3: rld: Fatal Error: unresolvable symbol >in > ./_imagingtk.so: jpeg_resync_to_restart >I don't know much about SGI build issues, but the >"jpeg_resync_to_restart" >symbol is defined by the JPEG library -- which shouldn't be needed by >the >Tk interface... >guessing wildly, you could try changing this part of setup.py >try: > import _tkinter > TCL_VERSION = _tkinter.TCL_VERSION[ >except (ImportError, AttributeError): > pass >else: > INCLUDE_DIRS = ["libImaging"] > LIBRARY_DIRS = ["libImaging"] > LIBRARIES = ["Imaging"] >to read >try: > import _tkinter > TCL_VERSION = _tkinter.TCL_VERSION[ >except (ImportError, AttributeError): > pass >else: > INCLUDE_DIRS += ["libImaging"] > LIBRARY_DIRS += ["libImaging"] > LIBRARIES += ["Imaging"] -- o Alexandre Gillet email: gillet@scripps.edu / The Scripps Research Institute, o Dept. Molecular Biology, MB-5, \ 10550 North Torrey Pines Road, o La Jolla, CA 92037-1000, USA. / tel: (858) 784-2053 o fax: (858) 784-2860 From areopagus125@yahoo.com Tue May 13 19:01:42 2003 From: areopagus125@yahoo.com (David Smith) Date: Tue, 13 May 2003 11:01:42 -0700 (PDT) Subject: [Image-SIG] PIL bit decoder Message-ID: <20030513180142.64392.qmail@web12204.mail.yahoo.com> Evidently, I don't understand something about PIL's bit decoder. I have an 11-bit image to read, with pixels packed so that they cross byte boundaries. The documentation says that the bit decoder reads into floating point images. I figured that reading 11-bit data should produce floating point pixels with integer values from 0.0 to 2047.0. But I am getting littly teeny pixels instead, like 1e-15 and 7.3789486648102458e-021. It also appears that only the low-numbered rows are receiving data. What am I missing? David Smith __________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com From jbreiden@parc.com Tue May 13 21:54:34 2003 From: jbreiden@parc.com (Jeff Breidenbach) Date: Tue, 13 May 2003 13:54:34 PDT Subject: [Image-SIG] Re: suspected bug in PIL 1.1.3 bmp reader Message-ID: Following up on the suggested patch. I tried the BmpReader patch below [1] supplied by Fredrik [2] to see if it would fix a BMP reader problem [3]. Unfortunately it appeared to have no effect, and the same error message occured namely "ValueError: unknown raw mode." I think I patched PIL correctly (I'm a Debian user, so I grabbed the source for the package, patched it, rebuilt the .deb, and installed it). However, I'm pretty new to Python/PIL so it's possible that I missed something. -Jeff [1] http://mail.python.org/pipermail/image-sig/2003-April/002182.html [2] http://www.jab.org/www/foo.bmp [3] http://mail.python.org/pipermail/image-sig/2003-April/002200.html --- original 2003-05-13 11:47:59.000000000 -0700 +++ BmpImagePlugin.py 2003-05-13 11:34:35.000000000 -0700 @@ -108,7 +108,7 @@ palette.append(rgb) if greyscale: if colors == 2: - self.mode = "1" + self.mode = rawmode = "1" else: self.mode = rawmode = "L" else: From fredrik@pythonware.com Tue May 13 22:04:45 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Tue, 13 May 2003 23:04:45 +0200 Subject: [Image-SIG] Re: PIL bit decoder References: <20030513180142.64392.qmail@web12204.mail.yahoo.com> Message-ID: David Smith wrote: > Evidently, I don't understand something about PIL's > bit decoder. I have an 11-bit image to read, with > pixels packed so that they cross byte boundaries. The > documentation says that the bit decoder reads into > floating point images. I figured that reading 11-bit > data should produce floating point pixels with integer > values from 0.0 to 2047.0. But I am getting littly > teeny pixels instead, like 1e-15 and > 7.3789486648102458e-021. It also appears that only > the low-numbered rows are receiving data. What am I > missing? a working PIL install? try this: import Image im = Image.fromstring("F", (10,10), "*"*1000, "bit", 11, 0, 0, 0, 0) print im.mode print im.size print list(im.getdata()) on my box, this prints: F (10, 10) [337.0, 650.0, 1108.0, 674.0, 1301.0, 168.0, ..., 1108.0, 674.0] From areopagus125@yahoo.com Tue May 13 23:36:50 2003 From: areopagus125@yahoo.com (David Smith) Date: Tue, 13 May 2003 15:36:50 -0700 (PDT) Subject: [Image-SIG] Re: PIL bit decoder In-Reply-To: Message-ID: <20030513223650.8902.qmail@web12204.mail.yahoo.com> --- Fredrik Lundh wrote: > try this: > > import Image > > im = Image.fromstring("F", (10,10), "*"*1000, > "bit", 11, 0, 0, 0, 0) > > print im.mode > print im.size > print list(im.getdata()) > > on my box, this prints: > > F > (10, 10) > [337.0, 650.0, 1108.0, 674.0, 1301.0, 168.0, > ..., 1108.0, 674.0] Yes, it produces the same result for me. -- David Smith __________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com From fredrik@pythonware.com Tue May 13 23:39:29 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Wed, 14 May 2003 00:39:29 +0200 Subject: [Image-SIG] Re: suspected bug in PIL 1.1.3 bmp reader References: Message-ID: Jeff Breidenbach wrote: > I tried the BmpReader patch below [1] supplied by Fredrik [2] to see > if it would fix a BMP reader problem [3]. Unfortunately it appeared to > have no effect, and the same error message occured namely "ValueError: > unknown raw mode." PIL 1.1.4 doesn't seem to have any problems reading the file at http://www.jab.org/www/foo.bmp, so you maybe you didn't manage to install the patch after all... or maybe some other change in 1.1.4 solved the problem... you can get fresh 1.1.4 sources from this page: http://www.pythonware.com/products/pil From areopagus125@yahoo.com Wed May 14 06:10:41 2003 From: areopagus125@yahoo.com (David Smith) Date: Tue, 13 May 2003 22:10:41 -0700 (PDT) Subject: [Image-SIG] Re: PIL bit decoder In-Reply-To: Message-ID: <20030514051041.19273.qmail@web12202.mail.yahoo.com> I found what I was missing. The description of the tile descriptor's region parameter says "region. A 4-tuple specifying where to store data in the image." I supposed the 3rd and 4th elements were width and height, but they are end coordinates. David Smith __________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com From eaganj@bazza.com Wed May 14 22:12:29 2003 From: eaganj@bazza.com (James Eagan) Date: Wed, 14 May 2003 22:12:29 +0100 Subject: [Image-SIG] PIL on Mac OS X: _imaging C module not installed Message-ID: <20030514211229.GA20444@bazza.com> Hi folks, I'm having a little trouble getting PIL to work on my Mac OS X (10.2.6) system. I have python2.3a2 installed as a framework (along with Tcl and Tk), and PIL 1.1.4. Both python and PIL are built from source. My PIL is installed in: dhcp119:/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-pac kages/PIL $ ls [...] ImageDraw.py PSDraw.py _imaging.so* ImageDraw.pyc PSDraw.pyc _imagingft.so* ImageEnhance.py PaletteFile.py _imagingtk.so* In python, import Image works, but then I get runtime errors of: ImportError: The _imaging C module is not installed Here's the output of a python -v (Note that _imaging.so does indeed exist in path and that Image.pyc is being loaded from the same directory): Python 2.3a2 (#1, Apr 24 2003, 16:37:26) [GCC 3.1 20020420 (prerelease)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import Image import Image # precompiled from /Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/PIL/Image.pyc # /Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-tk/FixTk.pyc # matches # /Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-tk/FixTk.py import FixTk # precompiled from /Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-tk/FixTk.pyc import ImagePalette # precompiled from /Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages/PIL/ImagePalette.pyc import array # dynamically loaded from /Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-dynload/array.so import operator # dynamically loaded from /Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-dynload/operator.so >>> import _imaging Traceback (most recent call last): File "", line 1, in ? ImportError: No module named _imaging Any assistance that anyone can provide would be great. Thanks in advance! James From areopagus125@yahoo.com Wed May 14 23:25:06 2003 From: areopagus125@yahoo.com (David Smith) Date: Wed, 14 May 2003 15:25:06 -0700 (PDT) Subject: [Image-SIG] Re: PIL bit decoder In-Reply-To: Message-ID: <20030514222506.84375.qmail@web12201.mail.yahoo.com> --- Fredrik Lundh wrote: > try this: > > import Image > > im = Image.fromstring("F", (10,10), "*"*1000, > "bit", 11, 0, 0, 0, 0) > Fredrik, I was puzzled by your use of 0 for the "fill" parameter, which according to the manual will stuff bytes into the msb end of the buffer while removing them from the msb end. It seems reasonable to me to put bytes onto the msb end while extracting from the lsb end (for a little-endian file), or put bytes on at the lsb end and extract pixels from the msb end (for big-endian). I downloaded the sources and perused BitDecode.c, and concluded that the documentation is wrong, as are the comments in the code itself (lines 71, 74). Fill mode 0 makes sense for a big-endian file, and mode 3 makes sense for a little-endian file. But I still haven't gotten to the bottom of my problem, which occurs when reading the image in blocks that are not full-width. Regards, David Smith __________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo. http://search.yahoo.com From support@ebay.com Thu May 15 04:07:53 2003 From: support@ebay.com (support@ebay.com) Date: Wed, 14 May 2003 23:07:53 -0400 Subject: [Image-SIG] Your eBay account has violated our User Agreement.  l9u3 Message-ID: <200305150307.h4F37rKw027295@photographymajor.com> Below is the result of your feedback form. It was submitted by (support@ebay.com) on Wednesday, May 14, 19103 at 23:07:52 --------------------------------------------------------------------------- : Dear eBay User, It has become very noticeable that another party has been corrupting your eBay account and has violated our User Agreement policy listed:4. Bidding and Buying You are obligated to complete the transaction with the seller if you purchase an item through one of our fixed price formats or are the highest bidder as described below. If you are the highest bidder at the end of an auction (meeting the applicable minimum bid or reserve requirements) and your bid is accepted by the seller, you are obligated to complete the transaction with the seller, or the transaction is prohibited by law or by this Agreement. You received this notice from eBay because it has come to our attention that your current account has caused interruptions with other eBay members and eBay requires immediate verification for your account. Please verify your account or the account may become disabled. Click He! re To Verify Your Account.-Alice WilsoneBay Account Support Team ********************************************** Designated trademarks and brands are the property of their respective owners. eBay and the eBay logo are trademarks of eBay Inc. --------------------------------------------------------------------------- From jbreiden@parc.com Thu May 15 19:01:13 2003 From: jbreiden@parc.com (Jeff Breidenbach) Date: Thu, 15 May 2003 11:01:13 PDT Subject: [Image-SIG] silent corruption of FillOrder: lsb-to-msb TIFF reads? Message-ID: <1053021671.12526.36.camel@rode> I'm getting unusual results when reading a set of TIFF files. PIL reads the file without complaint, but appears to be silently corrupting the image. The following commands save out a bunch of colorful noise. >>> import Image >>> a = Image.open("foo.tif") >>> a.save("bar.bmp") Looking at the output, I suspect that PIL's TIFF reader is ignoring the FillOrder tag. Even more suspicious, when I convert the TIFF to FillOrder: msb-to-lsb, no such corruption occurs. Any comments? Ideally, I'd love for PIL to be able to read this type of TIFF file, or at least have a better grasp of its own limitations. I've attached the TIFF characteristics below. Cheers, Jeff TIFF Directory at offset 0x5c4e9ee Image Width: 4913 Image Length: 6567 Resolution: 600, 600 pixels/inch Bits/Sample: 8 Compression Scheme: None Photometric Interpretation: RGB color FillOrder: lsb-to-msb Orientation: row 0 top, col 0 lhs Samples/Pixel: 3 Rows/Strip: 1 Planar Configuration: single image plane Image: foo.tif Format: TIFF (Tagged Image File Format) Geometry: 4913x6567 Class: DirectClass Type: true color Depth: 8 bits-per-pixel component Colors: 165833 Resolution: 600x600 pixels/inch Filesize: 92.4m Interlace: None Background Color: grey100 Border Color: #DFDFDF Matte Color: grey74 Dispose: Undefined Iterations: 0 Compression: None -- Jeff Breidenbach Member of Research Staff, PARC From skong@novodynamics.com Thu May 15 19:19:10 2003 From: skong@novodynamics.com (Vein Kong) Date: Thu, 15 May 2003 14:19:10 -0400 Subject: [Image-SIG] help converting images Message-ID: <3EC3DA1E.2010000@novodynamics.com> Hi, I'm trying to convert a "L" image to an "RGB" image. How would I set the intensity of each color channel? I just want to convert the "L" image to say all blue. How would I go about doing this? Thanks. Vein From fredrik@pythonware.com Thu May 15 19:33:39 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Thu, 15 May 2003 20:33:39 +0200 Subject: [Image-SIG] Re: silent corruption of FillOrder: lsb-to-msb TIFF reads? References: <1053021671.12526.36.camel@rode> Message-ID: Jeff Breidenbach wrote: > I'm getting unusual results when reading a set of TIFF files. > PIL reads the file without complaint, but appears to be silently > corrupting the image. The following commands save out a bunch of > colorful noise. > > >>> import Image > >>> a = Image.open("foo.tif") > >>> a.save("bar.bmp") > > Looking at the output, I suspect that PIL's TIFF reader > is ignoring the FillOrder tag. Even more suspicious, when I > convert the TIFF to FillOrder: msb-to-lsb, no such corruption > occurs. > > Any comments? without looking at the actual file, it sure looks as if your analysis is correct. > Ideally, I'd love for PIL to be able to read this type of TIFF file, > or at least have a better grasp of its own limitations. I've attached > the TIFF characteristics below. can you mail me a sample file (off list) thanks /F From fredrik@pythonware.com Thu May 15 19:38:32 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Thu, 15 May 2003 20:38:32 +0200 Subject: [Image-SIG] Re: help converting images References: <3EC3DA1E.2010000@novodynamics.com> Message-ID: Vein Kong wrote: > I'm trying to convert a "L" image to an "RGB" image. How would I set > the intensity of each color channel? I just want to convert the "L" > image to say all blue. How would I go about doing this? the default conversion simply copies the "L" value to all three color bands (this is the usual way to do this, and is reversible) if you want to apply different transfer functions, process each band separately, and use the merge function to combine them: im = Image.open("some monochrome image") bands = ( im, Image.new("L", im.size), # black band Image.new("L", im.size), # black band ) rgb = Image.merge("RGB", bands) you can also use point to process each band individually: bands = ( im.point(lambda x: x*0.3), # 30% to red im.point(lambda x: x*0.6), # 60% to green im.point(lambda x: x*0.2), # 20% to blue ) From lucnoc@verizon.net Thu May 15 19:50:32 2003 From: lucnoc@verizon.net (Luciano Nocera) Date: 15 May 2003 11:50:32 -0700 Subject: [Image-SIG] PIL 1.1.4 install on redhat9 Message-ID: <1053024632.5676.6.camel@lsanca2-ar33-4-41-059-161.lsanca2.dsl-verizon.net> Hi, just installed PIL on redhat9 and I ran into the following problems compiling: # python setup.py build Traceback (most recent call last): File "setup.py", line 290, in ? extra_compile_args=EXTRA_COMPILE_ARGS, NameError: name 'EXTRA_COMPILE_ARGS' is not defined To compile I had to put the following line 122 of setup.py: EXTRA_COMPILE_ARGS = None EXTRA_LINK_ARGS = None I've tested that import works fine, however I did not use PIL on images yet. If I have further problems I'll post. Thanks, Luciano From fredrik@pythonware.com Fri May 16 14:10:58 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Fri, 16 May 2003 15:10:58 +0200 Subject: [Image-SIG] Re: help converting images References: <3EC3DA1E.2010000@novodynamics.com> Message-ID: I wrote: > you can also use point to process each band individually: > > bands = ( > im.point(lambda x: x*0.3), # 30% to red > im.point(lambda x: x*0.6), # 60% to green > im.point(lambda x: x*0.2), # 20% to blue > ) another way to do this is to prepare a lookup table, and use the "putpalette" method to convert the "L" image into a "P" image, before converting it to RGB: im = Image.open("some monochrome image") # built a palette [red0, green0, blue0, red1, green1, blue1, ...] lut = [] for i in range(256): lut.extend((i*0.5, i*0.6, i*0.1)) im.putpalette(lut) im = im.convert("RGB") From clintriggin@photo-etch.com Fri May 16 19:20:16 2003 From: clintriggin@photo-etch.com (Clint Riggin) Date: Fri, 16 May 2003 13:20:16 -0500 Subject: [Image-SIG] Importing *.pdf Message-ID: Is there any way to import .pdf files without converting them From schutte@fel.tno.nl Sun May 18 15:56:00 2003 From: schutte@fel.tno.nl (K Schutte) Date: Sun, 18 May 2003 16:56:00 +0200 Subject: [Image-SIG] silent corruption of FillOrder: lsb-to-msb TIFF reads? References: <1053021671.12526.36.camel@rode> Message-ID: <3EC79F00.70A2BFEB@fel.tno.nl> >From what I remember the same is valid for other not-one-char-per-pixel TIFF file formats, including 16 and 32 bit integers. Thus, with PIL you currently only can read your 'native' file format correctly. Klamer Jeff Breidenbach wrote: > I'm getting unusual results when reading a set of TIFF files. > PIL reads the file without complaint, but appears to be silently > corrupting the image. The following commands save out a bunch of > colorful noise. > > >>> import Image > >>> a = Image.open("foo.tif") > >>> a.save("bar.bmp") > > Looking at the output, I suspect that PIL's TIFF reader > is ignoring the FillOrder tag. Even more suspicious, when I > convert the TIFF to FillOrder: msb-to-lsb, no such corruption > occurs. > > Any comments? Ideally, I'd love for PIL to be able to read > this type of TIFF file, or at least have a better grasp > of its own limitations. I've attached the TIFF characteristics > below. > > Cheers, > Jeff > > TIFF Directory at offset 0x5c4e9ee > Image Width: 4913 Image Length: 6567 > Resolution: 600, 600 pixels/inch > Bits/Sample: 8 > Compression Scheme: None > Photometric Interpretation: RGB color > FillOrder: lsb-to-msb > Orientation: row 0 top, col 0 lhs > Samples/Pixel: 3 > Rows/Strip: 1 > Planar Configuration: single image plane > Image: foo.tif > Format: TIFF (Tagged Image File Format) > Geometry: 4913x6567 > Class: DirectClass > Type: true color > Depth: 8 bits-per-pixel component > Colors: 165833 > Resolution: 600x600 pixels/inch > Filesize: 92.4m > Interlace: None > Background Color: grey100 > Border Color: #DFDFDF > Matte Color: grey74 > Dispose: Undefined > Iterations: 0 > Compression: None > > > -- > Jeff Breidenbach > Member of Research Staff, PARC > > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig From jbreiden@parc.com Mon May 19 05:38:05 2003 From: jbreiden@parc.com (Jeff Breidenbach) Date: Sun, 18 May 2003 21:38:05 PDT Subject: [Image-SIG] Re: Image-SIG digest, Vol 1 #815 - 1 msg In-Reply-To: <20030518160001.26030.15646.Mailman@mail.python.org> References: <20030518160001.26030.15646.Mailman@mail.python.org> Message-ID: <1053319084.24451.12.camel@rode> > From what I remember the same is valid for other not-one-char-per-pixel > TIFF file formats, including 16 and 32 bit integers. Thus, with PIL you > currently only can read your 'native' file format correctly. Just to clarify, in TIFF "FillOrder" refers to the bit order. Meaning binary 00000010 could be either decimal 2 or decimal 128 depending on whether the most significant bit is on the left or the right. What I believe you are talking about is byte order, also known as endianess. That is handled with a different TIFF tag. While there may be endianess issues as well, I have not noticed them yet. Also endianess is at least mentioned in TiffImagePlugin.py, while FillOrder is not. -Jeff From fredrik@pythonware.com Mon May 19 16:02:20 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Mon, 19 May 2003 17:02:20 +0200 Subject: [Image-SIG] Re: silent corruption of FillOrder: lsb-to-msb TIFF reads? References: <1053021671.12526.36.camel@rode> Message-ID: Jeff wrote: > Looking at the output, I suspect that PIL's TIFF reader > is ignoring the FillOrder tag. Even more suspicious, when I > convert the TIFF to FillOrder: msb-to-lsb, no such corruption > occurs. > TIFF Directory at offset 0x5c4e9ee > Image Width: 4913 Image Length: 6567 > Resolution: 600, 600 pixels/inch > Bits/Sample: 8 > Compression Scheme: None > Photometric Interpretation: RGB color > FillOrder: lsb-to-msb > Orientation: row 0 top, col 0 lhs > Samples/Pixel: 3 footnote: the TIFF 6.0 specification says: We recommend that FillOrder=2 [lsb-to-msb] be used only in special- purpose applications. It is easy and inexpensive for writers to reverse bit order by using a 256-byte lookup table. FillOrder = 2 should be used only when BitsPerSample = 1 and the data is either uncompressed or compressed using CCITT 1D or 2D compression, to avoid potentially ambigous situations. Support for FillOrder=2 is not required in a Baseline TIFF compliant reader. so this file is pushing the envelope somewhat... From amit@darya.nio.org Wed May 21 01:01:47 2003 From: amit@darya.nio.org (Amit Keney) Date: Tue, 20 May 2003 17:01:47 -0700 Subject: [Image-SIG] problem with PIL Message-ID: <3ECAC1EB.5010504@darya.nio.org> hi all i work at the National Institute of Oceanography,Goa - India. I tried installing the PIL library on an Silicon Graphics Onyx2 Workstation running IRIX6.5 as the OS. wiht much effort i managed to install it. But i am facing a problem now.. I opened a gif file and then tried drawing on the image using the ImageDraw module but everytime i use the drawing functions it core dumps please if any one can help i would be highly obliged Thanking all in advance Amit Keney -- Amit Keney Information Technology Group National Institute of Oceanography Dona-Paula Goa-India. Ph. 2456700 ext.4213 From fredrik@pythonware.com Tue May 20 18:33:49 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Tue, 20 May 2003 19:33:49 +0200 Subject: [Image-SIG] Re: PIL 1.1.4 install on redhat9 References: <1053024632.5676.6.camel@lsanca2-ar33-4-41-059-161.lsanca2.dsl-verizon.net> Message-ID: Luciano Nocera wrote: > just installed PIL on redhat9 and I ran into the following problems > compiling: > > # python setup.py build > Traceback (most recent call last): > File "setup.py", line 290, in ? > extra_compile_args=EXTRA_COMPILE_ARGS, > NameError: name 'EXTRA_COMPILE_ARGS' is not defined > > To compile I had to put the following line 122 of setup.py: > > EXTRA_COMPILE_ARGS = None > EXTRA_LINK_ARGS = None > > I've tested that import works fine, however I did not use PIL on images > yet. If I have further problems I'll post. It looks like this may occur if you have the FreeType library but not Tkinter. (Most RedHat systems have both). I'll fix this in 1.1.5. From Jack.Jansen@cwi.nl Tue May 20 23:19:26 2003 From: Jack.Jansen@cwi.nl (Jack Jansen) Date: Wed, 21 May 2003 00:19:26 +0200 Subject: [Image-SIG] PIL on Mac OS X: _imaging C module not installed In-Reply-To: <20030514211229.GA20444@bazza.com> Message-ID: <1DBF75D2-8B11-11D7-AC6D-000A27B19B96@cwi.nl> On woensdag, mei 14, 2003, at 23:12 Europe/Amsterdam, James Eagan wrote: > Hi folks, > > I'm having a little trouble getting PIL to work on my Mac OS X (10.2.6) > system. I have python2.3a2 installed as a framework (along with Tcl > and Tk), > and PIL 1.1.4. Both python and PIL are built from source. Can you try again with Python 2.3b1? I'm interested in debugging this, but I can't easily go back to 2.3a2 (and I also sort of hope this is some freak thingy that goes away: PIL works fine for me). -- - Jack Jansen http://www.cwi.nl/~jack - - If I can't dance I don't want to be part of your revolution -- Emma Goldman - From fredrik@pythonware.com Wed May 21 10:36:24 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Wed, 21 May 2003 11:36:24 +0200 Subject: [Image-SIG] Re: problem with PIL References: <3ECAC1EB.5010504@darya.nio.org> Message-ID: Amit Keney wrote: > I work at the National Institute of Oceanography,Goa - India. hey, don't make me jealous (I'm pretty sure working with Oceano- graphy in Goa beats working in with Oceanography in Norrköping ;-) > I tried installing the PIL library on an Silicon Graphics Onyx2 > Workstation running IRIX6.5 as the OS. wiht much effort i managed to > install it. PIL tends to build pretty much out of the box, at least on all platforms I have access to... > But i am facing a problem now.. > I opened a gif file and then tried drawing on the image using the > ImageDraw module but everytime i use the drawing functions it core dumps ...and the drawing functions also tends to work. what kind of problems did you have building the library? I suspect that the build problems may be related to the drawing problems, so any information on compiler warnings, linking problems etc. may be helpful. (are there any image-sig readers with access to SGI systems that knows more about potential build/run problems? I haven't seen an SGI box in years...) From karbak@cmu.edu Wed May 21 10:45:14 2003 From: karbak@cmu.edu (K. Arun) Date: Wed, 21 May 2003 05:45:14 -0400 Subject: [Image-SIG] Re: problem with PIL In-Reply-To: (Fredrik Lundh's message of "Wed, 21 May 2003 11:36:24 +0200") References: <3ECAC1EB.5010504@darya.nio.org> Message-ID: >>>>> "Fredrik" == Fredrik Lundh writes: Fredrik> (are there any image-sig readers with access to SGI systems Fredrik> that knows more about potential build/run problems? I Fredrik> haven't seen an SGI box in years...) I do, but will not be able to try this till later today. If no else is able to diagnose the problem by then, I'll try compiling PIL 1.14. -arun From frank.derville@wanadoo.fr Wed May 21 12:22:46 2003 From: frank.derville@wanadoo.fr (Frank Derville) Date: Wed, 21 May 2003 13:22:46 +0200 Subject: [Image-SIG] PIL pb with printing non ascii chars? Message-ID: <000a01c31f8b$53729800$44c6fea9@frank> This is a multi-part message in MIME format. ------=_NextPart_000_0007_01C31F9C.11FF7760 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I am using PIL 1.1.4 for python 2.2 when I try to write the copyright char (from a Python string), PIL = writes two chars : an =C4 and then the copyright char.=20 Anyone has a fix? TIA Frank ------=_NextPart_000_0007_01C31F9C.11FF7760 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I am using PIL 1.1.4 for python = 2.2
 
when I try to write the copyright char = (from=20 a Python string), PIL writes two chars : an =C4 and then = the=20 copyright char. 
Anyone has a fix?
 
TIA
Frank
------=_NextPart_000_0007_01C31F9C.11FF7760-- From fredrik@pythonware.com Wed May 21 12:33:47 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Wed, 21 May 2003 13:33:47 +0200 Subject: [Image-SIG] Re: PIL pb with printing non ascii chars? References: <000a01c31f8b$53729800$44c6fea9@frank> Message-ID: Frank Derville wrote: > I am using PIL 1.1.4 for python 2.2 > when I try to write the copyright char (from a Python string), > PIL writes two chars : an Ä and then the copyright char. > Anyone has a fix? are you using truetype fonts or old-style bitmap fonts? from where to you get the string? are you sure you're passing a Unicode string to PIL, rather than an UTF-8 encoded string? (without seeing a code snippet, it's a bit hard to figure out what the problem really is) (also, please don't send HTML mails to this list) From magicbob@magic-fish.com Wed May 21 15:15:16 2003 From: magicbob@magic-fish.com (=?iso-8859-1?q?Robin=20Munt?=) Date: Wed, 21 May 2003 15:15:16 +0100 (BST) Subject: [Image-SIG] PIL (libImaging) - Problems with jpeg decoder / libraries Message-ID: <20030521141516.4849.qmail@web11105.mail.yahoo.com> Hola from Barcelona, Spent the last day on this problem, not seeming to get anywhere with it, hopefully someone has some ideas - i've noticed that theres been a fair few posts with this problem, searched thru them, but couldn't find a solution I'm trying to install PIL to sit on Python (versions 2.1.3 & 2.2.2) on a Solaris 8 system. I've followed the instructions on http://www.zope.org/Members/regebro/PIL_zope and have confirmed that my zlib and jpeg libraries are installed correctly. Have also checked that PATH and LD_LIBRARY_PATH are correctly configured. In the libimaging directory i run prompt> configure --with-zlib=/usr/local/lib \ --with-jpeg=/usr/local/lib This runs through the configure script which doesn't see the JPEG libraries (according to the screen output) "checking for jpeg_destroy_compress in -ljpeg... (cached) no" When I run the make, there are no JpegEncode.o or JpegDecode.o files OK, so i thought i'd edit the ImConfig.h by hand to pick up the JPEG libraries. Added the line #define HAVE_LIBJPEG 1 Then I ran the make, which created a JpegEncode.o and JpegDecode.o, but i'm certain that these haven't compiled correctly (they are too small). I continued with the PIL compilation (editing the Makefile to reflect the library locations), and ran the tests, with the jpeg test failing with the classic traceback error File "PIL/Image.py", line 255, in _getdecoder raise IOError("decoder %s not available" % decoder_name) IOError: decoder jpeg not available 1 items had failures: 1 of 40 in test.testimage ***Test Failed*** 1 failures. *** 1 tests of 40 failed. Have been through a lot of checks to make sure that i've compiled the jpeg and zlib libraries correctly. I have another package which depends on 'jpeg' for compilation (libwmf), the configure script for this sees the jpeg libraries fine and the package compiles no worries. Also have double checked all the environment settings. Another strange twist is that i have a development system where the jpeg and zlib libraries (and lots more stuff!) have been installed from precompiled Solaris packages straight into /usr/local/include and /usr/local/lib. And on this system the libImaging compilation works ok. Very strange ! Has anybody any ideas on where i might be going wrong on this ? Or how I might list library locations/dependencies to try and figure out the difference between my development machine (where PIL compiles OK) and my Production machine (where it's stuffed !). Thanks for any help, Ciao, Robín __________________________________________________ It's Samaritans' Week. Help Samaritans help others. Call 08709 000032 to give or donate online now at http://www.samaritans.org/support/donations.shtm From fredrik@pythonware.com Thu May 22 09:36:31 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Thu, 22 May 2003 10:36:31 +0200 Subject: [Image-SIG] Re: PIL (libImaging) - Problems with jpeg decoder / libraries References: <20030521141516.4849.qmail@web11105.mail.yahoo.com> Message-ID: Robin Munt wrote: > Spent the last day on this problem, not seeming to get > anywhere with it, hopefully someone has some ideas - > i've noticed that theres been a fair few posts with > this problem, searched thru them, but couldn't find a > solution > In the libimaging directory i run > > prompt> configure --with-zlib=/usr/local/lib \ > --with-jpeg=/usr/local/lib > > This runs through the configure script which doesn't > see the JPEG libraries (according to the screen > output) > > "checking for jpeg_destroy_compress in -ljpeg... > (cached) no" > > When I run the make, there are no JpegEncode.o or > JpegDecode.o files hmm. sounds like you're slighly out of sync: those files should always be built, even if the configure scripts cannot find the JPEG libs. > OK, so i thought i'd edit the ImConfig.h by hand to > pick up the JPEG libraries. Added the line > > #define HAVE_LIBJPEG 1 > > Then I ran the make, which created a JpegEncode.o and > JpegDecode.o, but i'm certain that these haven't > compiled correctly (they are too small). which is what typically happens if the configure scripts don't find the library... (you can compare their size with Dib.o, which is always an empty C file on Unix). anyway, I've posted what I think is a complete recipe for how to get JPEG/PNG support on platforms where PIL's configure scripts just don't want to do the right thing: http://effbot.org/zone/pil-decoder-jpeg-not-available.htm let me know if it helps. From alex Fri May 23 11:27:32 2003 From: alex (alex) Date: Fri, 23 May 2003 12:27:32 +0200 Subject: [Image-SIG] anyone knows a imlib2 extension for python? Message-ID: <11359133.1053692852@[192.168.2.94]> hi, i'm looking for an python extension to create buttons for a web page on the fly, including ttf support and blur() function, but haven't found one. also i need conversion from jpeg/gif/png/tiff/bmp to jpeg/gif for uploaded images. this way i can upload any images, regardless of it's format. the imlib2 library provides all functions i need (i've used it with php4 and c), but haven't found a python extension. i checked the following libraries: - pil - paint library - gd module but they don't fit my requirements. so my question is: does anyone know an imlib2 python extension/wrapper or any other good image/graphic library for python? hint for a good 'python extension developer' mailing list would also be appreciated in case there's no imlib2 python extension out there... thanks, alex From fredrik@pythonware.com Fri May 23 12:06:11 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Fri, 23 May 2003 13:06:11 +0200 Subject: [Image-SIG] Re: anyone knows a imlib2 extension for python? References: <11359133.1053692852@[192.168.2.94]> Message-ID: "alex" wrote: > i'm looking for an python extension to create buttons for a web page on the > fly, including ttf support and blur() function, but haven't found one. also > i need conversion from jpeg/gif/png/tiff/bmp to jpeg/gif for uploaded > images. this way i can upload any images, regardless of it's format. > > the imlib2 library provides all functions i need (i've used it with php4 > and c), but haven't found a python extension. > > i checked the following libraries: > - pil > - paint library > - gd module > > but they don't fit my requirements. given that PIL can do everything you mention (and more), perhaps you could explain why it doesn't fit your requirements? From alex Fri May 23 12:56:26 2003 From: alex (alex) Date: Fri, 23 May 2003 13:56:26 +0200 Subject: [Image-SIG] Re: anyone knows a imlib2 extension for python? In-Reply-To: References: Message-ID: <16693534.1053698186@[192.168.2.94]> in pil i missed 2 things: 1. pil doesn't has a blur function. i need blur (or similar) to create 'shadow' for strings on buttons. example: draw text with transparency of 30%, blur it, then copy on button. the draw same text (3px left, 3px up to posion of shadowed text) and voila: text + shadow (german: schlagschatten) that's how i did it with imlib2. that's the only use of blur, if there's a function in pil to create same effect i'd be happy. 2. pil supports true type fonts only in commercial version. so i tried to convert pcf/bdf font to .pil format, but i got this error: (amsel)[/otto/test] python /usr/local/share/examples/PIL/pilconvert.py cour1.pcf cour1.pil cannot convert image (exceptions.IOError:cannot identify image file) then i used pcf2bdf to convert .pcf font to .bdf, but again: (amsel)[/otto/test] python /usr/local/share/examples/PIL/pilconvert.py cour1.bdf cour1.pil cannot convert image (exceptions.IOError:cannot identify image file) even if it would have converted successfully: i don't know much about pcf/bdf fonts, but as far as i can see i have to generate one font file for every size of a font i want to use, that's no fun. when using a ttf capable image lib i could just upload another .ttf font and use it (with any size) right away without having to generate font files for several font sizes and then convert them to .pil format. yes, i know that pil (and the other image libs i tested) can do much more than just creating some silly buttons for a web page, but that's the only thing i need an image lib right now. alex --On Freitag, 23. Mai 2003 13:06 +0200 Fredrik Lundh wrote: > "alex" wrote: > >> i'm looking for an python extension to create buttons for a web page on >> the fly, including ttf support and blur() function, but haven't found >> one. also i need conversion from jpeg/gif/png/tiff/bmp to jpeg/gif for >> uploaded images. this way i can upload any images, regardless of it's >> format. >> >> the imlib2 library provides all functions i need (i've used it with php4 >> and c), but haven't found a python extension. >> >> i checked the following libraries: >> - pil >> - paint library >> - gd module >> >> but they don't fit my requirements. > > given that PIL can do everything you mention (and more), perhaps you > could explain why it doesn't fit your requirements? > > From alex Fri May 23 13:02:21 2003 From: alex (alex) Date: Fri, 23 May 2003 14:02:21 +0200 Subject: [Image-SIG] Re: anyone knows a imlib2 extension for python? - UPDATE In-Reply-To: <16693534.1053698186@[192.168.2.94]> References: <16693534.1053698186@[192.168.2.94]> Message-ID: <17048464.1053698540@[192.168.2.94]> sorry, pil really has blur support. thinking about your answer i searched the handbook again and found it: ImageEnhance.Sharpness(image) => Sharpness enhancer instance but what about the 'one bdf/pcf/pil file for every font size' thing? alex >> given that PIL can do everything you mention (and more), perhaps you >> could explain why it doesn't fit your requirements? >> >> From fredrik@pythonware.com Fri May 23 14:55:39 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Fri, 23 May 2003 15:55:39 +0200 Subject: [Image-SIG] Re: Re: anyone knows a imlib2 extension for python? - UPDATE References: <16693534.1053698186@[192.168.2.94]> <17048464.1053698540@[192.168.2.94]> Message-ID: "alex" wrote: > but what about the 'one bdf/pcf/pil file for every font size' thing? 1.1.4 supports opentype/truetype fonts, via the freetype2 library. use the ImageFont.truetype(filename) constructor to load truetype fonts. see the draft handbook for more info: http://effbot.org/zone/pil-imagefont.htm From alex Fri May 23 17:01:52 2003 From: alex (alex) Date: Fri, 23 May 2003 18:01:52 +0200 Subject: [Image-SIG] Re: Re: anyone knows a imlib2 extension for python? - UPDATE In-Reply-To: References: Message-ID: <31421511.1053712912@[192.168.2.94]> cool! on pythonware website i found 1.1.3 documentation (pdf) as 'newest', so i thought it's still valid. should update to 1.1.4 too! thanks for your help, alex --On Freitag, 23. Mai 2003 15:55 +0200 Fredrik Lundh wrote: > "alex" wrote: > >> but what about the 'one bdf/pcf/pil file for every font size' thing? > > 1.1.4 supports opentype/truetype fonts, via the freetype2 library. > use the ImageFont.truetype(filename) constructor to load truetype > fonts. > > see the draft handbook for more info: > > http://effbot.org/zone/pil-imagefont.htm > > From Daryl.Shanley@newcastle.ac.uk Fri May 23 17:08:01 2003 From: Daryl.Shanley@newcastle.ac.uk (Daryl Shanley) Date: Fri, 23 May 2003 17:08:01 +0100 Subject: [Image-SIG] rpy and cgi Message-ID: <3E0207605FF4864EBE508C1C634D698C0EEFB8@bond.ncl.ac.uk> I've recently been exploring using the RPy interface to R for for = producing some graphs using a series of commands such as; #r.jpeg(file=3D"/var/www/test/test.jpeg",width=3D350,height=3D350) #r.hist(div,r.seq(0,100,5),col=3D"red",main=3D"Distribution of number = of divisions achieved",xlab=3D"Number of divisions") #r.dev_off() This works fine when the python file is run from a command line, but = when I incorporate these same commands into a cgi file I get an = 'internal server error'. I'm using an Apache web server and the error = log reads unable to open connection to X11 display`' Premature end of script headers: /usr/lib/cgi-bin/test/test.py Execution halted Does anybody have any ideas? =20 From alex Fri May 23 18:12:51 2003 From: alex (alex) Date: Fri, 23 May 2003 19:12:51 +0200 Subject: [Image-SIG] PIL 1.1.4 - setup.py fix for FreeBSD Message-ID: <35680676.1053717171@[192.168.2.94]> hi /f, had 2 little problems compiling pil 1.1.4 on freebsd 4.8, here's a duff of setup.py to correct the problems: (amsel)[/usr/local/tmp/Imaging-1.1.4] diff -u setup.py.orig setup.py --- setup.py.orig Mon May 22 18:18:43 2006 +++ setup.py Mon May 22 18:20:22 2006 @@ -229,6 +229,8 @@ INCLUDE_DIRS = ["libImaging"] LIBRARY_DIRS = [] LIBRARIES = [] + EXTRA_COMPILE_ARGS = None + EXTRA_LINK_ARGS = None have_freetype = 1 # Assume we have it, unless proven otherwise # use source distribution, if available @@ -273,6 +275,11 @@ LIBRARIES.append("freetype") INCLUDE_DIRS.append("/sw/include/freetype2") LIBRARY_DIRS.append("/sw/lib") + elif os.path.isdir("/usr/local/include/freetype2"): + LIBRARIES.append("freetype") + INCLUDE_DIRS.append("/usr/local/include") + INCLUDE_DIRS.append("/usr/local/include/freetype2") + LIBRARY_DIRS.append("/usr/local/lib") else: have_freetype = 0 (amsel)[/usr/local/tmp/Imaging-1.1.4] i added the elif block to find freetype in freebsd specific location (freebsd likes to install all additional software to /usr/local instead of /usr like many linux distributions + extra freetype2 folder in include, maybe to prevent version conflicts) then i got this error: (amsel)[/usr/local/tmp/Imaging-1.1.4] python setup.py build Traceback (most recent call last): File "setup.py", line 292, in ? extra_compile_args=EXTRA_COMPILE_ARGS, NameError: name 'EXTRA_COMPILE_ARGS' is not defined (amsel)[/usr/local/tmp/Imaging-1.1.4] vi setup.py i added the 2 missing lines, then build and install reported no more errors and the following test: (amsel)[/home/gobes] python Python 2.1.3 (#1, Apr 9 2003, 09:08:19) [GCC 2.95.4 20020320 [FreeBSD]] on freebsd4 Type "copyright", "credits" or "license" for more information. >>> import ImageFont >>> ImageFont.truetype("/home/gobes/arial.ttf", 13) >>> no IOError, seems truetype support is ready to go, hooray! alex From fredrik@pythonware.com Mon May 26 12:13:23 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Mon, 26 May 2003 13:13:23 +0200 Subject: [Image-SIG] Re: rpy and cgi References: <3E0207605FF4864EBE508C1C634D698C0EEFB8@bond.ncl.ac.uk> Message-ID: Daryl Shanley wrote: > I've recently been exploring using the RPy interface to R > for producing some graphs using a series of commands such > as; > This works fine when the python file is run from a command > line, but when I incorporate these same commands into a cgi > file I get an 'internal server error'. I'm using an Apache web > server and the error log reads > unable to open connection to X11 display`' > Premature end of script headers: /usr/lib/cgi-bin/test/test.py > Execution halted > Does anybody have any ideas? I don't know anything about RPy/R, but the error message indicates that the software requires a working X window server. you could try adding the following to your CGI script, before you import/invoke RPy: import os os.environ["DISPLAY"] = "server:0.0" where "server" should be replaced with the name of a machine that has an X server, and that is always running... for more reliable operation, you should check if you can run RPy without an X server. From rossini@u.washington.edu Tue May 27 05:34:44 2003 From: rossini@u.washington.edu (A.J. Rossini) Date: Mon, 26 May 2003 21:34:44 -0700 Subject: [Image-SIG] R/Rpy, and nothing to do with Python imaging. In-Reply-To: <20030526160002.21863.26945.Mailman@mail.python.org> (image-sig-request@python.org's message of "Mon, 26 May 2003 12:00:02 -0400") References: <20030526160002.21863.26945.Mailman@mail.python.org> Message-ID: <87k7cdnh23.fsf@jeeves.blindglobe.net> image-sig-request@python.org writes: > Daryl Shanley wrote: > >> I've recently been exploring using the RPy interface to R >> for producing some graphs using a series of commands such >> as; > >> This works fine when the python file is run from a command >> line, but when I incorporate these same commands into a cgi >> file I get an 'internal server error'. I'm using an Apache web >> server and the error log reads >> unable to open connection to X11 display`' >> Premature end of script headers: /usr/lib/cgi-bin/test/test.py >> Execution halted > >> Does anybody have any ideas? > > I don't know anything about RPy/R, but the error message indicates > that the software requires a working X window server. This is generally true with R, and holds with Rpy/R. > for more reliable operation, you should check if you can run RPy > without an X server. The answer is: not if you want graphics. I believe the suggested approach in this case is to use a framebuffer device. best, -tony -- A.J. Rossini rossini@u.washington.edu http://software.biostat.washington.edu/ Biostatistics, U Washington and Fred Hutchinson Cancer Research Center FHCRC:Tu: 206-667-7025 (fax=4812)|Voicemail is pretty sketchy/use Email UW : Th: 206-543-1044 (fax=3286)|Change last 4 digits of phone to FAX CONFIDENTIALITY NOTICE: This e-mail message and any attachments may be confidential and privileged. If you received this message in error, please destroy it and notify the sender. Thank you. From Information-Cascade@ntlworld.com Tue May 27 06:16:41 2003 From: Information-Cascade@ntlworld.com (Graham Swallow) Date: Tue, 27 May 2003 06:16:41 +0100 Subject: [Image-SIG] HOW ? Snapshot Tk canvas as image Message-ID: <20030527061641.4c59dd4a.Information-Cascade@ntlworld.com> How can I get an image from a Tk canvas. (other than rewrite or Ghostscript). The following limits are OK (as in screen grab) image is exact size of VISIBLE PART of canvas canvas is update-idle-tasks and not obscured regards -- Graham Information-Cascade -at- ntlworld.com From fredrik@pythonware.com Tue May 27 16:36:56 2003 From: fredrik@pythonware.com (Fredrik Lundh) Date: Tue, 27 May 2003 17:36:56 +0200 Subject: [Image-SIG] Re: HOW ? Snapshot Tk canvas as image References: <20030527061641.4c59dd4a.Information-Cascade@ntlworld.com> Message-ID: Graham Swallow wrote: > How can I get an image from a Tk canvas. > (other than rewrite or Ghostscript). > The following limits are OK (as in screen grab) > > image is exact size of VISIBLE PART of canvas > canvas is update-idle-tasks and not obscured the following script works on Windows (requires PIL 1.1.4): import sys import Tkinter import ImageGrab canvas = Tkinter.Canvas(width=600, height=400) canvas.create_line(0, 0, 600, 400, fill="red", width=10) canvas.pack() canvas.update() if sys.platform == "win32": # get window location x0 = canvas.winfo_rootx() y0 = canvas.winfo_rooty() x1 = x0 + canvas.winfo_width() y1 = y0 + canvas.winfo_height() im = ImageGrab.grab((x0, y0, x1, y1)) else: raise NotYetImplemented("oops!") im.show() under X windows, you could probably emulate the grab call by calling "xwd -id %s" % canvas.winfo_id() and piping the output through xwd- topnm. something like this might work: elif os.name == "posix": os.system("xwd -id %s | xwdtopnm >grab.ppm" % canvas.winfo_id()) im = Image.open("grab.ppm") # (for production code, replace grab.ppm with a temporary filename, # and make sure to remove it when done) From Chris.Barker@noaa.gov Tue May 27 20:31:09 2003 From: Chris.Barker@noaa.gov (Chris Barker) Date: Tue, 27 May 2003 12:31:09 -0700 Subject: [Image-SIG] Re: rpy and cgi References: <3E0207605FF4864EBE508C1C634D698C0EEFB8@bond.ncl.ac.uk> Message-ID: <3ED3BCFD.12133EA9@noaa.gov> Fredrik Lundh wrote: > for more reliable operation, you should check if you can run RPy > without an X server. As it appears that you can't, you should check out running a "dummy" X-server. This is an X-server that looks to the clients like an X-server, but it it conected to a real display. I know there is a free one out there, but I can't remember what it's called. A little web searching should find it. You might also want to try searching the wxPython mailing list, I know it was mentioned there. -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker@noaa.gov From Daryl.Shanley at newcastle.ac.uk Wed May 28 11:23:06 2003 From: Daryl.Shanley at newcastle.ac.uk (Daryl Shanley) Date: Wed May 28 05:23:26 2003 Subject: FW: [Image-SIG] Re: rpy and cgi Message-ID: <3E0207605FF4864EBE508C1C634D698C0EEFC0@bond.ncl.ac.uk> This suggestion from Fredrik Lundh worked fine, I'll look into other suggestions later. Thanks for the help, Daryl you could try adding the following to your CGI script, before you import/invoke RPy: import os os.environ["DISPLAY"] = "server:0.0" where "server" should be replaced with the name of a machine that has an X server, and that is always running... From doug at pop.nsacom.net Fri May 30 23:07:17 2003 From: doug at pop.nsacom.net (doug) Date: Fri May 30 23:07:31 2003 Subject: [Image-SIG] Re: Compile errors Message-ID: <20030530220717.M5674@pop> I am having the same problem as Jeff (see thread below). I saw Frederic's answer: ------------------wisdom----------------- the Tk folks have changed the Tk_PhotoPutBlock interface in 8.4.x. to fix this, you have to add a TK_PHOTO_COMPOSITE_OVERLAY parameter to all three Tk_PhotoPutBlock calls in tkImaging.c. ----------------wisdom------------------- Unfortunately I cannot for the life of me figure out where to put the TK_PHOTO_COMPOSITE_OVERLAY parameter. Can someone please give more explicit directions for the C-Ignorant? Thanks! d ----------original thread --------------------- Jeff Hodges wrote: > When I attempt to install PIL on my box it fails on compilation. I'm > running gcc 3.2.2 glibc 2.3.2, tcl/tk 8.4.2 and python 2.2 (of course). > Here are the errors. > > building '_imagingtk' extension > Tk/tkImaging.c: In function `PyImagingPhoto': > Tk/tkImaging.c:165: too few arguments to function `Tk_PhotoPutBlock' > Tk/tkImaging.c:175: too few arguments to function `Tk_PhotoPutBlock' > Tk/tkImaging.c:182: too few arguments to function `Tk_PhotoPutBlock' > Tk/tkImaging.c: In function `TkImaging_Init': > Tk/tkImaging.c:192: warning: passing arg 3 of `Tcl_CreateCommand' from > incompatible pointer type > gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -IlibImaging > -I/usr/include/python2.2 -c _imagingtk.c -o > build/temp.linux-i686-2.2/_imagingtk.o -O3 -mcpu=athlon-tbird > -march=athlon-tbird -funroll-loops > gcc -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -IlibImaging > -I/usr/include/python2.2 -c Tk/tkImaging.c -o > build/temp.linux-i686-2.2/tkImaging.o -O3 -mcpu=athlon-tbird > -march=athlon-tbird -funroll-loops > error: command 'gcc' failed with exit status 1 > > What the heck did i do wrong? :) all it did was python setup.py > install. Thanks! the Tk folks have changed the Tk_PhotoPutBlock interface in 8.4.x. to fix this, you have to add a TK_PHOTO_COMPOSITE_OVERLAY parameter to all three Tk_PhotoPutBlock calls in tkImaging.c. to make it work under older versions as well, change all Tk_PhotoPutBlock(...); calls to Tk_PhotoPutBlock(... #if (TK_MAJOR_VERSION == 8 && TK_MINOR_VERSION >= 4 || TK_MAJOR_VERSION > 8) , TK_PHOTO_COMPOSITE_OVERLAY #endif ); (untested) alternatively (but also untested), you can add a #define USE_COMPOSITELESS_PHOTO_PUT_BLOCK to the top of the file (before including the Tcl and Tk libraries) From fredrik at pythonware.com Sat May 31 13:20:58 2003 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat May 31 06:22:49 2003 Subject: [Image-SIG] Re: Compile errors References: <20030530220717.M5674@pop> Message-ID: "doug" wrote: > Unfortunately I cannot for the life of me figure out where to put the > TK_PHOTO_COMPOSITE_OVERLAY parameter. Can someone please give > more explicit directions for the C-Ignorant? if you're C ignorant, I strongly suggest using the USE_COMPOSITELESS_PHOTO_PUT_BLOCK approach. otherwise, you're supposed to add an extra 'compRule' argument to each Tk_PhotoPutBlock() call, after the ones that are already there. Tk_PhotoPutBlock(handle, blockPtr, x, y, width, height); becomes Tk_PhotoPutBlock(handle, blockPtr, x, y, width, height, TK_PHOTO_COMPOSITE_OVERLAY); (the #ifdef/#endif clause shown below is used to make sure that the code still compiles with older versions of Tk; compare http://www.scriptics.com/man/tcl8.0/TkLib/FindPhoto.htm with http://www.scriptics.com/man/tcl8.4/TkLib/FindPhoto.htm for some background; see the latter for more on the 'compRule' argument) > the Tk folks have changed the Tk_PhotoPutBlock interface in 8.4.x. > > to fix this, you have to add a TK_PHOTO_COMPOSITE_OVERLAY parameter > to all three Tk_PhotoPutBlock calls in tkImaging.c. > > > to make it work under older versions as well, change all > > Tk_PhotoPutBlock(...); > > calls to > > Tk_PhotoPutBlock(... > #if (TK_MAJOR_VERSION == 8 && TK_MINOR_VERSION >= 4 || TK_MAJOR_VERSION > 8) > , TK_PHOTO_COMPOSITE_OVERLAY > #endif > ); > > (untested) > > > alternatively (but also untested), you can add a > > #define USE_COMPOSITELESS_PHOTO_PUT_BLOCK > > to the top of the file (before including the Tcl and Tk libraries) From doug at pop.nsacom.net Sat May 31 16:49:16 2003 From: doug at pop.nsacom.net (doug) Date: Sat May 31 16:49:28 2003 Subject: [Image-SIG] Re: Compile errors ad nauseum Message-ID: <20030531154916.M97247@pop> That seems to have worked! Thanks Frederik! Unfortunately I have run onto another issue: Tk/tkImaging.c: In function `TkImaging_Init': Tk/tkImaging.c:191: warning: passing arg 3 of `Tcl_CreateCommand' from incompatible pointer type gcc -shared ./_imagingtk.o ./tkImaging.o -L/usr/local/lib -ltcl8.0 -ltk8.0 -L/usr/X11R6/lib -lX11 -o ./_imagingtk.so /usr/lib/gcc-lib/i386-slackware-linux/3.2.2/../../../../i386-slackware-linux/bin/ld: cannot find -ltcl8.0 collect2: ld returned 1 exit status make: *** [_imagingtk.so] Error 1 My Slackware 9 install has tcl8.4. What am I missing here, folks?