From jwt at onjapan.net Tue Feb 1 05:31:53 2005 From: jwt at onjapan.net (Jim Tittsler) Date: Tue Feb 1 05:32:01 2005 Subject: [Image-SIG] Error with PIL on RH-7.3 In-Reply-To: References: Message-ID: <1567895c988946e5e0a607a429c7b3eb@onjapan.net> On Jan 12, 2005, at 06:17, Marc-Elian Begin wrote: > I?m running into the following error running PIL 1.1.4 on Red-Hat 7.3, > trying to ?import _imaging? > > ImportError: /lib/i686/libc.so.6: version `GLIBC_2.3' not found > (required by ./_imaging.so) Did you build PIL on that system? It looks like you are using a version built on a machine with a newer GLIBC. (A normal RH7.3 machine has GLIBC 2.2.) -- Jim Tittsler http://www.OnJapan.net/ GPG: 0x01159DB6 Python Starship http://Starship.Python.net/ Ringo MUG Tokyo http://www.ringo.net/rss.html From olivmartin at gmail.com Tue Feb 1 16:09:00 2005 From: olivmartin at gmail.com (Olivier Martin) Date: Tue Feb 1 16:15:43 2005 Subject: [Image-SIG] Fwd: ImageFilterz... In-Reply-To: <9be90a76050201064610efea2d@mail.gmail.com> References: <9be90a76050201064610efea2d@mail.gmail.com> Message-ID: <9be90a7605020107095061f503@mail.gmail.com> Hi, First to say, i'm very impressed of the performances of the PIL module ImageFilter's results! I've tried combining some filters and the results are quite good !! As it is for research purpose (PhD thesis in facial expression recognition), I'd like to be able to understand what's contained in the functions (how the filters work, what they actually do)... Is there anyway where such information could be found ? (details about the ImageFilter.CONTOUR, ImageFilter.SMOOTH, ImageFilter.FIND_EDGES, etc....). I didn't find it on the web... Thanks in advance, Olivier Martin, Belgian PhD thesis student From ChristianJ at implicitnetworks.com Tue Feb 1 17:07:34 2005 From: ChristianJ at implicitnetworks.com (Christian Jensen) Date: Tue Feb 1 17:07:39 2005 Subject: [Image-SIG] Fwd: ImageFilterz... Message-ID: <148D64496E077C4DAF1FA4BBC6F74DA62F5F8F@corp1.implicit.implicitnetworks.com> You could always look at the source code :) -----Original Message----- From: image-sig-bounces@python.org [mailto:image-sig-bounces@python.org] On Behalf Of Olivier Martin Sent: Tuesday, February 01, 2005 7:09 AM To: image-sig@python.org Subject: [Image-SIG] Fwd: ImageFilterz... Hi, First to say, i'm very impressed of the performances of the PIL module ImageFilter's results! I've tried combining some filters and the results are quite good !! As it is for research purpose (PhD thesis in facial expression recognition), I'd like to be able to understand what's contained in the functions (how the filters work, what they actually do)... Is there anyway where such information could be found ? (details about the ImageFilter.CONTOUR, ImageFilter.SMOOTH, ImageFilter.FIND_EDGES, etc....). I didn't find it on the web... Thanks in advance, Olivier Martin, Belgian PhD thesis student _______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig From thogrom at terra.es Tue Feb 1 18:08:26 2005 From: thogrom at terra.es (THOGROM.terra.es) Date: Tue Feb 1 18:08:52 2005 Subject: [Image-SIG] PIL and gtk.Image Message-ID: <1107277706.4394.1.camel@localhost.localdomain> Hello. I want to show a PIL image in a gtk.Image widget. How can i do it? Thanks -- THOGROM.terra.es From lroubeyrie at limair.asso.fr Fri Feb 4 10:02:31 2005 From: lroubeyrie at limair.asso.fr (Lionel Roubeyrie) Date: Fri Feb 4 10:04:04 2005 Subject: [Image-SIG] animated gif Message-ID: <200502041002.31581.lroubeyrie@limair.asso.fr> Hi all, Is it possible to create an animated gif with PIL? I can't find any documentation about this feature? Thanks Lionel -- Lionel Roubeyrie - lroubeyrie@limair.asso.fr LIMAIR http://www.limair.asso.fr From gohaku at earthlink.net Thu Feb 3 04:45:18 2005 From: gohaku at earthlink.net (gohaku) Date: Sat Feb 5 04:45:27 2005 Subject: [Image-SIG] animated gif Message-ID: Hi Lionel, Although I have not tested gifmaker, it certainly seems like you can create an animated GIF with PIL. You can download gifmaker.py at http://www.bel-epa.com/pyapache/Python/PIL/Imaging-1.1.1/Scripts/ gifmaker.py or http://olympus.het.brown.edu/doc/python-imaging/examples/gifmaker.py and check out the following test script: # import Image # import gifmaker # # sequence = [] # # # generate sequence # for i in range(100): # im = # sequence.append(im) # # # write GIF animation # fp = open("out.gif", "wb") # gifmaker.makedelta(fp, sequence) # fp.close() gohaku > Hi all, > Is it possible to create an animated gif with PIL? I can't find any > documentation about this feature? > Thanks > Lionel From r.oudkerk at tiscali.co.uk Sat Feb 5 23:25:59 2005 From: r.oudkerk at tiscali.co.uk (Richard Oudkerk) Date: Sat Feb 5 23:26:03 2005 Subject: [Image-SIG] buffer overflow in ImagingQuantize() when num cols >256 Message-ID: <420547F7.7080405@tiscali.co.uk> The code import Image im = Image.open("Images/lena.jpg") im = im.quantize(500) causes a buffer overflow (and segfault) in the function ImagingQuantize() (in the file "libImaging/Quant.c") because it tries to copy 500*4 bytes into the palette of a "P" mode image (which only has size 256*4 bytes). Instead an "RGB" mode image should be returned when there are more than 256 colours. The following patch seems to make things work. *** Quant.c Wed Oct 6 09:55:35 2004 --- libImaging/Quant.c Sat Feb 5 20:45:55 2005 *************** *** 1565,1570 **** --- 1565,1583 ---- if (result) { + if (paletteLength > 256) { + imOut = ImagingNew("RGB", im->xsize, im->ysize); + + for (i = y = 0; y < im->ysize; y++) + for (x=0; x < im->xsize; x++) + imOut->image32[y][x] = palette[newData[i++]].v; + + free(newData); + free(palette); + + return imOut; + + } else { imOut = ImagingNew("P", im->xsize, im->ysize); for (i = y = 0; y < im->ysize; y++) *************** *** 1592,1597 **** --- 1605,1612 ---- return imOut; + } + } else { return (Imaging) ImagingError_ValueError("quantization error"); Also in dict ImageColor.colormap the key "lightgrey" appears twice -- the first of these should be spelt with an "a" *** ImageColor.py Sun Dec 12 17:26:52 2004 --- PIL/ImageColor.py Sat Feb 5 19:54:36 2005 *************** *** 184,190 **** "lightcyan": "#e0ffff", "lightgoldenrodyellow": "#fafad2", "lightgreen": "#90ee90", ! "lightgrey": "#d3d3d3", "lightgrey": "#d3d3d3", "lightpink": "#ffb6c1", "lightsalmon": "#ffa07a", --- 184,190 ---- "lightcyan": "#e0ffff", "lightgoldenrodyellow": "#fafad2", "lightgreen": "#90ee90", ! "lightgray": "#d3d3d3", "lightgrey": "#d3d3d3", "lightpink": "#ffb6c1", "lightsalmon": "#ffa07a", From hgerlach at compals.com Sun Feb 6 18:59:21 2005 From: hgerlach at compals.com (Henryk Gerlach) Date: Sun Feb 6 18:59:20 2005 Subject: [Image-SIG] colorshift while converting png to gif Message-ID: <200502061859.21902.hgerlach@compals.com> Hi list, I experience the following problem: I have a small 10x10 Image named 'white.png', which is just a plain white square (generated with GIMP). After I ran this code ================= #Versions of rpm-packages # python-imaging-1.1.4-106 # python-2.3-52 import Image, ImageDraw im = Image.open('white.png') f = open("white-converted.gif","wb") im.save(f, "GIF") f.close() f = open("white-converted.png","wb") im.save(f, "png") f.close() ================== the GIF image is no longer white, but light gray (#fcfcfc) while the png stays white (#ffffff). What am I doing wrong? Is there some way to keep the GIF white? This also happens with more complex pictures. Any ideas? Best regards, Henryk Gerlach From jepler at unpythonic.net Sun Feb 6 21:24:59 2005 From: jepler at unpythonic.net (Jeff Epler) Date: Sun Feb 6 21:25:01 2005 Subject: [Image-SIG] colorshift while converting png to gif In-Reply-To: <200502061859.21902.hgerlach@compals.com> References: <200502061859.21902.hgerlach@compals.com> Message-ID: <20050206202456.GB16104@unpythonic.net> I get a similar problem with the following complete program: import Image i = Image.fromstring("RGB", (1, 1), chr(255) * 3) j = i.convert("P") print j.getpixel((0,0)) # prints 252, should print 255 This seems to have something to do with converting to a palette image. Jeff -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://mail.python.org/pipermail/image-sig/attachments/20050206/c8b4f1e9/attachment.pgp From gwidion at mpc.com.br Mon Feb 7 01:27:11 2005 From: gwidion at mpc.com.br (Joao S. O. Bueno Calligaris) Date: Mon Feb 7 01:27:41 2005 Subject: [Image-SIG] animated gif In-Reply-To: <200502041002.31581.lroubeyrie@limair.asso.fr> References: <200502041002.31581.lroubeyrie@limair.asso.fr> Message-ID: <200502062227.11663.gwidion@mpc.com.br> On Friday 04 February 2005 07:02, Lionel Roubeyrie wrote: > Hi all, > Is it possible to create an animated gif with PIL? I can't find any > documentation about this feature? Ok ..if no one answered, and there are no docs, I'd say PIL currently does not do anum gif. I do not know what you intend to do, but if you need it, write me (off list), and I can tell you how to do it using Python scripts for the GIMP. Regards, JS -><- If you wi > Thanks > Lionel From jwt at OnJapan.net Mon Feb 7 10:13:47 2005 From: jwt at OnJapan.net (Jim Tittsler) Date: Mon Feb 7 10:13:30 2005 Subject: [Image-SIG] animated gif In-Reply-To: <200502062227.11663.gwidion@mpc.com.br> References: <200502041002.31581.lroubeyrie@limair.asso.fr> <200502062227.11663.gwidion@mpc.com.br> Message-ID: <20050207091347.GE32195@server.onjapan.net> On Sun, Feb 06, 2005 at 10:27:11PM -0200, Joao S. O. Bueno Calligaris wrote: > On Friday 04 February 2005 07:02, Lionel Roubeyrie wrote: > > Is it possible to create an animated gif with PIL? I can't find any > > documentation about this feature? > > Ok ..if no one answered, and there are no docs, I'd say PIL currently > does not do anum gif. An example of how to build animated GIFs is included in the Scripts directory of the PIL distribution: gifmaker.py -- Jim Tittsler http://www.OnJapan.net/ GPG: 0x01159DB6 Python Starship http://Starship.Python.net/ Ringo MUG Tokyo http://www.ringo.net/rss.html From fredrik at pythonware.com Tue Feb 8 17:47:40 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue Feb 8 18:03:59 2005 Subject: [Image-SIG] ANN: PIL 1.1.5 beta 3 (february 8, 2005) Message-ID: PIL 1.1.5 beta 3 (aka rc1) is now available from effbot.org: http://effbot.org/downloads#imaging (look for Imaging-1.1.5b3.tar.gz. no compiled windows versions yet; stay tuned for updates) Visible changes in this release include: + Don't crash in "quantize" method if the number of colors requested is larger than 256. This release raises a ValueError exception; future versions may return a mode "RGB" image instead (reported by Richard Oudkerk). + Added WBMP read/write support (based on code by Duncan Booth). For a list of other changes in 1.1.5, see this page: http://effbot.org/zone/pil-changes-115.htm Report bugs to this list or directly to me, as usual. enjoy /F From fredrik at pythonware.com Tue Feb 8 18:14:58 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue Feb 8 18:22:48 2005 Subject: [Image-SIG] Re: PIL 1.1.5 beta 3 (february 8, 2005) References: Message-ID: > (look for Imaging-1.1.5b3.tar.gz. no compiled windows versions yet; > stay tuned for updates) binaries for 2.1, 2.2, 2.3, and 2.4 are now available from: http://effbot.org/downloads#pil From ChristianJ at implicitnetworks.com Tue Feb 8 18:59:09 2005 From: ChristianJ at implicitnetworks.com (Christian Jensen) Date: Tue Feb 8 18:59:13 2005 Subject: [Image-SIG] ANN: PIL 1.1.5 beta 3 (February 8, 2005) Message-ID: <148D64496E077C4DAF1FA4BBC6F74DA62F60F8@corp1.implicit.implicitnetworks.com> Can you go into more detail about the 16bit changes? Does this mean that I can have a 16bit (565) image now? I have been working on a method to take a PNG (RGBA) and convert it to another RGBA but have the RGB quantized and dithered to 16 bit images. Does this help me any? Do any of you know of an easy way to do this? Thanks! Christian -----Original Message----- From: image-sig-bounces@python.org [mailto:image-sig-bounces@python.org] On Behalf Of Fredrik Lundh Sent: Tuesday, February 08, 2005 8:48 AM To: image-sig@python.org Subject: [Image-SIG] ANN: PIL 1.1.5 beta 3 (february 8, 2005) PIL 1.1.5 beta 3 (aka rc1) is now available from effbot.org: http://effbot.org/downloads#imaging (look for Imaging-1.1.5b3.tar.gz. no compiled windows versions yet; stay tuned for updates) Visible changes in this release include: + Don't crash in "quantize" method if the number of colors requested is larger than 256. This release raises a ValueError exception; future versions may return a mode "RGB" image instead (reported by Richard Oudkerk). + Added WBMP read/write support (based on code by Duncan Booth). For a list of other changes in 1.1.5, see this page: http://effbot.org/zone/pil-changes-115.htm Report bugs to this list or directly to me, as usual. enjoy /F _______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig From fredrik at pythonware.com Tue Feb 8 19:56:20 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue Feb 8 19:56:24 2005 Subject: [Image-SIG] Re: ANN: PIL 1.1.5 beta 3 (February 8, 2005) References: <148D64496E077C4DAF1FA4BBC6F74DA62F60F8@corp1.implicit.implicitnetworks.com> Message-ID: Christian Jensen wrote: > Can you go into more detail about the 16bit changes? what 16-bit changes? if you mean Added limited support for "point" mappings from mode "I" to mode "L". Only 16-bit values are supported (other values are clipped), the lookup table must contain exactly 65536 entries, and the mode argument must be set to "L". it means exactly what it says: you can use point() to convert from "I" to "L", as long as the lookup table contains exactly 65536 entries. the current version of PIL only supports 24-bit RGB. From bob at redivi.com Tue Feb 8 22:02:43 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue Feb 8 22:02:58 2005 Subject: [Image-SIG] ANN: PIL 1.1.5 beta 3 (february 8, 2005) In-Reply-To: References: Message-ID: <88c9cd68cb393836ac12dc917570d142@redivi.com> On Feb 8, 2005, at 11:47, Fredrik Lundh wrote: > PIL 1.1.5 beta 3 (aka rc1) is now available from effbot.org: > > http://effbot.org/downloads#imaging > > (look for Imaging-1.1.5b3.tar.gz. no compiled windows versions yet; > stay tuned for updates) > > Visible changes in this release include: > > + Don't crash in "quantize" method if the number of colors requested > is larger than 256. This release raises a ValueError exception; > future versions may return a mode "RGB" image instead (reported > by Richard Oudkerk). > > + Added WBMP read/write support (based on code by Duncan Booth). > > For a list of other changes in 1.1.5, see this page: > > http://effbot.org/zone/pil-changes-115.htm > > Report bugs to this list or directly to me, as usual. -------------------------------------------------------------------- PIL 1.1.5b3 BUILD SUMMARY -------------------------------------------------------------------- version 1.1.5b3 platform darwin 2.3 (#1, Sep 13 2003, 00:49:11) [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] -------------------------------------------------------------------- --- TKINTER support ok --- JPEG support ok --- ZLIB (PNG/ZIP) support ok --- FREETYPE2 support ok -------------------------------------------------------------------- % python selftest.py ***************************************************************** Failure in example: d.line((0, 0, 128, 128), fill=128) from line #84 of selftest.testimage Exception raised: Traceback (most recent call last): File "./doctest.py", line 499, in _run_examples_inner exec compile(source, "", "single") in globs File "", line 1, in ? File "PIL/ImageDraw.py", line 199, in line self.draw.draw_lines(xy, ink, width) TypeError: function takes exactly 2 arguments (3 given) ***************************************************************** Failure in example: d.line((0, 128, 128, 0), fill=128) from line #85 of selftest.testimage Exception raised: Traceback (most recent call last): File "./doctest.py", line 499, in _run_examples_inner exec compile(source, "", "single") in globs File "", line 1, in ? File "PIL/ImageDraw.py", line 199, in line self.draw.draw_lines(xy, ink, width) TypeError: function takes exactly 2 arguments (3 given) ***************************************************************** Failure in example: im.getextrema() from line #86 of selftest.testimage Expected: (64, 128) Got: (64, 64) 1 items had failures: 3 of 55 in selftest.testimage ***Test Failed*** 3 failures. *** 3 tests of 55 failed. -bob From bob at redivi.com Tue Feb 8 22:17:35 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue Feb 8 22:17:43 2005 Subject: [Image-SIG] PIL 1.1.5b3 installer for Mac OS X 10.3 Message-ID: I've put together a Mac OS X 10.3 binary installer for PIL 1.1.5b3 available here: http://undefined.org/python/Imaging-1.1.5b3-py2.3-macosx10.3.zip Details are here: http://bob.pythonmac.org/archives/2005/02/08/pil-115b3-for-mac-os-x -103/ -bob From fredrik at pythonware.com Tue Feb 8 22:14:48 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue Feb 8 22:30:20 2005 Subject: [Image-SIG] Re: ANN: PIL 1.1.5 beta 3 (february 8, 2005) References: <88c9cd68cb393836ac12dc917570d142@redivi.com> Message-ID: Bob Ippolito wrote: > % python selftest.py > ***************************************************************** > Failure in example: d.line((0, 0, 128, 128), fill=128) > from line #84 of selftest.testimage > Exception raised: > Traceback (most recent call last): > File "./doctest.py", line 499, in _run_examples_inner > exec compile(source, "", "single") in globs > File "", line 1, in ? > File "PIL/ImageDraw.py", line 199, in line > self.draw.draw_lines(xy, ink, width) > TypeError: function takes exactly 2 arguments (3 given) looks like PIL's picking up an old _imaging module. try importing _imaging from the Python prompt, and check what the __file__ attribute points to. From bob at redivi.com Tue Feb 8 22:41:21 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue Feb 8 22:41:38 2005 Subject: [Image-SIG] Re: ANN: PIL 1.1.5 beta 3 (february 8, 2005) In-Reply-To: References: <88c9cd68cb393836ac12dc917570d142@redivi.com> Message-ID: On Feb 8, 2005, at 16:14, Fredrik Lundh wrote: > Bob Ippolito wrote: > >> % python selftest.py >> ***************************************************************** >> Failure in example: d.line((0, 0, 128, 128), fill=128) >> from line #84 of selftest.testimage >> Exception raised: >> Traceback (most recent call last): >> File "./doctest.py", line 499, in _run_examples_inner >> exec compile(source, "", "single") in globs >> File "", line 1, in ? >> File "PIL/ImageDraw.py", line 199, in line >> self.draw.draw_lines(xy, ink, width) >> TypeError: function takes exactly 2 arguments (3 given) > > looks like PIL's picking up an old _imaging module. > > try importing _imaging from the Python prompt, and check what the > __file__ > attribute points to. That fixes it, of course. % python selftest.py 55 tests passed. Most of the projects I deal with will run tests with the build dir in sys.path so that you don't have to install before testing.. It might be better to create a "test" distutils command that runs the test and ensures that a build already happened, we do this for PyObjC. -bob From fredrik at pythonware.com Tue Feb 8 23:05:48 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue Feb 8 23:12:01 2005 Subject: [Image-SIG] Re: PIL 1.1.5b3 installer for Mac OS X 10.3 References: Message-ID: Bob Ippolito wrote: > I've put together a Mac OS X 10.3 binary installer for PIL 1.1.5b3 available here: > http://undefined.org/python/Imaging-1.1.5b3-py2.3-macosx10.3.zip most excellent. thanks! I've included a pointer to your blog entry in the "official" announcement. From fredrik at pythonware.com Tue Feb 8 23:02:56 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue Feb 8 23:33:03 2005 Subject: [Image-SIG] Re: Re: ANN: PIL 1.1.5 beta 3 (february 8, 2005) References: <88c9cd68cb393836ac12dc917570d142@redivi.com> Message-ID: Bob Ippolito wrote: > That fixes it, of course. > > % python selftest.py > 55 tests passed. > > Most of the projects I deal with will run tests with the build dir in sys.path so that you don't > have to install before testing. that's why the README recommends you to do $ python setup.py build_ext -i $ python selftest.py (this builds the extension "in place", so you can test it without having to mess with the path) From bob at redivi.com Tue Feb 8 23:38:15 2005 From: bob at redivi.com (Bob Ippolito) Date: Tue Feb 8 23:38:26 2005 Subject: [Image-SIG] Re: Re: ANN: PIL 1.1.5 beta 3 (february 8, 2005) In-Reply-To: References: <88c9cd68cb393836ac12dc917570d142@redivi.com> Message-ID: <1F2A131A-7A22-11D9-AB52-000A95C93D30@redivi.com> On Feb 8, 2005, at 5:02 PM, Fredrik Lundh wrote: > Bob Ippolito wrote: > >> That fixes it, of course. >> >> % python selftest.py >> 55 tests passed. >> >> Most of the projects I deal with will run tests with the build dir in >> sys.path so that you don't >> have to install before testing. > > that's why the README recommends you to do > > $ python setup.py build_ext -i > $ python selftest.py > > (this builds the extension "in place", so you can test it without > having > to mess with the path) I see, I simply ran "python setup.py build" after modifying the setup.py accordingly (to make sure it built before packaging with bdist_mpkg), and then it said to run selftest.py to test, so I did. It didn't tell me I needed to do anything else. I (obviously) didn't bother to read the README. -bob From hgerlach at compals.com Wed Feb 9 14:34:07 2005 From: hgerlach at compals.com (Henryk Gerlach) Date: Wed Feb 9 14:34:06 2005 Subject: [Image-SIG] colorshift while converting png to gif Message-ID: <200502091434.07333.hgerlach@compals.com> Hi Jeff, > I get a similar problem with the following complete program: > > import Image > i = Image.fromstring("RGB", (1, 1), chr(255) * 3) > j = i.convert("P") > print j.getpixel((0,0)) # prints 252, should print 255 > >This seems to have something to do with converting to a palette image. You are right, the "problem" is is with the palette. The way we invoke convert it uses the default palette. The entry #252 = (252,252,252) is the entry closest to white that it contains (there are only 255 entries at all). The trick is to tell the convert method to use an adaptive palette, i. e. call palette_im = im.convert("P", palette=Image.ADAPTIVE). palette_im.getpixel((0,0)) will return #0 in your example, because there will be only one entry in the palette which is #0 = (255,255,255). Thanks again Jeff, for pointing out it's a problem with the palette. And thanks to PIL people for their great product and access to the source, so the hidden APIs could be found.... Best regards, Henryk Gerlach -- www.compals.com From fredrik at pythonware.com Wed Feb 9 19:08:52 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed Feb 9 19:16:23 2005 Subject: [Image-SIG] Re: colorshift while converting png to gif References: <200502061859.21902.hgerlach@compals.com> <20050206202456.GB16104@unpythonic.net> Message-ID: Jeff Epler wrote: > I get a similar problem with the following complete program: > > import Image > i = Image.fromstring("RGB", (1, 1), chr(255) * 3) > j = i.convert("P") > print j.getpixel((0,0)) # prints 252, should print 255 > > This seems to have something to do with converting to a palette image. you really mean print j.convert("RGB").getpixel((0,0)) # prints (252, 252, 252), should print (255, 255, 255) here -- but the fact that you did get index 252 was just what I needed to realize what the problem was (the target palette contains a 6x6x6 color cube, but also a couple of grayscale values, and the palette matching algorithm considers 252 to be "close enough", despite the fact that the palette contains better matches). the attached patch fixes the problem. =================================================================== --- libImaging/Palette.c (revision 2287) +++ libImaging/Palette.c (working copy) @@ -61,9 +62,14 @@ if (!palette) return NULL; + for (i = 0; i < 10; i++) { + palette->palette[i*4+0] = + palette->palette[i*4+1] = + palette->palette[i*4+2] = 0; + } + /* Simple 6x6x6 colour cube */ - i = 10; for (b = 0; b < 256; b += 51) for (g = 0; g < 256; g += 51) for (r = 0; r < 256; r += 51) { @@ -73,6 +79,12 @@ i++; } + for (; i < 256; i++) { + palette->palette[i*4+0] = + palette->palette[i*4+1] = + palette->palette[i*4+2] = 0; + } + return palette; } From janssen at parc.com Wed Feb 9 22:09:31 2005 From: janssen at parc.com (Bill Janssen) Date: Wed Feb 9 22:09:47 2005 Subject: [Image-SIG] Re: colorshift while converting png to gif In-Reply-To: Your message of "Wed, 09 Feb 2005 10:08:52 PST." Message-ID: <05Feb9.130935pst."58617"@synergy1.parc.xerox.com> Aahhhh! Thanks so much -- I too was wondering what was going on, and hadn't pinned the problem down. I hope that patch will be in a future release. Bill > Jeff Epler wrote: > > > I get a similar problem with the following complete program: > > > > import Image > > i = Image.fromstring("RGB", (1, 1), chr(255) * 3) > > j = i.convert("P") > > print j.getpixel((0,0)) # prints 252, should print 255 > > > > This seems to have something to do with converting to a palette image. > > you really mean > > print j.convert("RGB").getpixel((0,0)) # prints (252, 252, 252), should print (255, 255, 255) > > here -- but the fact that you did get index 252 was just what I needed to realize > what the problem was (the target palette contains a 6x6x6 color cube, but also a > couple of grayscale values, and the palette matching algorithm considers 252 to > be "close enough", despite the fact that the palette contains better matches). the > attached patch fixes the problem. From tt at bu.edu Wed Feb 9 22:28:31 2005 From: tt at bu.edu (Tommaso Toffoli) Date: Wed Feb 9 22:58:03 2005 Subject: [Image-SIG] installing PIL Message-ID: <200502092128.j19LSVe9003511@pm1.bu.edu> I'm building PIL from source (1.1.4) for Fedora Core 3. At the stage when I'm executing the final build command, python setup.py build_ext -i I get the error message "`ft2build.h' hasn't been included yet!" and gcc fails. (I've seen this error mentioned on the web in a number of contexts other than PIL.) What do I do now? Many thanks Tom Toffoli ---------------------------------------------------------------- Prof. Tommaso Toffoli tt@bu.edu | ECE Dept., PHO531 pm1.bu.edu/~tt/ | home: Boston University 617/353-9846 | 617/864-8545 8 Saint Mary's St. fax -6440 | 26 Athens St. Boston, MA 02215 | Cambridge, MA 02138 From jwt at onjapan.net Thu Feb 10 02:37:59 2005 From: jwt at onjapan.net (Jim Tittsler) Date: Thu Feb 10 02:38:04 2005 Subject: [Image-SIG] installing PIL In-Reply-To: <200502092128.j19LSVe9003511@pm1.bu.edu> References: <200502092128.j19LSVe9003511@pm1.bu.edu> Message-ID: <173f1cbdda5674bc8c026e605bc5b3e2@onjapan.net> On Feb 10, 2005, at 06:28, Tommaso Toffoli wrote: > I'm building PIL from source (1.1.4) for Fedora Core 3. > [...] > I get the error message "`ft2build.h' hasn't been included yet!" and > gcc Did you make the change(s) suggested in the 1.1.4 errata? -- Jim Tittsler http://www.OnJapan.net/ GPG: 0x01159DB6 Python Starship http://Starship.Python.net/ Ringo MUG Tokyo http://www.ringo.net/rss.html From tt at bu.edu Thu Feb 10 06:53:51 2005 From: tt at bu.edu (Tommaso Toffoli) Date: Thu Feb 10 07:23:22 2005 Subject: [Image-SIG] installing PIL In-Reply-To: <173f1cbdda5674bc8c026e605bc5b3e2@onjapan.net> (message from Jim Tittsler on Thu, 10 Feb 2005 10:37:59 +0900) References: <200502092128.j19LSVe9003511@pm1.bu.edu> <173f1cbdda5674bc8c026e605bc5b3e2@onjapan.net> Message-ID: <200502100553.j1A5rp4s004295@pm1.bu.edu> Thanks! It worked. Tom Toffoli From revenge at gmail.com Thu Feb 10 18:07:34 2005 From: revenge at gmail.com (Ron Cybulskie) Date: Thu Feb 10 18:07:48 2005 Subject: [Image-SIG] font rendering problem Message-ID: <7e0c73db0502100907a7a84d6@mail.gmail.com> I am having problems rendering centain fonts using PIL 1.1.4 (and 1.1.5). One font that is causing problems is Marlett - a standard windows font. the following code: import Image, ImageFont, ImageDraw image = Image.new("RGB",(800,600)) fontpath = "C:\\WINDOWS\\Fonts\\Marlett.ttf" font = ImageFont.truetype(fontpath,18) draw = ImageDraw.Draw(image) draw.text((10, 10), "abcdefghijklmnopqrstuvwxyzASDFGH1234567", font=font, fill="#ffffff") image.save("C:\\marlett.gif","GIF") wont bomb out - the GIF saves out - but the glyphs are not rendering. I'm getting square boxes for each of the glyphs. Since I'm fairly unfamiliar with the TrueType format I'm not sure how the font actually differs from other baked-in windows fonts like Times or Arial. any help is appreciated. -- Ron Cybulskie revenge@gmail.com From fredrik at pythonware.com Thu Feb 10 18:34:27 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu Feb 10 18:48:05 2005 Subject: [Image-SIG] Re: font rendering problem References: <7e0c73db0502100907a7a84d6@mail.gmail.com> Message-ID: Ron Cybulskie wrote: >I am having problems rendering centain fonts using PIL 1.1.4 (and 1.1.5). > One font that is causing problems is Marlett - a standard windows font. C:\>dir \windows\fonts\marlett.ttf Volume in drive C has no label. Volume Serial Number is 1234-5678 Directory of C:\windows\fonts File Not Found C:\>attrib \windows\fonts\marlett.ttf H C:\windows\fonts\marlett.ttf Secret fonts. Interesting. Marlett seems to be a symbol font, and contains no ordinary characters. In 1.1.5, you can use the encoding argument to the truetype factory to specify non-Unicode character sets; from the CHANGES file: + Added optional "encoding" argument to the ImageFont.truetype factory. This argument can be used to specify non-Unicode character maps for fonts that support that. For example, to draw text using the Microsoft Symbol font, use: font = ImageFont.truetype("symbol.ttf", 16, encoding="symb") draw.text((0, 0), unichr(0xF000 + 0xAA)) (note that the symbol font uses characters in the 0xF000-0xF0FF range) (but I don't know what encoding that file uses, nor what character range it uses) From Mark.Robey at dipnr.nsw.gov.au Fri Feb 11 04:58:32 2005 From: Mark.Robey at dipnr.nsw.gov.au (Mark Robey) Date: Fri Feb 11 05:00:13 2005 Subject: [Image-SIG] 2.4 Message-ID: Hi Will there be a version of PIL for Python 2.4? Thanks Mark From bob at redivi.com Fri Feb 11 05:14:44 2005 From: bob at redivi.com (Bob Ippolito) Date: Fri Feb 11 05:14:49 2005 Subject: [Image-SIG] 2.4 In-Reply-To: References: Message-ID: <79c4cdea20bc4f616c83087da7261a1d@redivi.com> On Feb 10, 2005, at 10:58 PM, Mark Robey wrote: > Will there be a version of PIL for Python 2.4? http://effbot.org/downloads/#PIL -bob From r.oudkerk at tiscali.co.uk Tue Feb 15 00:20:21 2005 From: r.oudkerk at tiscali.co.uk (Richard Oudkerk) Date: Tue Feb 15 00:20:26 2005 Subject: [Image-SIG] bug in getcolors() Message-ID: <42113235.2000803@tiscali.co.uk> Sometimes (depending on the setting of the parameter maxcolors) the last colour in the list returned by im.getcolors() is reported as having a zero pixel count, and that colour will have appeared earlier in the list. For example if we do . >>> import Image . >>> im = Image.open("Images/lena.ppm") . >>> A = im.quantize(3).convert("RGB") then we get . >>> A.getcolors(maxcolors=8) . [(3236, (227, 183, 147)), (6851, (208, 143, 112)), (0, (227, 183, 147))] (which is wrong) but get . >>> A.getcolors(maxcolors=16) . [(6851, (208, 143, 112)), (6297, (143, 84, 81)), (3236, (227, 183, 147))] (which is right). This seems to be caused by a bug at the end of getcolors32() in GetBBox.c when table[] is being packed. It looks as though the packing only works correctly if table[0] is unoccupied (or the image has only one colour). Otherwise table[0] will get overwritten and lost. I think this patch fixes things. *** GetBBox.c Mon Feb 14 01:04:58 2005 --- libImaging/GetBBox.c Mon Feb 14 01:12:44 2005 *************** *** 307,315 **** overflow: /* pack the table */ ! for (x = y = 0; x < (int) code_size; x++) ! if (table[x].count && x != y) table[y++] = table[x]; table[y].count = 0; /* mark end of table */ --- 307,320 ---- overflow: + /* find first unoccupied position in table */ + for (y = 0; y < (int) code_size; y++) + if (!table[y].count) + break; + /* pack the table */ ! for (x = y; x < (int) code_size; x++) ! if (table[x].count) table[y++] = table[x]; table[y].count = 0; /* mark end of table */ From gene at siteworx.com Fri Feb 4 00:03:26 2005 From: gene at siteworx.com (Gene Skonicki) Date: Tue Feb 15 12:19:02 2005 Subject: [Image-SIG] PIL thumbnail zero division patch Message-ID: <83A09C47AC2C18478A50F393D26B531002C74F@exchange.siteworx.local> Greetings, The (very) short patch below corrects some issues I have had in PIL using the thumbnail method in certain, admittedly pathological conditions. When aspect ratios are large enough and one dimension is small enough, it is possible to get these lines to go to zero and pass zeros through to draft(). I'm not an expert on the finer points of graphics processing, so this may not be the most correct solution. Regards, Gene --- Image.py.orig Thu Feb 3 17:42:43 2005 +++ Image.py Thu Feb 3 17:32:40 2005 @@ -1420,8 +1420,8 @@ # preserve aspect ratio x, y = self.size - if x > size[0]: y = y * size[0] / x; x = size[0] - if y > size[1]: x = x * size[1] / y; y = size[1] + if x > size[0]: y = (y * size[0] / x) or 1; x = size[0] + if y > size[1]: x = (x * size[1] / y) or 1; y = size[1] size = x, y if size == self.size: -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20050203/84758e62/attachment.htm From slovell at aptima.com Fri Feb 4 00:03:27 2005 From: slovell at aptima.com (Stacy Lovell) Date: Tue Feb 15 12:19:31 2005 Subject: [Image-SIG] PhotoImage filename Message-ID: <20050203230632.B8CF91E4004@bag.python.org> One can construct a Tkinter PhotoImage from a filename, like so: name = 'icon.gif' self.image = PhotoImage(file=name) However, is it possible to then get the filename used in constructing the PhotoImage back (using self.image)? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20050203/40caa1fa/attachment.html From rwarren at bcgsc.ca Tue Feb 15 00:21:38 2005 From: rwarren at bcgsc.ca (Rene Warren) Date: Tue Feb 15 12:19:32 2005 Subject: [Image-SIG] image resolution Message-ID: Hi, I was wondering if it's possible to adjust the resolution of a newly created image under PIL. e.g. is it possible to specify the number of DPI? Thanks, Rene Rene Warren BCGSC -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20050214/bbf6b6bc/attachment.htm From fredrik at pythonware.com Tue Feb 15 12:35:03 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue Feb 15 12:35:41 2005 Subject: [Image-SIG] Re: image resolution References: Message-ID: Rene Warren wrote: > I was wondering if it's possible to adjust the resolution of a newly > created image under PIL. > e.g. is it possible to specify the number of DPI? depends on the file format. many, but not all, output drivers support the dpi= option. example: im.save(filename, dpi=(72, 72)) From morten at nidelven-it.no Tue Feb 15 14:07:00 2005 From: morten at nidelven-it.no (Morten W. Petersen) Date: Tue Feb 15 14:07:06 2005 Subject: [Image-SIG] Creating text on images In-Reply-To: <41E62AAB.8030502@hlabs.spb.ru> References: <41E5FFB4.7070403@nidelven-it.no> <41E62AAB.8030502@hlabs.spb.ru> Message-ID: <4211F3F4.4020005@nidelven-it.no> Dmitry Vasiliev wrote: > Morten W. Petersen wrote: > >> Hi all, >> >> I'm trying to create a script that will superimpose text on an image. >> I didn't find any great examples out there on how this can be done (I >> presume using PIL is necessary), do you know of any examples? > > > You can do it like this: > > >>> from PIL import Image, ImageDraw > >>> image = Image.new("L", (100, 50)) > >>> draw = ImageDraw.Draw(image) > >>> draw.text((10, 10), "Hello, World!", fill=0xff) > >>> image.show() > > See also ImageFont module. Thanks, as I mentioned earlier, that helped. I have a new problem now however; the image I'm drawing on is a transparent PNG, and any text that's drawn is also transparent, i.e. it just 'cuts out' pieces of the image instead of drawing colored text.. how do I fix that? PS: I'm not on the list so I would appreciate a CC. -- Regards, Morten Tlf: +47 45 44 00 69 Blog: http://www.blogologue.com -------------- next part -------------- A non-text attachment was scrubbed... Name: morten.vcf Type: text/x-vcard Size: 290 bytes Desc: not available Url : http://mail.python.org/pipermail/image-sig/attachments/20050215/fbd2ab53/morten.vcf From lists at hlabs.spb.ru Tue Feb 15 15:21:24 2005 From: lists at hlabs.spb.ru (Dmitry Vasiliev) Date: Tue Feb 15 15:22:19 2005 Subject: [Image-SIG] Creating text on images In-Reply-To: <4211F3F4.4020005@nidelven-it.no> References: <41E5FFB4.7070403@nidelven-it.no> <41E62AAB.8030502@hlabs.spb.ru> <4211F3F4.4020005@nidelven-it.no> Message-ID: <42120564.1070600@hlabs.spb.ru> Morten W. Petersen wrote: [SKIP] > Thanks, as I mentioned earlier, that helped. I have a new problem now > however; > the image I'm drawing on is a transparent PNG, and any text that's drawn is > also transparent, i.e. it just 'cuts out' pieces of the image instead of > drawing colored text.. how do I fix that? The slightly modified example: >>> image = Image.new("RGBA", (100, 50)) >>> draw = ImageDraw.Draw(image) >>> draw.text((12, 12), "Hello, World!", fill=(0, 0, 0, 0x55)) >>> draw.text((10, 10), "Hello, World!", fill=(0, 0, 0xff, 0xff)) >>> image.save("test.png") -- Dmitry Vasiliev (dima at hlabs.spb.ru) http://hlabs.spb.ru From morten at nidelven-it.no Tue Feb 15 16:55:19 2005 From: morten at nidelven-it.no (Morten W. Petersen) Date: Tue Feb 15 16:55:25 2005 Subject: [Image-SIG] Creating text on images In-Reply-To: <42120564.1070600@hlabs.spb.ru> References: <41E5FFB4.7070403@nidelven-it.no> <41E62AAB.8030502@hlabs.spb.ru> <4211F3F4.4020005@nidelven-it.no> <42120564.1070600@hlabs.spb.ru> Message-ID: <42121B67.40108@nidelven-it.no> Dmitry, great, exactly what I needed again. :) -Morten Dmitry Vasiliev wrote: > Morten W. Petersen wrote: > > [SKIP] > >> Thanks, as I mentioned earlier, that helped. I have a new problem >> now however; >> the image I'm drawing on is a transparent PNG, and any text that's >> drawn is >> also transparent, i.e. it just 'cuts out' pieces of the image instead >> of drawing colored text.. how do I fix that? > > > The slightly modified example: > > >>> image = Image.new("RGBA", (100, 50)) > >>> draw = ImageDraw.Draw(image) > >>> draw.text((12, 12), "Hello, World!", fill=(0, 0, 0, 0x55)) > >>> draw.text((10, 10), "Hello, World!", fill=(0, 0, 0xff, 0xff)) > >>> image.save("test.png") > -- Regards, Morten Tlf: +47 45 44 00 69 Blog: http://www.blogologue.com -------------- next part -------------- A non-text attachment was scrubbed... Name: morten.vcf Type: text/x-vcard Size: 290 bytes Desc: not available Url : http://mail.python.org/pipermail/image-sig/attachments/20050215/81e27183/morten.vcf From jbreiden at parc.com Wed Feb 16 22:39:41 2005 From: jbreiden at parc.com (Jeff Breidenbach) Date: Wed Feb 16 22:39:49 2005 Subject: [Image-SIG] perspective transform In-Reply-To: <1106008994.29623.14.camel@rode.parc.com> References: <1106008994.29623.14.camel@rode.parc.com> Message-ID: <1108589981.2605.3.camel@rode.parc.com> PIL's Image Module already has support for affine transformations. Is there any interest in adding support for the perspective transformation as well? Something like: =================== im.transform(size, PERSPECTIVE, data) Applies a persepctive transform to the image, and places the result in a new image with the given size. Data is a 8-tuple (a, b, c, d, e, f, g, h) which contains the coefficients for a perspective transform. For each pixel (x, y) in the output image, the new value is taken from a position (a x + b y + c)/(g x + h y + 1), (d x + e y + f)/(g x + h y + 1) in the input image, rounded to nearest pixel. This function can be used to change the 2D perspective of the original image. From jbreiden at parc.com Thu Feb 17 04:55:55 2005 From: jbreiden at parc.com (Jeff Breidenbach) Date: Thu Feb 17 04:56:16 2005 Subject: [Image-SIG] perspective transform [patch] In-Reply-To: <20050216110005.25AC31E4007@bag.python.org> References: <20050216110005.25AC31E4007@bag.python.org> Message-ID: <1108612556.2595.9.camel@rode.parc.com> Here's the patch for the perspective transform. Hope to see it in a future version of PIL. Cheers, Jeff -------------- next part -------------- A non-text attachment was scrubbed... Name: perspective-transform-pil-1.1.4.diff.gz Type: application/x-gzip Size: 1298 bytes Desc: not available Url : http://mail.python.org/pipermail/image-sig/attachments/20050216/896c13fa/perspective-transform-pil-1.1.4.diff.bin From greg.lindstrom at novasyshealth.com Thu Feb 17 16:29:31 2005 From: greg.lindstrom at novasyshealth.com (Greg Lindstrom) Date: Thu Feb 17 16:29:36 2005 Subject: [Image-SIG] Strings and Images Message-ID: <4214B85B.3060701@novasyshealth.com> Hello- I am new to PIL and would like some help/advice. I am to write an application to pull information from a database and format it so that it would print to a form. I would like to pull the form into my Python application (I have it in pdf and png format) and overlay my data on top of it. I can open and play with the image in PIL but can not figure out how to write strings on top of the location for each data element (I have been playing with crop). Can I do this with PIL and, if so, how do I go about doing it. Or, is there a better way to accomplish this task? Thanks for your help, --greg -- Greg Lindstrom 501 975.4859 Computer Programmer greg.lindstrom@novasyshealth.com NovaSys Health Little Rock, Arkansas "We are the music makers, and we are the dreamers of dreams." W.W. Confidentiality Notice ---------------------- This email and any attachments to it are privileged and confidential and are intended solely for use of the individual or entity to which they are addressed. If the reader of this message is not the intended recipient, any use, distribution, or copying of this communication, or disclosure of all or any part of its content to any other person, is strictly prohibited. If you have received this communication in error, please notify the sender by replying to this message and destroy this message and delete any copies held in your electronic files. Thank you. From greg.lindstrom at novasyshealth.com Thu Feb 17 17:03:12 2005 From: greg.lindstrom at novasyshealth.com (Greg Lindstrom) Date: Thu Feb 17 17:03:17 2005 Subject: [Image-SIG] Setting Font Size Message-ID: <4214C040.3040408@novasyshealth.com> I can now write a string over my image but cannot figure out how to set the font size (an instance of the ImageFont class loaded from file....what file?). This looks like it will do exactly what I need and I'm really looking forward to using it. --greg -- Greg Lindstrom 501 975.4859 Computer Programmer greg.lindstrom@novasyshealth.com NovaSys Health Little Rock, Arkansas "We are the music makers, and we are the dreamers of dreams." W.W. Confidentiality Notice ---------------------- This email and any attachments to it are privileged and confidential and are intended solely for use of the individual or entity to which they are addressed. If the reader of this message is not the intended recipient, any use, distribution, or copying of this communication, or disclosure of all or any part of its content to any other person, is strictly prohibited. If you have received this communication in error, please notify the sender by replying to this message and destroy this message and delete any copies held in your electronic files. Thank you. From fredrik at pythonware.com Thu Feb 17 22:16:08 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu Feb 17 22:17:09 2005 Subject: [Image-SIG] Re: bug in getcolors() References: <42113235.2000803@tiscali.co.uk> Message-ID: Richard Oudkerk wrote: > Sometimes (depending on the setting of the parameter maxcolors) the > last colour in the list returned by im.getcolors() is reported as > having a zero pixel count, and that colour will have appeared earlier > in the list. > This seems to be caused by a bug at the end of getcolors32() in > GetBBox.c when table[] is being packed. > > It looks as though the packing only works correctly if table[0] is > unoccupied (or the image has only one colour). Otherwise table[0] > will get overwritten and lost. tricky. after staring at the code for a while, I'm pretty sure it was supposed to look like this: /* pack the table */ for (x = y = 0; x < (int) code_size; x++) if (table[x].count) { if (x != y) table[y] = table[x]; y++; } table[y].count = 0; /* mark end of table */ thanks /F From fredrik at pythonware.com Sun Feb 20 10:58:37 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun Feb 20 10:58:45 2005 Subject: [Image-SIG] Re: Strings and Images References: <4214B85B.3060701@novasyshealth.com> Message-ID: Greg Lindstrom wrote: > I am new to PIL and would like some help/advice. I am to write an application to pull information > from a database and format it so that it would print to a form. I would like to pull the form > into my Python application (I have it in pdf and png format) and overlay my data on top of it. I > can open and play with the image in PIL but can not figure out how to write strings on top of the > location for each data element (I have been playing with crop). Can I do this with PIL and, if > so, how do I go about doing it. Or, is there a better way to accomplish this task? this recent thread might be helpful: http://thread.gmane.org/gmane.comp.python.image/1320 From fredrik at pythonware.com Mon Feb 21 12:04:09 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon Feb 21 12:13:48 2005 Subject: [Image-SIG] Re: perspective transform [patch] References: <20050216110005.25AC31E4007@bag.python.org> <1108612556.2595.9.camel@rode.parc.com> Message-ID: Jeff Breidenbach wrote: > Here's the patch for the perspective transform. Hope > to see it in a future version of PIL. that's very likely, but unfortunately a bit too late for the 1.1.5 release candidate. (but I might squeeze it in as an "experimental" feature in 1.1.5 anyway) thanks /F From michael.bierenfeld at web.de Tue Feb 22 13:37:19 2005 From: michael.bierenfeld at web.de (Michael Bierenfeld) Date: Tue Feb 22 13:37:22 2005 Subject: [Image-SIG] Setting TITT Attributes when saving Message-ID: <709250834@web.de> Greetings, I have just joined the list .. so nice greetings to all : The following code : fp = open (pgmpfile) # 8 Bit pgm File imagecontent = fp.read () fp.close () parser = ImageFile.Parser () parser.feed (imagecontent) image = parser.close () image.save (tifffile) Stores a PGM-File as a TIFF-File. The File should be further processed by pytiff. But this packages throws the following Exception while executing reader = pytiff.TiffReader (tifffile) ValueError: TIFF image doesn't have a samples per pixel tag. The same happens if I convert the Image with image = image.convert ("1") Then it complains "ValueError: TIFF image doesn't have a bits per sample tag" too. Does anybody know how to set these parameters in the saved TIFF-File ? From fredrik at pythonware.com Tue Feb 22 17:00:05 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue Feb 22 17:00:29 2005 Subject: [Image-SIG] Re: Setting TITT Attributes when saving References: <709250834@web.de> Message-ID: Michael Bierenfeld wrote: > I have just joined the list .. so nice greetings to all : > > The following code : > > fp = open (pgmpfile) # 8 Bit pgm File > imagecontent = fp.read () > fp.close () > parser = ImageFile.Parser () > parser.feed (imagecontent) > image = parser.close () (umm. what's wrong with using "image = Image.open(pgmpfile)" ?) > image.save (tifffile) > > Stores a PGM-File as a TIFF-File. The File should be further processed > by pytiff. But this packages throws the following Exception while executing > > reader = pytiff.TiffReader (tifffile) > > ValueError: TIFF image doesn't have a samples per pixel tag. Looks like someone didn't read the TIFF specification. The "samples per pixels" tag (tag 277) defaults to 1 in all versions of the specification, and is only required for images that consist of multiple bands (such as RGB and RGBA). The pytiff library should be fixed to use proper defaults for "missing" fields (see appendix A in the TIFF specification for details). From michael.bierenfeld at web.de Tue Feb 22 17:17:32 2005 From: michael.bierenfeld at web.de (Michael Bierenfeld) Date: Tue Feb 22 17:17:37 2005 Subject: [Image-SIG] Re: Setting TITT Attributes when saving Message-ID: <709381187@web.de> (umm. what's wrong with using "image = Image.open(pgmpfile)" ?) Nothing :-) I thought opening reading and feeding is faster. Anyway ..... The pytiff library should be fixed to use proper defaults for "missing" fields (see appendix A in the TIFF specification for details). Patch is on the way to oliverh at nortwesn .... Kind regards Michael _______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig From fredrik at pythonware.com Tue Feb 22 17:17:31 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue Feb 22 17:24:13 2005 Subject: [Image-SIG] ANN: PIL 1.1.5 release candidate 1 (february 20, 2005) Message-ID: PIL 1.1.5 release candidate 1 (aka rc1 revision 2) is now available from effbot.org: http://effbot.org/downloads#imaging (look for Imaging-1.1.5c1.tar.gz for source, and PIL-115c1*.exe for windows binaries). For a list of changes, see this page: http://effbot.org/zone/pil-changes-115.htm Report bugs to this list or directly to me, as usual. enjoy /F From jbreiden at parc.com Tue Feb 22 18:48:00 2005 From: jbreiden at parc.com (Jeff Breidenbach) Date: Tue Feb 22 18:48:20 2005 Subject: R[Image-SIG] Re: perspective transform [patch] In-Reply-To: <20050222110117.E508D1E4007@bag.python.org> References: <20050222110117.E508D1E4007@bag.python.org> Message-ID: <1109094480.604.27.camel@rode.parc.com> > > (but I might squeeze it in as an "experimental" feature in 1.1.5 anyway) I think it should be safe. I've been testing heavily against 1.1.4 and haven't noticed any bugs or problems yet. There is an obvious and trivial tweak to line 37 & 38 of the patch which can save a bit of CPU time (one division operation per pixel) but that certainly isn't required. Cheers, Jeff From thogrom at terra.es Wed Feb 23 14:28:12 2005 From: thogrom at terra.es (THOGROM.terra.es) Date: Wed Feb 23 14:28:38 2005 Subject: [Image-SIG] tostring Message-ID: <1109165292.5364.9.camel@localhost.localdomain> Hello list! I'm using python to store some images as strings. image = PIL.Image.open(sname) self.__simagestr = image.tostring() os.remove(sname) Later, I have to store this string on a file: def savedraw(self, suri): #suri is a path like "/home/image.jpeg" data = StringIO.StringIO(self.__simagestr) im = PIL.Image.open(data) im.save(data,'JPEG') But the system shows the next error when execute PIL.Image.open(data) raise IOError("cannot identify image file") What is wrong? Thanks jmd -- THOGROM.terra.es From lists at hlabs.spb.ru Thu Feb 24 11:33:35 2005 From: lists at hlabs.spb.ru (Dmitry Vasiliev) Date: Thu Feb 24 11:34:24 2005 Subject: [Image-SIG] tostring In-Reply-To: <1109165292.5364.9.camel@localhost.localdomain> References: <1109165292.5364.9.camel@localhost.localdomain> Message-ID: <421DAD7F.4000709@hlabs.spb.ru> THOGROM.terra.es wrote: > Hello list! > I'm using python to store some images as strings. > image = PIL.Image.open(sname) > self.__simagestr = image.tostring() > os.remove(sname) tostring() just returns pixels data. If you want opening the string through StringIO later you just can do: self.__simagestr = open(sname).read() > Later, I have to store this string on a file: > def savedraw(self, suri): > #suri is a path like "/home/image.jpeg" > data = StringIO.StringIO(self.__simagestr) > im = PIL.Image.open(data) > im.save(data,'JPEG') im.save(suri, 'JPEG') ? > But the system shows the next error when execute PIL.Image.open(data) > raise IOError("cannot identify image file") -- Dmitry Vasiliev (dima at hlabs.spb.ru) http://hlabs.spb.ru From mark at diversiform.com Fri Feb 18 17:47:45 2005 From: mark at diversiform.com (Mark Daley) Date: Tue Mar 1 17:07:17 2005 Subject: [Image-SIG] Using PIL to change bitmaps - transparency masking? Message-ID: <110874552901@neptune.hosting4u.net> I am trying to use the Image module to do some bitmap conversions (pretty simple, just invert, rotate and set transparency) and write to a PDF through ReportLab. Here is the line that's killing me: proof.drawImage(out, int(values[2]), int(values[3]), mask = [0,1,0,1,0,1]) Now, in a bitmap, you have two color options, 0 and 1. I have determined that 0 is white and 1 is black. However, when I use the mask option to attempt to mask the white in the bitmap when I write it to the PDF, it ends up masking the black pixels. Well, no problem, I think, I'll just mask the opposite choice. Wrong! Whether I change the mask to [1,2,1,2,1,2] or [255,256,255,256,255,256], nothing happens. Is what I'm trying to do even possible? I have posted the snippet below for your perusal. tempimage = os.path.splitext(values[4])[0] + 'temp.bmp' print tempimage im = Image.open(values[4]) print im.format, im.size, im.mode xval = im.size[0] yval = im.size[1] for horiz in range(xval): for vert in range(yval): if im.getpixel((horiz, vert)) == 0: im.putpixel((horiz, vert), 1) else: im.putpixel((horiz, vert), 0) out = im.rotate(180) proof.drawImage(out, int(values[2]), int(values[3]), mask = [0,1,0,1,0,1]) out.save(tempimage, 'BMP') - Mark Daley -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20050218/2441c11e/attachment.html From export at hope.cz Fri Feb 25 12:30:45 2005 From: export at hope.cz (export@hope.cz) Date: Tue Mar 1 17:07:27 2005 Subject: [Image-SIG] Watermark feature in PIL Message-ID: <421F1A75.2430.EA89A0@localhost> Hello, I am a newbie with PIL module and would like to use it because I need to resize a lot of pictures and prepare them for our web. I would like to add a watermark to each picture with our URL address. Is it possible with PIL ? Is watermark feature supported in PIL ? Thanks for help. Lad. From export at hope.cz Sat Feb 26 08:33:40 2005 From: export at hope.cz (export@hope.cz) Date: Tue Mar 1 17:07:37 2005 Subject: [Image-SIG] Aspect ratio in PIL Message-ID: <42203464.4261.537D813@localhost> Is KEEP ASPECT RATIO available when I resize a picture? Thanks for help Lad.