From dkirtley at gmail.com Wed May 4 18:35:25 2005 From: dkirtley at gmail.com (David Kirtley) Date: Wed, 4 May 2005 11:35:25 -0500 Subject: [Image-SIG] Odd behavior in PIL 1.1.4 equalization Message-ID: <22b0f40d050504093530609811@mail.gmail.com> Hi all, I seem to have found an odd behavior in the equalization. I created a series of test images with PIL for a demonstration: a 300x300 RGB image with three bars of gray with offsets of 20 in all three channels with starting values of 0 to 200 in steps of 50. I expected the equalization routine to move them to 0, 128, 255 as per the definition of Histogram Equailzation but to my suprise the equalization routine decides to instead set them to 0, 85, 170. Is this intended functionality? Is this a bug/feature? :) David ------------------------------------- Source used------------------------- import Image, ImageOps, ImageDraw, ImageFilter def fill(im,start): d = ImageDraw.Draw(im) d.rectangle((0,0,99,299), fill=(start+0,start+0,start+0), outline =(start+0,start+0,start+0)) d.rectangle((100,0,199,299), fill=(start+20,start+20,start+20), outline =(start+20,start+20,start+20)) d.rectangle((200,0,299,299), fill=(start+40,start+40,start+40), outline =(start+40,start+40,start+40)) return im x = Image.new('RGB',(300,300)) original = open('original.csv','w') equalized = open('equalized.csv','w') for image_base in [a for a in range(0,200,50)]: a = fill(x, image_base) a.save('%s_original.png'%image_base,'PPM') b = ImageOps.equalize(a) b.save('%s_equalized.png'%image_base,'PPM') original.write('%s,'%image_base+`a.histogram()`[1:-1]+'\n') equalized.write('%s,'%image_base+`b.histogram()`[1:-1]+'\n') From darkstar at brturbo.com.br Wed May 4 22:50:17 2005 From: darkstar at brturbo.com.br (Weldner Alves) Date: Wed, 4 May 2005 17:50:17 -0300 (BRT) Subject: [Image-SIG] Question about PIL and transparency Message-ID: <31227331.1115239817089.JavaMail.nobody@webmail1.brturbo.com> What I wanna do is simple: I just want to write a string on a transparent background. Here is my code: import Image, ImageDraw, ImageFont im = Image.new("P",(500,500), 'white') fonte = ImageFont.truetype("comicbd.ttf",15) draw = ImageDraw.Draw(im) im.info['transparency'] = 255 """(the background is white, then white is my transparency)""" draw.text((0,0), "HERE GOES THE STRING", fill='black', font=fonte) #save im.save("something.png", "PNG") Now when I go to the prompt: >>> im = Image.open('something.png') >>> im.info.items() [] >>> im.info["transparency"]=255 >>> im.save("anything.png", "PNG") >>> im = Image.open('anything.png') >>> im.info.items() [] There was suposed to be a "transparency" with value 255 inside the info dict. So whats wrong ? From fredrik at pythonware.com Thu May 5 11:05:43 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 5 May 2005 11:05:43 +0200 Subject: [Image-SIG] Question about PIL and transparency References: <31227331.1115239817089.JavaMail.nobody@webmail1.brturbo.com> Message-ID: Weldner Alves wrote: > im.info['transparency'] = 255 > #save > im.save("something.png", "PNG") try im.save("something.png", transparency=255) instead. From fredrik at pythonware.com Thu May 5 11:04:31 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 5 May 2005 11:04:31 +0200 Subject: [Image-SIG] Odd behavior in PIL 1.1.4 equalization References: <22b0f40d050504093530609811@mail.gmail.com> Message-ID: David Kirtley wrote: > I seem to have found an odd behavior in the equalization. > > I created a series of test images with PIL for a demonstration: > a 300x300 RGB image with three bars of gray with offsets of 20 in > all three channels > with starting values of 0 to 200 in steps of 50. > > I expected the equalization routine to move them to 0, 128, 255 as per > the definition of Histogram Equailzation but to my suprise the > equalization routine decides to instead > set them to 0, 85, 170. > > Is this intended functionality? Is this a bug/feature? :) looks like an off-by-one error (note that 170+85=255). should only cause problems for extreme cases, and should be trivial to fix. I'll into this for 1.1.6 (patches are welcome). From fredrik at pythonware.com Thu May 5 23:14:10 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 5 May 2005 23:14:10 +0200 Subject: [Image-SIG] Odd behavior in PIL 1.1.4 equalization References: <22b0f40d050504093530609811@mail.gmail.com> Message-ID: I wrote: > I'll into this for 1.1.6 make that "I'll look into this for 1.1.6". > (patches are welcome). I've attached a (preliminary) patch. Index: PIL/ImageOps.py =================================================================== --- PIL/ImageOps.py (revision 2382) +++ PIL/ImageOps.py (working copy) @@ -207,13 +207,15 @@ h = image.histogram(mask) lut = [] for b in range(0, len(h), 256): - step = reduce(operator.add, h[b:b+256]) / 255 - if step == 0: - step = 1 - n = 0 - for i in range(256): - lut.append(n / step) - n = n + h[i+b] + histo = filter(None, h[b:b+256]) + if len(histo) <= 1: + lut.append(range(256)) + else: + step = (reduce(operator.add, histo) - histo[-1]) / 255 + n = step / 2 + for i in range(256): + lut.append(n / step) + n = n + h[i+b] return _lut(image, lut) ## From douglas at paradise.net.nz Fri May 6 04:00:04 2005 From: douglas at paradise.net.nz (Douglas Bagnall) Date: Fri, 06 May 2005 14:00:04 +1200 Subject: [Image-SIG] downscaling by area averaging Message-ID: <427ACFA4.6070602@paradise.net.nz> hi, I've made a patch to resize by averaging pixels. http://halo.gen.nz/pil/pil_area_average.patch If people want it, I'll fix up the GCCisms, and make it work on other than RGB images. I wrote it for statistical analysis of images (to get the average density of various areas). For every size I tried it proved quicker and more accurate than the antialias filter (which, OTOH, is more flexible). Typical times resizing from 450 x 325 to 16 x 12 are: NEAREST: 0.000022 BILINEAR: 0.000112 BICUBIC: 0.000192 AREA_AVERAGE: 0.001558 ANTIALIAS: 0.009321 (linux, athlon XP 2800+). The results of this are here: http://halo.gen.nz/pil/examples.html Interestingly, the area averaged image is generally pixel perfect with the Gimp's best resizing ("Cubic"). and finally, I just discovered that emacs can save files as syntax highlighted html, so here is the guts of the patch in full colour: http://halo.gen.nz/pil/AreaAverage_c.html regards Douglas Bagnall From fredrik at pythonware.com Fri May 6 12:19:32 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 6 May 2005 12:19:32 +0200 Subject: [Image-SIG] New to PIL and struggling... References: Message-ID: "charlie clark" wrote: > Trying to understand things: lut is effectively a palette table all set to > the same value? > What does lut[im.info["transparency"]] = 0 do? > In my case its would sets lut[14] = 0 > So the real magic is im.point() which creates a single band presumably > reacting to the transparency in the original image. "point" just maps the source pixels through the lookup-table (the "lut"), like this: for all coordinates in image: ... load pixel from input image ... pixel = lut[pixel] ... store pixel in output pixel ... the result is a mask which has the value 0 for all transparent pixels (index 14), and the value 1 for all other pixels. "point" itself doesn't know about transparency; it just uses the table it got. From fredrik at pythonware.com Fri May 6 12:26:34 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 6 May 2005 12:26:34 +0200 Subject: [Image-SIG] downscaling by area averaging References: <427ACFA4.6070602@paradise.net.nz> Message-ID: Douglas Bagnall wrote: > I've made a patch to resize by averaging pixels. > > http://halo.gen.nz/pil/pil_area_average.patch > > If people want it, I'll fix up the GCCisms, and make it work on other > than RGB images. looks interesting, but in theory (and without analyzing your code), shouldn't this be the same as running ImagingStretch with the nearest filter? (=an adaptive box filter) (guess I'll have to do some experiments... I've been meaning to switch to ImagingStretch for all downsampling uses, but haven't had time to tune the filters yet (=make them behave the same as the upsampling filters). this might be the prodding I needed) > Interestingly, the area averaged image is generally pixel perfect with > the Gimp's best resizing ("Cubic"). that's odd. what kind of source images are you processing? From fredrik at pythonware.com Fri May 6 13:29:58 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 6 May 2005 13:29:58 +0200 Subject: [Image-SIG] downscaling by area averaging References: <427ACFA4.6070602@paradise.net.nz> Message-ID: > what kind of source images are you processing? this is what happens when you don't click on all links in a message ;-) some observations: + the sample you used sure illustrates why PIL's BILINEAR and BICUBIC fixed-size kernel filters are not very good for down- sampling... + in case anyone wants to play with PIL's internal stretch filters, you can use the following little wrapper function: def stretch(im, size, filter=Image.NEAREST): im.load() im = im._new(im.im.stretch(size, filter)) return im supported filters are Image.NEAREST, BILINEAR, and BICUBIC, in addition to ANTIALIAS (which is already exposed via the "resize" method). unlike their resize counterparts, the stretch filters use an adaptive kernel size (the more you downsample, the larger the kernel) + as expected, NEAREST stretch isn't too far from your results, but it's not identical (and it probably shouldn't be) + I'm beginning to wonder if there's not an off-by-something error lurking somewhere in stretch. hmm... From darkstar at brturbo.com.br Fri May 6 19:33:45 2005 From: darkstar at brturbo.com.br (Weldner Alves) Date: Fri, 6 May 2005 14:33:45 -0300 (BRT) Subject: [Image-SIG] Question about PIL and transparency Message-ID: <31780687.1115400825585.JavaMail.nobody@webmail4.brturbo.com> What I wanna do is simple: I just want to write a string on a transparent background. Here is my code: import Image, ImageDraw, ImageFont im = Image.new("P",(500,500), 'white') fonte = ImageFont.truetype("comicbd.ttf",15) draw = ImageDraw.Draw(im) im.info['transparency'] = 255 """(the background is white, then white is my transparency)""" draw.text((0,0), "HERE GOES THE STRING", fill='black', font=fonte) #save im.save("something.png", "PNG") Now when I go to the prompt: >>> im = Image.open('something.png') >>> im.info.items() [] >>> im.info["transparency"]=255 >>> im.save("anything.png", "PNG") >>> im = Image.open('anything.png') >>> im.info.items() [] There was suposed to be a "transparency" with value 255 inside the info dict. So whats wrong ? From fredrik at pythonware.com Fri May 6 20:06:35 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 6 May 2005 20:06:35 +0200 Subject: [Image-SIG] Question about PIL and transparency References: <31780687.1115400825585.JavaMail.nobody@webmail4.brturbo.com> Message-ID: Weldner Alves wrote: > What I wanna do is simple: > I just want to write a string on a transparent background. Here is my code: did you post this again after I replied, or is it a problem with the python.org mailserver? (if the former, please read replies before repeating a question). From douglas at paradise.net.nz Sat May 7 03:54:28 2005 From: douglas at paradise.net.nz (Douglas Bagnall) Date: Sat, 07 May 2005 13:54:28 +1200 Subject: [Image-SIG] downscaling by area averaging In-Reply-To: References: <427ACFA4.6070602@paradise.net.nz> Message-ID: <427C1FD4.70700@paradise.net.nz> I've added stretched versions to http://halo.gen.nz/pil/examples.html With javascript, clicking on the top image should cycle through the unscaled, area averaged, anti-aliased, and nearest-neighbour-stetched images. > + I'm beginning to wonder if there's not an off-by-something error > lurking somewhere in stretch. hmm... In my tests, all the resize and stretch filters appear to shift the image down and to the right by about half an output pixel. Assuming my controls images are right... [Earlier] >>Interestingly, the area averaged image is generally pixel perfect with >>the Gimp's best resizing ("Cubic"). > > that's odd. Without looking, I think it must be adaptive, but is called cubic because that is an ancient photoshop keyword for "the best possible". douglas From fredrik at pythonware.com Sat May 7 11:09:14 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 7 May 2005 11:09:14 +0200 Subject: [Image-SIG] Odd behavior in PIL 1.1.4 equalization References: <22b0f40d050504093530609811@mail.gmail.com> Message-ID: > I've attached a (preliminary) patch. here's a sligtly less broken patch: Index: PIL/ImageOps.py =================================================================== --- PIL/ImageOps.py (revision 2134) +++ PIL/ImageOps.py (working copy) @@ -9,6 +9,7 @@ # 2001-10-23 fl Added autocontrast operator # 2001-12-18 fl Added Kevin's fit operator # 2004-03-14 fl Fixed potential division by zero in equalize +# 2005-05-05 fl Fixed equalize for low number of values # # Copyright (c) 2001-2004 by Secret Labs AB # Copyright (c) 2001-2004 by Fredrik Lundh @@ -207,13 +208,18 @@ h = image.histogram(mask) lut = [] for b in range(0, len(h), 256): - step = reduce(operator.add, h[b:b+256]) / 255 - if step == 0: - step = 1 - n = 0 - for i in range(256): - lut.append(n / step) - n = n + h[i+b] + histo = filter(None, h[b:b+256]) + if len(histo) <= 1: + lut.extend(range(256)) + else: + step = (reduce(operator.add, histo) - histo[-1]) / 255 + if not step: + lut.extend(range(256)) + else: + n = step / 2 + for i in range(256): + lut.append(n / step) + n = n + h[i+b] return _lut(image, lut) ## From jelle.feringa at ezct.net Sat May 7 12:27:18 2005 From: jelle.feringa at ezct.net (Jelle Feringa / EZCT Architecture & Design Research) Date: Sat, 7 May 2005 12:27:18 +0200 Subject: [Image-SIG] loading PIL image to pygame without the need to write a temporary image file Message-ID: <20050507102404.073071E4003@bag.python.org> Hi, I'm working on a script where I blend frames according to their visual difference. So if there's not too much difference, you'll have a swift fade-in, if the difference between the two frames is greater, the fade-in will last longer. Simple idea, but very effective, so cool to be able to do that kind of thing < 15 minutes in PIL & python. I'm using this sequence to write directly to mpeg2 output, and that's where things mess up. I use PyMedia (worth checking out!) to encode to mpeg2 files. My guess was that pilmage.tostring() would be quite similar to pygame's pygame.image.tostring(img, "RGB") function. That unfortuanately isn't the case. When I use the PIL function to encode to a string, the program crashes after a couple of frames, and works fine with the pygame string function. Since I use a PIL blend method to get the magic done, I'm trying to find a way to load the image into pygame without needing to write a temporary image file. And that's where I'm left clueless. I'm fairly new to python, and this is the kind of thing that still gets me stuck. So I hope to be able to learn from someone's experience facing a similar problem. Cheers, Jelle From fredrik at pythonware.com Sat May 7 12:29:07 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 7 May 2005 12:29:07 +0200 Subject: [Image-SIG] downscaling by area averaging References: <427ACFA4.6070602@paradise.net.nz> <427C1FD4.70700@paradise.net.nz> Message-ID: Douglas Bagnall wrote: > > + I'm beginning to wonder if there's not an off-by-something error > > lurking somewhere in stretch. hmm... > > In my tests, all the resize and stretch filters appear to shift the > image down and to the right by about half an output pixel. Assuming > my controls images are right... I've attached a (preliminary) patch. Index: libImaging/Antialias.c =================================================================== --- libImaging/Antialias.c (revision 2394) +++ libImaging/Antialias.c (working copy) @@ -145,7 +145,7 @@ if (imIn->xsize == imOut->xsize) { /* vertical stretch */ for (yy = 0; yy < imOut->ysize; yy++) { - center = yy * scale; + center = (yy + 0.5) * scale; ww = 0.0; ss = 1.0 / filterscale; /* calculate filter weights */ @@ -222,7 +222,7 @@ } else { /* horizontal stretch */ for (xx = 0; xx < imOut->xsize; xx++) { - center = xx * scale; + center = (xx + 0.5) * scale; ww = 0.0; ss = 1.0 / filterscale; xmin = floor(center - support); From fredrik at pythonware.com Sat May 7 14:41:01 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 7 May 2005 14:41:01 +0200 Subject: [Image-SIG] loading PIL image to pygame without the need to write atemporary image file References: <20050507102404.073071E4003@bag.python.org> Message-ID: Jelle Feringa wrote: > My guess was that pilmage.tostring() would be quite similar to pygame's > pygame.image.tostring(img, "RGB") function. That unfortuanately isn't the > case. judging from the pygame documentation, they do the exact same thing (but with slightly different arguments). according to the documentation, the following should work: mode = image.mode size = image.size data = image.tostring() assert mode in "RGB", "RGBA" surface = pygame.image.fromstring(data, size, mode) (and you could probably use frombuffer instead of fromstring). > When I use the PIL function to encode to a string, the program crashes after > a couple of frames, and works fine with the pygame string function. it crashes and works fine? how does it crash? traceback? coredump? what crashes and what works? From jelle.feringa at ezct.net Sat May 7 16:25:16 2005 From: jelle.feringa at ezct.net (Jelle Feringa / EZCT Architecture & Design Research) Date: Sat, 7 May 2005 16:25:16 +0200 Subject: [Image-SIG] loading PIL image to pygame without the need to Message-ID: <20050507142109.4BC691E4003@bag.python.org> Hi Frederik, That definitely solved my troubles, thanks a lot! Sorry for the crash confusion; PyMedia so far has no polite way of saying 'the data you supplied is corrupt' but grinds python to a halt. Is use the following code now, which is working just swell! Cheers, Jelle. img = pygame.image.frombuffer(blend.tostring(), blend.size, blend.mode) img = pygame.image.tostring(img, "RGB") bmpFrame= vcodec.VFrame(vcodec.formats.PIX_FMT_RGB24, sizeBlend, (blend.tostring(),None,None)) print 'bmpFrame' yuvFrame= bmpFrame.convert(vcodec.formats.PIX_FMT_YUV420P) print 'yuvFrame' d = e.encode(yuvFrame) print 'encode yuv - frame' video.write(d) print 'write frame to video file' From m.thomas at ucl.ac.uk Sun May 8 18:48:31 2005 From: m.thomas at ucl.ac.uk (Mark Thomas) Date: Sun, 08 May 2005 17:48:31 +0100 Subject: [Image-SIG] Help with PIL - importing CGM files. Message-ID: Does anybody know how I can import / load CGM image files into the Python Imaging Library? It seems odd to me that this isn't one of the standard recognized formats for PIL since it is the main output file format for a number of python graphics modules (gist, oog etc). Thanks Mark -- Dr Mark Thomas Department of Biology University College London Gower Street London WC1E 6BT Tel: (020) 7 679 2654 Fax: (020) 7 679 7096 Mobile: 07973 725955 Email: m.thomas at ucl.ac.uk Web: www.ucl.ac.uk/tcga/ From lbolognini at gmail.com Tue May 10 01:31:12 2005 From: lbolognini at gmail.com (Lorenzo Bolognini) Date: Tue, 10 May 2005 00:31:12 +0100 Subject: [Image-SIG] CAPTCHA antibot Message-ID: Hi all, first post here ;) i'm trying to do this: from PIL import Image, ImageDraw, ImageFont im = Image.new("RGB", (150,70), "#fff") draw = ImageDraw.Draw(im, "RGB") font = ImageFont.truetype("trebuc.ttf", 30) draw.text((20,20), "Hello World!", fill="#ff0000", font=font) im.save("C:\\pippo.png", "PNG") Trying to achieve something like this: http://www.google.com/accounts/ Google doesn't have a complex antibot protection but it's cute and it's good enough for me. What I'm missing in the code above is the deformation which the PIL documentation says it's supposed to be achieved by instatiating a deform object. I searched this ML archives but the only question on this subject got unanswered. So the question is: how do I create a deform object? Thanks everybody, Lorenzo From douglas at paradise.net.nz Tue May 10 06:07:36 2005 From: douglas at paradise.net.nz (Douglas Bagnall) Date: Tue, 10 May 2005 16:07:36 +1200 Subject: [Image-SIG] CAPTCHA antibot In-Reply-To: References: Message-ID: <42803388.50308@paradise.net.nz> Lorenzo Bolognini wrote: > from PIL import Image, ImageDraw, ImageFont > im = Image.new("RGB", (150,70), "#fff") > draw = ImageDraw.Draw(im, "RGB") > font = ImageFont.truetype("trebuc.ttf", 30) > draw.text((20,20), "Hello World!", fill="#ff0000", font=font) > im.save("C:\\pippo.png", "PNG") [...] > So the question is: how do I create a deform object? ImageOps.deform is precisely this: def deform(image, deformer, resample=Image.BILINEAR): "Deform image using the given deformer" return image.transform( image.size, Image.MESH, deformer.getmesh(image), resample ) so a deformer object is something with a getmesh method that returns a deformation mesh in response to an image. Your deformer object could do something like find the pixel length of the word and return the appropriate filter. But you probably don't need that. A simple quad filter might be enough: # corner co-ordinates, anticlockwise from top left corners = (15,15, 18,60, 140,50, 130,10) im.transform(im.size, Image.QUAD, corners, Image.BICUBIC).save("/tmp/pippo2.png") > Trying to achieve something like this: > http://www.google.com/accounts/ I think you mean https://www.google.com/accounts/NewAccount douglas From douglas at paradise.net.nz Fri May 13 03:56:12 2005 From: douglas at paradise.net.nz (Douglas Bagnall) Date: Fri, 13 May 2005 13:56:12 +1200 Subject: [Image-SIG] another out by 0.5 patch In-Reply-To: References: <427ACFA4.6070602@paradise.net.nz> <427C1FD4.70700@paradise.net.nz> Message-ID: <4284093C.10104@paradise.net.nz> Fredrik Lundh wrote: >>In my tests, all the resize and stretch filters appear to shift the >>image down and to the right by about half an output pixel. > > I've attached a (preliminary) patch. > It certainly works for me. Area-averaged and stretched images are mostly visually indistinguishable -- the exceptions being high contrast drawings. Stretch-resized images are consistently 1/256th darker than the same images resized by other means. My understanding of this is that when a region of input pixels is (say) all 255s, except for one pixel of 254, then the float average is 254.9xx, so the output pixel becomes 254. On average this should darken by 0.5, but over the two passes, it darkens by a unit. I've attached a patch. Here's an example, resizing a 450x325 image to 16x12 (as seen on http://halo.gen.nz/pil/examples.html), showing mean, RMS, and extreme differences between pixels. before the patch, comparing stretched(NEAREST) to gimp: R: mean: 1.020833 RMS: 1.190238, extrema: (-2.0, 4.0) G: mean: 0.973958 RMS: 1.120361, extrema: (-1.0, 4.0) B: mean: 0.911458 RMS: 1.058202, extrema: (-1.0, 3.0) with the patch: R: mean: 0.010417 RMS: 0.595119, extrema: (-3.0, 3.0) G: mean: 0.000000 RMS: 0.595119, extrema: (-2.0, 3.0) B: mean: -0.08854 RMS: 0.535218, extrema: (-2.0, 2.0) Contrary to my earlier assertion, I have discovered the area averaged images differ from the gimp on the bottom row of the image. comparing area-averaged to gimp: R: mean: 0.041667 RMS: 0.204124, extrema: (0.0, 1.0) G: mean: 0.052083 RMS: 0.228218, extrema: (0.0, 1.0) B: mean: 0.020833 RMS: 0.144338, extrema: (0.0, 1.0) douglas -------------- next part -------------- A non-text attachment was scrubbed... Name: pil-antialias.diff Type: text/x-patch Size: 2276 bytes Desc: not available Url : http://mail.python.org/pipermail/image-sig/attachments/20050513/38fefd50/pil-antialias.bin From simon.clay at imperial.ac.uk Fri May 13 19:33:45 2005 From: simon.clay at imperial.ac.uk (Simon Clay) Date: Fri, 13 May 2005 18:33:45 +0100 Subject: [Image-SIG] Installing: "The _imaging C module is not installed" Message-ID: <20050513173345.GA23794@imperial.ac.uk> Hi. I'm trying to install PIL with python 2.3.3 on a Debian Linux box. There are no errors from setup.py, and the summary looks like this: -------------------------------------------------------------------- PIL 1.1.5 BUILD SUMMARY -------------------------------------------------------------------- version 1.1.5 platform linux2 2.3.3 (#1, May 6 2004, 13:40:17) [GCC 2.95.4 20011002 (Debian prerelease)] -------------------------------------------------------------------- *** TKINTER support not available --- JPEG support ok --- ZLIB (PNG/ZIP) support ok --- FREETYPE2 support ok -------------------------------------------------------------------- Then I run selftest.py, and get: *** The _imaging C module is not installed Some quick googling turned up this list, and: http://effbot.org/zone/pil-imaging-not-installed.htm which talks about this very problem. Following the instructions there, all is well until: >>> import _imaging Traceback (most recent call last): File "", line 1, in ? ImportError: /home/simon/python/tmp/Imaging-1.1.5/PIL/_imaging.so: undefined symbol: __ctype_b_loc I'm not quite sure where to go from here. Any suggestions are welcome... Simon. From fredrik at pythonware.com Fri May 13 21:06:21 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 13 May 2005 21:06:21 +0200 Subject: [Image-SIG] Installing: "The _imaging C module is not installed" References: <20050513173345.GA23794@imperial.ac.uk> Message-ID: Simon Clay wrote: > >>> import _imaging > Traceback (most recent call last): > File "", line 1, in ? > ImportError: /home/simon/python/tmp/Imaging-1.1.5/PIL/_imaging.so: > undefined symbol: __ctype_b_loc > > I'm not quite sure where to go from here. Any suggestions are > welcome... judging from http://lists.debian.org/debian-glibc/2003/06/msg00062.html your gcc install seems to be somewhat botched. From eachand at gmail.com Mon May 9 19:02:59 2005 From: eachand at gmail.com (Aman) Date: Mon, 9 May 2005 10:02:59 -0700 Subject: [Image-SIG] Tif Handling routines Message-ID: <5dc4aea70505091002aae2c46@mail.gmail.com> Hello Folks Am new to python and trying to put up a prototype Tiff image splitter and merger could i get some one to help me start it off or if you have source codes it will be most welcomed.Pressed for time Cheers Edmond -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20050509/b2e6e908/attachment.html From fredrik at pythonware.com Fri May 13 22:06:43 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 13 May 2005 22:06:43 +0200 Subject: [Image-SIG] Tif Handling routines References: <5dc4aea70505091002aae2c46@mail.gmail.com> Message-ID: "Aman" wrote: > Am new to python and trying to put up a prototype Tiff image splitter and > merger could i get some one to help me start it off or if you have source > codes it will be most welcomed.Pressed for time if you're pressed for time, I suggest using the tiffsplit and tiffcp utilities included in the libtiff package: http://www.libtiff.org/ you can use Python's subprocess module to run the commands from Python. From stuartaw at gmail.com Mon May 16 03:37:08 2005 From: stuartaw at gmail.com (qzm) Date: Mon, 16 May 2005 13:37:08 +1200 Subject: [Image-SIG] PIL 1.1.5+window 2000 problem. Message-ID: <8046ffd605051518374b3cffbe@mail.gmail.com> Just wondering if anyone has ever seen this. I just hit a problem with the binary install of PIL1.1.5 on a windows 2000 machine with python 2.4.1, when I load a tga it comes out as an incorrect size, and nothing else works. ie: import Image im=Image.open('test.tga') print im.size returns (2,0) when it should be (640,480) Works fine on most of the other machine around here :-/ Am going to try a rebuild from source next. Does anyone know if PIL uses an inernal library for tga, and ifnot what the external one is? perhaps that is damaged. Never seen this one before :-/ Regards, Stuart. From fredrik at pythonware.com Mon May 16 08:36:26 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 16 May 2005 08:36:26 +0200 Subject: [Image-SIG] PIL 1.1.5+window 2000 problem. References: <8046ffd605051518374b3cffbe@mail.gmail.com> Message-ID: "qzm" wrote: > I just hit a problem with the binary install of PIL1.1.5 on a windows > 2000 machine with python 2.4.1, > when I load a tga it comes out as an incorrect size, and nothing else works. > > ie: > import Image > im=Image.open('test.tga') > print im.size > > returns (2,0) > when it should be (640,480) > > Works fine on most of the other machine around here :-/ how did you transfer the file to the windows machine? are you sure didn't accidentally transfer it in text mode? (if the same file works on other platforms, feel free to mail me a copy so I can look at it). > Am going to try a rebuild from source next. > Does anyone know if PIL uses an inernal library for tga, and ifnot > what the external one is? perhaps that is damaged. PIL uses Python code to parse the TGA headers (TgaImagePlugin.py). From ronaldoussoren at mac.com Mon May 16 20:48:04 2005 From: ronaldoussoren at mac.com (Ronald Oussoren) Date: Mon, 16 May 2005 20:48:04 +0200 Subject: [Image-SIG] setup.py and automaticly detecting freetype2 Message-ID: <393A6956-61DE-4740-9825-C1F95ADB8D4A@mac.com> Hi, The setup.py in Imageing-1.1.5 tries to autodetect if, and which, freetype is installed. This fails to consider the --include-dirs command-line option. I've freetype2 (as well as libjpeg and libtiff) installed in /opt/ local, which is not on the default search-path of distutils. Hence I built the extensions using:: python setup.py build_ext --include-dirs=/opt/local/include -- library-dirs=/opt/local/lib This works for the detection of libjpeg and libtiff because that code looks at the library path of self.compiler. The freetype configuration code also tries to find the freetype2 include-file. This only looks at a path that's hardcoded in setup.py, and ignores the include-path of self.compiler. IMHO this code should look at self.compiler.include_dirs instead of just include_dirs (setup.py around line 216) Regards, Ronald -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2105 bytes Desc: not available Url : http://mail.python.org/pipermail/image-sig/attachments/20050516/e801ef94/smime.bin From djarb at highenergymagic.org Mon May 16 22:52:52 2005 From: djarb at highenergymagic.org (Daniel Arbuckle) Date: Mon, 16 May 2005 13:52:52 -0700 Subject: [Image-SIG] PIL patch Message-ID: <20050516205252.GA9761@highenergymagic.org> The following patch should be applied to OleFileIO.py: 298c298 < if ix == 0xFFFFFFFEL or x == 0xFFFFFFFFL: --- > if ix == 0xFFFFFFFEL or ix == 0xFFFFFFFFL: From fredrik at pythonware.com Tue May 17 08:09:42 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 17 May 2005 08:09:42 +0200 Subject: [Image-SIG] PIL patch References: <20050516205252.GA9761@highenergymagic.org> Message-ID: Daniel Arbuckle write; > The following patch should be applied to OleFileIO.py: > > 298c298 > < if ix == 0xFFFFFFFEL or x == 0xFFFFFFFFL: > --- > > if ix == 0xFFFFFFFEL or ix == 0xFFFFFFFFL: thanks, but you're almost two years late: --- OleFileIO.py (revision 260) +++ OleFileIO.py (revision 261) @@ -11,6 +11,7 @@ # History: # 1997-01-20 fl Created # 1997-01-22 fl Fixed 64-bit portability quirk +# 2003-09-09 fl Fixed typo in OleFileIO.loadfat (noted by Daniel Haertle) # # Notes: # FIXME: change filename to use "a/b/c" instead of ["a", "b", "c"] @@ -295,7 +296,7 @@ fat = [] for i in range(0, len(sect), 4): ix = i32(sect, i) - if ix == 0xFFFFFFFEL or x == 0xFFFFFFFFL: + if ix == 0xFFFFFFFEL or ix == 0xFFFFFFFFL: break s = self.getsect(ix) fat = fat + map(lambda i, s=s: i32(s, i), range(0, len(s), 4)) From franz at trispen.com Fri May 20 13:33:07 2005 From: franz at trispen.com (Franz Struwig) Date: Fri, 20 May 2005 13:33:07 +0200 Subject: [Image-SIG] PIL Plus and ImageCrackCode Message-ID: Greetings, I'm new to Python and trying to use PIL to: a) Cross-correlate two images - i.e shift/scale/rotate the one image until they produce the best match. b) Find the Center Of Gravity of each letter on a page. Any advice or help in the above tasks would be greatly appreciated! I see that the ImageCrackCode module is able to calculate the Center Of Gravity of "features" on a page. Unfortunately I haven't been able to use the module - I don't think I have PIL Plus. What is PIL Plus, and how can I get it? Thanks, Franz From fredrik at pythonware.com Fri May 20 16:12:23 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 20 May 2005 16:12:23 +0200 Subject: [Image-SIG] PIL Plus and ImageCrackCode References: Message-ID: Franz Struwig wrote: > What is PIL Plus, and how can I get it? PIL Plus (aka imToolkit) was a commercial extension to Python, that was available to PIL Support customers. the PIL Plus ex- tension is no longer available: http://www.pythonware.com/products/pil/plus.htm From andy_chamberlain at yahoo.co.uk Tue May 24 17:41:45 2005 From: andy_chamberlain at yahoo.co.uk (Andrew Chamberlain) Date: Tue, 24 May 2005 16:41:45 +0100 (BST) Subject: [Image-SIG] PIL 1.1.6 (ImageMath) Message-ID: <20050524154145.85414.qmail@web25208.mail.ukl.yahoo.com> Hello, I was just wondering when PIL 1.1.6 might be released (or even a beta version of it)? The reason I ask is because I'm trying to calculate a ratio image between two bands in an RGB image, and was hoping the ImageMath module in 1.1.5 might be able to help. I've looked at possibilities in 1.1.5, including the ImageChops module, a division operator doesn't seem to be available at the moment. Many thanks in advance, Andy Chamberlain ___________________________________________________________ How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com From rzantow at ntelos.net Wed May 25 03:16:16 2005 From: rzantow at ntelos.net (rzed) Date: Tue, 24 May 2005 21:16:16 -0400 Subject: [Image-SIG] Regarding Wide lines in PIL In-Reply-To: <20050524154145.85414.qmail@web25208.mail.ukl.yahoo.com> References: <20050524154145.85414.qmail@web25208.mail.ukl.yahoo.com> Message-ID: <4293D1E0.1070608@ntelos.net> If I have the correct version of the PIL code, specifying the new width parameter to ImageDraw's line() function results in a line of twice the specified thickness. It appears to be because, in ImagingDrawWideLine (Draw.c), the width is both added to and subtracted from the line positions. If dx and dy were halved, the specification should work correctly (within rounding limits, anyway). dx = (int) (d * (y1-y0) + 0.5); dy = (int) (d * (x1-x0) + 0.5); add_edge(e+0, x0 - dx, y0 + dy, x1 - dx, y1 + dy); add_edge(e+1, x1 - dx, y1 + dy, x1 + dx, y1 - dy); add_edge(e+2, x1 + dx, y1 - dy, x0 + dx, y0 - dy); add_edge(e+3, x0 + dx, y0 - dy, x0 - dx, y0 + dy); To an extent, it can be worked around by halving the width specification, of course. -- rzed From douglas at paradise.net.nz Wed May 25 04:36:49 2005 From: douglas at paradise.net.nz (Douglas Bagnall) Date: Wed, 25 May 2005 14:36:49 +1200 Subject: [Image-SIG] PIL 1.1.6 (ImageMath) In-Reply-To: <20050524154145.85414.qmail@web25208.mail.ukl.yahoo.com> References: <20050524154145.85414.qmail@web25208.mail.ukl.yahoo.com> Message-ID: <4293E4C1.7090407@paradise.net.nz> Andrew Chamberlain wrote: > The reason I ask is because I'm trying to calculate a > ratio image between two bands in an RGB image, and was hoping the > ImageMath module in 1.1.5 might be able to help. If speed does not matter much, something like this should work: im = Image.open('some rgb image') im2 = Image.new('L', im.size) SCALE = 128 ratios = [min(int(SCALE * r / (g + 0.01)), 255) for r, g, b in im.getdata()] im2.putdata(ratios) im2.save('/tmp/ratio.png') douglas From fredrik at pythonware.com Wed May 25 08:50:57 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 25 May 2005 08:50:57 +0200 Subject: [Image-SIG] PIL 1.1.6 (ImageMath) References: <20050524154145.85414.qmail@web25208.mail.ukl.yahoo.com> Message-ID: Andrew Chamberlain wrote: > I was just wondering when PIL 1.1.6 might be released (or even a beta > version of it)? The reason I ask is because I'm trying to calculate a > ratio image between two bands in an RGB image, and was hoping the > ImageMath module in 1.1.5 might be able to help. you can get a sneak alpha release here (source only): http://effbot.org/downloads/#Imaging From fredrik at pythonware.com Wed May 25 22:42:56 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 25 May 2005 22:42:56 +0200 Subject: [Image-SIG] Regarding Wide lines in PIL References: <20050524154145.85414.qmail@web25208.mail.ukl.yahoo.com> <4293D1E0.1070608@ntelos.net> Message-ID: "rzed" wrote: > If I have the correct version of the PIL code, specifying the new width > parameter to ImageDraw's line() function results in a line of twice the > specified thickness. It appears to be because, in ImagingDrawWideLine > (Draw.c), the width is both added to and subtracted from the line > positions. If dx and dy were halved, the specification should work > correctly (within rounding limits, anyway). > > dx = (int) (d * (y1-y0) + 0.5); > dy = (int) (d * (x1-x0) + 0.5); > > add_edge(e+0, x0 - dx, y0 + dy, x1 - dx, y1 + dy); > add_edge(e+1, x1 - dx, y1 + dy, x1 + dx, y1 - dy); > add_edge(e+2, x1 + dx, y1 - dy, x0 + dx, y0 - dy); > add_edge(e+3, x0 + dx, y0 - dy, x0 - dx, y0 + dy); > > To an extent, it can be worked around by halving the width > specification, of course. I've attached the 'official' patch. Index: libImaging/Draw.c =================================================================== --- libImaging/Draw.c (revision 2434) +++ libImaging/Draw.c (working copy) @@ -674,7 +675,7 @@ return 0; } - d = width / sqrt(dx*dx + dy*dy); + d = width / sqrt(dx*dx + dy*dy) / 2.0; dx = (int) (d * (y1-y0) + 0.5); dy = (int) (d * (x1-x0) + 0.5); From TeXSatz at uni-bremen.de Wed May 25 23:15:12 2005 From: TeXSatz at uni-bremen.de (LML) Date: Wed, 25 May 2005 23:15:12 +0200 Subject: [Image-SIG] PIL 1.1.5 polygon filling off by one vertical pixel, alpha blended drawing? Message-ID: <4294EAE0.8070701@uni-bremen.de> Hi all, the ImageDraw.Draw.polygon function does not draw as I expect it. Deep down in the C-code some Floor, Ceil and +0.5 seem to combine for a strange effect. 1. Any suggestions to actually draw within the outline only? 2. Why can't I draw with alpha-blending (it seems like I have to im.paste to achieve this -- so inefficient...) 3. Do I have to destruct the Draw instance with del explicitly (like it's done in the example code) or is the implicit destruction enough to get it freed? 4. Is ImagePath.Path more efficient or just syntactic sugar? Code to show the effect: #piltest.py import Image, ImageDraw def save(image, fname='save.png'): W = file(fname, 'wb') image.save(W) W.close() def testpic(): """Test polygon, line etc. drawing.""" im = Image.new('RGBA', (100,100)) D = ImageDraw.Draw(im) fi=(0xbf, 0xbf, 0xbf, 0x7f) D.line([(39,0),(39,100)],fill=fi) #vertical lines D.line([(50,0),(50,100)],fill=fi) D.line([(61,0),(61,100)],fill=fi) D.line([(0,39),(100,39)],fill=fi) #horizontal lines D.line([(0,50),(100,50)],fill=fi) D.line([(0,61),(100,61)],fill=fi) fi=(0xbf, 0x00, 0x00, 0x7f) #red ou=(0x7f, 0x00, 0x00, 0x7f) D.polygon([(40, 40), (40, 60), (60, 60), (60, 40)], fill=fi, outline=ou) D.polygon([(10, 10), (10, 30), (30, 30), (30, 10)], fill=fi, outline=ou) D.polygon([(70, 10), (71, 30), (91, 30), (90, 10)], fill=fi, outline=ou) fi=(0x00, 0xbf, 0x00, 0x7f) #green ou=(0x00, 0x7f, 0x00, 0x7f) D.polygon([(20, 70), (10, 80), (20, 90), (30, 80)], fill=fi, outline=ou) D.polygon([(81, 70), (70, 80), (80, 90), (91, 80)], fill=fi, outline=ou) D.polygon([(50, 40), (40, 50), (50, 60), (60, 50)], fill=fi, outline=ou) D.point([(0, 0)],fill='red') #mark origin save(im) the resulting save.png is attached -- hopefully small enough ;-) I intend to use the polygon function to draw land/coastlines combined with satellite (point) data -- that's where the alpha blending is supposed to enter the picture... Thanks for your help. \bye Lothar (Meyer-Lerbs, Bremen, Germany) -------------- next part -------------- A non-text attachment was scrubbed... Name: save.png Type: image/png Size: 1780 bytes Desc: not available Url : http://mail.python.org/pipermail/image-sig/attachments/20050525/ec945c03/save.png From fredrik at pythonware.com Thu May 26 08:54:08 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 26 May 2005 08:54:08 +0200 Subject: [Image-SIG] PIL 1.1.5 polygon filling off by one vertical pixel, alpha blended drawing? References: <4294EAE0.8070701@uni-bremen.de> Message-ID: "LML" wrote: > the ImageDraw.Draw.polygon function does not draw as I expect it. > Deep down in the C-code some Floor, Ceil and +0.5 seem to combine > for a strange effect. can you elaborate: from a quick look, the image seems to match the code pretty well. > 1. Any suggestions to actually draw within the outline only? > 2. Why can't I draw with alpha-blending (it seems like I > have to im.paste to achieve this -- so inefficient...) recent versions support RGBA-on-RGB drawing; from the CHANGES document: + Added experimental RGBA-on-RGB drawing support. To use RGBA colours on an RGB image, pass "RGBA" as the second string to the ImageDraw.Draw constructor. > 3. Do I have to destruct the Draw instance with del explicitly > (like it's done in the example code) > or is the implicit destruction enough to get it freed? no. normal garbage collection works here. > 4. Is ImagePath.Path more efficient or just syntactic sugar? Path is more efficient if you need to scale/transform the data before you draw. If you're doing the calculations elsewhere, you can use any input format. From fredrik at pythonware.com Thu May 26 10:13:15 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 26 May 2005 10:13:15 +0200 Subject: [Image-SIG] PIL 1.1.5 polygon filling off by one vertical pixel, alpha blended drawing? References: <4294EAE0.8070701@uni-bremen.de> Message-ID: >> the ImageDraw.Draw.polygon function does not draw as I expect it. >> Deep down in the C-code some Floor, Ceil and +0.5 seem to combine >> for a strange effect. > > can you elaborate: from a quick look, the image seems to match > the code pretty well. oh, never mind. I'll look into this. From Ryan.Hruska at inl.gov Thu May 26 19:08:09 2005 From: Ryan.Hruska at inl.gov (Ryan C Hruska) Date: Thu, 26 May 2005 11:08:09 -0600 Subject: [Image-SIG] PIL / gdal_translate Message-ID: I am using PIL to process aerial imagery and would like to translate it from the sensor's frame coordinate system to a world coordinate system (UTM) using GPS/INS data collected at the time exposure. I am using python to calculate the UTM coordinates for the image corners and perspective center based on the camera model, but I haven't had any luck applying this to the imagery. It was suggested that I use gdal_translate utility to accomplish this. Anyway, is it possible to call the gdal_translate.exe utility from python and pass it the required parameters? I am using the Pythonwin development environment. Any help or guidance would be appreciated. Ryan -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20050526/3618345e/attachment.htm -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/gif Size: 19670 bytes Desc: not available Url : http://mail.python.org/pipermail/image-sig/attachments/20050526/3618345e/attachment.gif From fredrik at pythonware.com Thu May 26 19:40:24 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 26 May 2005 19:40:24 +0200 Subject: [Image-SIG] PIL / gdal_translate References: Message-ID: Ryan C Hruska wrote: > I am using PIL to process aerial imagery and would like to translate it > from the sensor's frame coordinate system to a world coordinate system > (UTM) using GPS/INS data collected at the time exposure. I am using python > to calculate the UTM coordinates for the image corners and perspective > center based on the camera model, but I haven't had any luck applying this > to the imagery. It was suggested that I use gdal_translate utility to > accomplish this. > > Anyway, is it possible to call the gdal_translate.exe utility from python > and pass it the required parameters? I am using the Pythonwin development > environment. Any help or guidance would be appreciated. start here: http://www.python.org/dev/doc/devel/lib/module-subprocess.html if you're using Python 2.2 or 2.3, you can download a subprocess installer here: http://effbot.org/downloads/#subprocess From john.ertl at fnmoc.navy.mil Fri May 27 22:48:52 2005 From: john.ertl at fnmoc.navy.mil (Ertl, John) Date: Fri, 27 May 2005 13:48:52 -0700 Subject: [Image-SIG] Error when trying to open a .ps file Message-ID: All, I am trying to open a .ps file and then eventually convert it to a .png but I cannot even open it. If I use a postscript viewer I can view the image so I think the image is O.K. I am using Python 2.4 on RH ES 3.0 and PIL 1.1.5. I have been doing some work with other formats it has been great so I think PIL is installed correctly but I have just had no luck with .ps files. Any ideas? >>> im = Image.open("test.ps") Traceback (most recent call last): File "", line 1, in -toplevel- im = Image.open("test.ps") File "/opt/global/python/python-2.4/lib/python2.4/site-packages/PIL/Image.py", line 1730, in open return factory(fp, filename) File "/opt/global/python/python-2.4/lib/python2.4/site-packages/PIL/ImageFile.py" , line 82, in __init__ self._open() File "/opt/global/python/python-2.4/lib/python2.4/site-packages/PIL/EpsImagePlugi n.py", line 277, in _open raise IOError, "cannot determine EPS bounding box" IOError: cannot determine EPS bounding box Thanks, John C. Ertl Fleet Numerical Meteorology & Oceanography Center 7 Grace Hopper Ave Monterey, CA 93943 phone: (831) 656-5704 fax: (831) 656-4363 From fredrik at pythonware.com Sat May 28 13:23:27 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 28 May 2005 13:23:27 +0200 Subject: [Image-SIG] Error when trying to open a .ps file References: Message-ID: "Ertl, John" wrote: > I am trying to open a .ps file and then eventually convert it to a .png but > I cannot even open it. If I use a postscript viewer I can view the image > so I think the image is O.K. I am using Python 2.4 on RH ES 3.0 and PIL > 1.1.5. I have been doing some work with other formats it has been great so > I think PIL is installed correctly but I have just had no luck with .ps > files. > > Any ideas? > > >>> im = Image.open("test.ps") > > Traceback (most recent call last): > File "", line 1, in -toplevel- > im = Image.open("test.ps") > File > "/opt/global/python/python-2.4/lib/python2.4/site-packages/PIL/Image.py", > line 1730, in open > return factory(fp, filename) > File > "/opt/global/python/python-2.4/lib/python2.4/site-packages/PIL/ImageFile.py" > , line 82, in __init__ > self._open() > File > "/opt/global/python/python-2.4/lib/python2.4/site-packages/PIL/EpsImagePlugi > n.py", line 277, in _open > raise IOError, "cannot determine EPS bounding box" > IOError: cannot determine EPS bounding box PIL can only open EPS files (a variant of PS designed for embedding), and it looks like your PS file isn't an EPS. I suggest running it directly through Ghostscript (in batch mode), and processing the output instead. From 550283447739-0001 at t-online.de Tue May 31 11:03:12 2005 From: 550283447739-0001 at t-online.de (Oliver Albrecht) Date: Tue, 31 May 2005 11:03:12 +0200 Subject: [Image-SIG] Help colors Message-ID: <429C2850.6010804@t-online.de> Greetings, I'm new to Python and trying to use PIL to: - Wich Colorreduce Method used PIL other as "Web"? "Octree" , "Median" ? - Why has the GIF format double size? (I use PSP as Graphic-program ) - How discover the nearest color? x= (r1,g1,b1) - (r,g,b) y= (r2,g2,b2) - (r,g,b) if pos(x) > pos(y): nearest=y else: nearest=x I want make a script to switch the colorpalette from images. # numerate all pixel(palette_Id) MapL=list(enumerate(data_list)) # turn round nr/palette_Id MapL= [(b, [a]) for a, b in MapL] MapL.sort() Listshort=[("",[""])] # delete all double palette_Id but put the key(nr) to it for value, key in MapL: if value != Listshort[-1][0]: Listshort.append((value,key)) else: Listshort[-1][1].extend(key) Listshort=sorted(Listshort[1:]) # now load a other palette and compare this sorted(palette1,palette2) # then switch the palette_Ids in Listshort and reinsert it as im.data If it give another, better way tell it me. else i will post the completed script. tiny-fault-report: I think in the PIL-Beta-Docu this Example is an fault. http://effbot.org/imagingbook/imagepalette.htm ##Getting the Palette Contents Using Resize/Convert assert im.mode == "P" lut = im.resize((256, 1)) lut.putdata(range(256)) lut = im.convert("RGB").getdata() ^^ # lut now contains a sequence of (r, g, b) tuples "lut" has the sequence from "im" but not from "lut.putdata(range(256))" "lut" is a copy from "im" but "im" is not resized. -- From 550283447739-0001 at t-online.de Tue May 31 15:00:52 2005 From: 550283447739-0001 at t-online.de (Oliver Albrecht) Date: Tue, 31 May 2005 15:00:52 +0200 Subject: [Image-SIG] Help GIF format Message-ID: <429C6004.4040602@t-online.de> by Fredrik Lundh Jul 11 1998 > When writing GIF files, PIL uses a simpleminded encoding that, by some > odd reason, LZW decoders have no trouble reading. To write compressed > GIF files, there are a number of options: > > -- install NETPBM, and hack GifImagePlugin so it uses _save_ppm instead > of _save (just remove "_ppm" from the latter). > -- write an _imaging_gif module that takes a PIL image and writes > a GIF version of it. how you implement that is up to you... _imaging_gif has anyone this module? I try compile my model with py2exe, but it hold on GifImagePlugin on line ['_imaging_gif'] sould i delete this line!? and a additional little color question: how can i simple replace one color? here my means: im_pal=[] img_pall=im.getpalette() for RGB in xrange(0,len(img_pall),3): pal_tmp=img_pall[RGB:RGB+3] if pal_tmp==[0, 0, 132]: pal_tmp=[255, 0, 255] im_pal[RGB:RGB]=pal_tmp im.putpalette(im_pal) -- From fredrik at pythonware.com Tue May 31 15:43:00 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 31 May 2005 15:43:00 +0200 Subject: [Image-SIG] Help GIF format References: <429C6004.4040602@t-online.de> Message-ID: Oliver Albrecht wrote: > I try compile my model with py2exe, but it hold on GifImagePlugin on > line ['_imaging_gif'] sould i delete this line!? I'm pretty sure you can tell py2exe to ignore optional extensions. if you get stuck, you can replace the try/import/except statement in GifImagePlugin with a simple assignment: _imaging_gif = None From christianj at implicitnetworks.com Wed May 25 07:24:02 2005 From: christianj at implicitnetworks.com (Christian M. Jensen) Date: Wed, 25 May 2005 05:24:02 -0000 Subject: [Image-SIG] PsdImagePlugin.py Message-ID: <326A1C8DE34E8E4189BE602CE791678403F3B4@corporate.implicit.implicitnetworks.com> Anyone have any issues reading PSDs from CS? im = Image.open("test2.psd") File "C:\Python24\Lib\site-packages\PIL\Image.py", line 1745, in open raise IOError("cannot identify image file") IOError: cannot identify image file -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20050525/d4aee152/attachment.htm