From janssen at parc.com Wed Mar 1 00:14:59 2006 From: janssen at parc.com (Bill Janssen) Date: Tue, 28 Feb 2006 15:14:59 PST Subject: [Image-SIG] pildriver.py can't resize image In-Reply-To: Your message of "Tue, 28 Feb 2006 13:46:35 PST." <06Feb28.134644pst."58633"@synergy1.parc.xerox.com> Message-ID: <06Feb28.151459pst."58633"@synergy1.parc.xerox.com> This turns out to be another bug in pildriver.py: def do_resize(self): """usage: resize Resize the top image. """ ysize = int(self.do_pop()) xsize = int(self.do_pop()) image = self.do_pop() self.push(image.resize(xsize, ysize)) should be def do_resize(self): """usage: resize Resize the top image. """ ysize = int(self.do_pop()) xsize = int(self.do_pop()) image = self.do_pop() self.push(image.resize((xsize, ysize,))) Bill From fredrik at pythonware.com Wed Mar 1 20:54:14 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 1 Mar 2006 20:54:14 +0100 Subject: [Image-SIG] PIL sources now available via subversion Message-ID: thanks to the nice folks over at python-hosting.com, a number of PIL releases are now available from svn.effbot.python-hosting.com. latest alpha (currently 1.1.6a1-20051211): svn co http://svn.effbot.python-hosting.com/pil/ tagged releases: svn co http://svn.effbot.python-hosting.com/tags/pil-1.1.6a1-20051211/ svn co http://svn.effbot.python-hosting.com/tags/pil-1.1.5 svn co http://svn.effbot.python-hosting.com/tags/pil-1.1.4 svn co http://svn.effbot.python-hosting.com/tags/pil-1.1.3 svn co http://svn.effbot.python-hosting.com/tags/pil-1.1.2 svn co http://svn.effbot.python-hosting.com/tags/pil-1.1.1 source browser: http://effbot.python-hosting.com/browser/ note that this isn't the main development repository; all releases on python-hosting.com are so-called "vendor drops". also note that the trac section is read-only; for the time being, bugs and feature requests should be reported to this list. enjoy /F From jwestra at ics.ele.tue.nl Thu Mar 2 18:35:09 2006 From: jwestra at ics.ele.tue.nl (Jurjen Westra) Date: Thu, 02 Mar 2006 18:35:09 +0100 Subject: [Image-SIG] Combining PIL and Boost.Python Message-ID: <44072CCD.1080903@ics.ele.tue.nl> Hi all, I am working on a system that has already a lot of functionality exported with Boost.Python. I want to add PIL to the system. I am wondering how to do the following. In short: I want to create a totally independent library with PIL extensions. This library should be exported with Boost. I want to be able to extend PIL in my own module without touching the source code of PIL. I have played a bit already, and the way I do it now involves editing Imaging.h, _imaging.c and Image.py (and setup.py). Starting from a C/C++ function, e.g. Imaging myPILExtension(Imaging img1, Imaging img2, MyClass mc) I could export it using Boost, but how can I make sure my Boost wrapper around Imaging is considered the same as a python Image as it is now? If anybody has experience with this, please share it. I don't have much experience with exporting, so any help is very welcome! Thanks! Jurjen From bialix at ukr.net Thu Mar 2 22:34:37 2006 From: bialix at ukr.net (Alexander Belchenko) Date: Thu, 02 Mar 2006 23:34:37 +0200 Subject: [Image-SIG] Converting from 24-bit RGB to Black&White Message-ID: As part of my application I wrote simple convertor of 24-bit RGB images to greyscale and black&white (1-bit images). PIL-Handbook.pdf (for version PIL 1.1.3) description of method "im.convert(mode) => image" claims: "When translating a greyscale image into a bilevel image (mode "1"), all non-zero values are set to 255 (white). To use other thresholds, use the point method." I use PIL 1.1.5, OS Windows 2000. During testing my convertor I discover following. When I have paletted image (mode is 'P') then converting to black & white works as described in doc. If I have 'RGB' or 'L' mode image then after conversion to black & white I have dithered(?) image. Is this intended behaviour or this is a bug? Here simple script that illustrate problem: import Image im = Image.open('star24bit.bmp') im1 = im.convert('1') im1.save('out1.bmp') im2 = im.convert('L').convert('1') im2.save('out2.bmp') im3 = im.convert('P').convert('1') im3.save('out3.bmp') You can download testing source and result images at: http://www.onembedding.com/off/pil-b&w.zip -- Alexander From fredrik at pythonware.com Thu Mar 2 22:44:10 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 2 Mar 2006 22:44:10 +0100 Subject: [Image-SIG] Converting from 24-bit RGB to Black&White References: Message-ID: Alexander Belchenko wrote: > PIL-Handbook.pdf (for version PIL 1.1.3) description of method > "im.convert(mode) => image" claims: > > "When translating a greyscale image into a bilevel image (mode "1"), all > non-zero values are set to 255 (white). To use other thresholds, use the > point method." the 1.1.3 handbook is incorrect. here's the corresponding text from the draft docs: "When converting to a bilevel image (mode "1"), the source image is first converted to black and white. Resulting values larger than 127 are then set to white, and the image is dithered. To use other thresholds, use the point method." (from http://www.effbot.org/imagingbook/image.htm ) From bialix at ukr.net Thu Mar 2 23:03:20 2006 From: bialix at ukr.net (Alexander Belchenko) Date: Fri, 03 Mar 2006 00:03:20 +0200 Subject: [Image-SIG] Converting from 24-bit RGB to Black&White In-Reply-To: References: Message-ID: Fredrik Lundh ?????: > Alexander Belchenko wrote: > >>PIL-Handbook.pdf (for version PIL 1.1.3) description of method >>"im.convert(mode) => image" claims: >> >>"When translating a greyscale image into a bilevel image (mode "1"), all >>non-zero values are set to 255 (white). To use other thresholds, use the >>point method." > > the 1.1.3 handbook is incorrect. here's the corresponding text from the > draft docs: > > "When converting to a bilevel image (mode "1"), the source image is > first converted to black and white. Resulting values larger than 127 > are then set to white, and the image is dithered. To use other > thresholds, use the point method." > > (from http://www.effbot.org/imagingbook/image.htm ) I don't understand why solid green color (#00FF00) converted as mix of black and white dots (you can see this in my out1.bmp). Is this result of dithering? And why paletted image works as described in 1.1.3 manual? At the ned, I need behaviour that obtains with paletted image, so I simply convert 'RGB' first to 'P' then to '1'. This behaviour will not breaking in future releases? -- Alexander From fredrik at pythonware.com Thu Mar 2 23:23:43 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 2 Mar 2006 23:23:43 +0100 Subject: [Image-SIG] Converting from 24-bit RGB to Black&White References: Message-ID: Alexander Belchenko wrote: > I don't understand why solid green color (#00FF00) converted as mix of > black and white dots (you can see this in my out1.bmp). Is this result > of dithering? yes. when converted to luminance (grayscale), green corresponds to a gray level, not white or black: >>> import Image >>> i = Image.new("RGB", (1,1), "#00FF00") >>> i.getpixel((0,0)) (0, 255, 0) >>> i = i.convert("L") >>> i.getpixel((0,0)) 149 to represent149 in an image that only consists of 0 (black) and 255 (white), PIL uses a dither pattern to make the image look gray, on average: >>> i = Image.new("RGB", (100,100), "#00FF00") >>> i = i.convert("1") >>> i.getcolors() [(4140, 0), (5860, 255)] >>> (4140*0+5860*255)/(100*100) 149 > And why paletted image works as described in 1.1.3 manual? conversion to P uses dithering too, so it's probably only your choice of colors that makes things work as you want when you do this. if you want full control of the graylevel-to-bilevel mapping, and you don't want dithering, I'd recommend converting first to "L", and then using the point method with a suitable lookup table to convert to "1": im = im.convert("L") # get luminance im = im.point(table, "1") From fredrik at pythonware.com Sat Mar 4 08:18:55 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 4 Mar 2006 08:18:55 +0100 Subject: [Image-SIG] ANN: PIL 1.1.6 alpha 1 (december 11, 2005) Message-ID: The second PIL 1.1.6 alpha is now available from the public subversion server: $ svn co http://svn.effbot.python-hosting.com/tags/pil-1.1.6a2-20060303 If you prefer to use the latest alpha, use this command instead: $ svn co http://svn.effbot.python-hosting.com/pil (note that the latter points to the latest "stable alpha or beta", not the development trunk, and should be relatively safe to use in any project that don't necessarily need a proper "final" release) This release mostly contains bug fixes, including an updated Sane driver with better support for duplex scanning. For more information, see: http://svn.effbot.org/tags/pil-1.1.6a2-20060303/CHANGES Report bugs to this list as usual. (bugs in the alpha/beta releases can also be reported directly to me, if you prefer) enjoy /F From fredrik at pythonware.com Sat Mar 4 08:44:25 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 4 Mar 2006 08:44:25 +0100 Subject: [Image-SIG] ANN: PIL 1.1.6 alpha 2 (march 3, 2006) Message-ID: (reposted with correct subject line, and correct amount of coffein) The second PIL 1.1.6 alpha is now available from the public subversion server: $ svn co http://svn.effbot.python-hosting.com/tags/pil-1.1.6a2-20060303 If you prefer to use the latest alpha, whatever it is, use this command instead: $ svn co http://svn.effbot.python-hosting.com/pil (note that the latter points to the latest "stable alpha or beta", not the development trunk, and should be relatively safe to use in any project that don't necessarily need a proper "final" release) This release mostly contains bug fixes, including an updated Sane driver with better support for duplex scanning. For more information, see: http://svn.effbot.org/tags/pil-1.1.6a2-20060303/CHANGES Report bugs to this list as usual. (bugs in the alpha/beta releases can also be reported directly to me, if you prefer) enjoy /F From hughett at bbl.med.upenn.edu Tue Mar 7 18:51:13 2006 From: hughett at bbl.med.upenn.edu (Paul Hughett) Date: Tue, 7 Mar 2006 12:51:13 -0500 Subject: [Image-SIG] Announcing another Python imaging package? Message-ID: <200603071751.k27HpD4D011855@mercur.uphs.upenn.edu> I have been developing an open-source Python extension module for volume image processing, particularly medical imaging. Would it be appropriate for me to announce new releases of that package on this list? Paul Hughett -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. From michele.petrazzo at unipex.it Tue Mar 7 19:27:00 2006 From: michele.petrazzo at unipex.it (Michele Petrazzo) Date: Tue, 07 Mar 2006 19:27:00 +0100 Subject: [Image-SIG] Announcing another Python imaging package? In-Reply-To: <200603071751.k27HpD4D011855@mercur.uphs.upenn.edu> References: <200603071751.k27HpD4D011855@mercur.uphs.upenn.edu> Message-ID: <440DD074.8020404@unipex.it> Paul Hughett wrote: > I have been developing an open-source Python extension module for > volume image processing, particularly medical imaging. Would it be > appropriate for me to announce new releases of that package on this > list? Yes, someone (one of the developers that follow this list) say me when I made an announce on comp.lang.python of my image library, that this is the right place to do it, so you are welcome! > > > Paul Hughett > Michele From fredrik at pythonware.com Tue Mar 7 20:43:58 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 7 Mar 2006 20:43:58 +0100 Subject: [Image-SIG] Announcing another Python imaging package? References: <200603071751.k27HpD4D011855@mercur.uphs.upenn.edu> Message-ID: Paul Hughett wrote: > I have been developing an open-source Python extension module for > volume image processing, particularly medical imaging. Would it be > appropriate for me to announce new releases of that package on this > list? absolutely! From hughett at bbl.med.upenn.edu Tue Mar 7 20:53:05 2006 From: hughett at bbl.med.upenn.edu (Paul Hughett) Date: Tue, 7 Mar 2006 14:53:05 -0500 Subject: [Image-SIG] Pyvox release 0.72 now available Message-ID: <200603071953.k27Jr5NN012029@mercur.uphs.upenn.edu> The source distribution kit for Pyvox version 0.72 is now available from http://www.med.upenn.edu/bbl/downloads/pyvox/ Pyvox is a Python extension module for processing volume images, particularly medical images; it also includes some examples and simple applications. Features added in release 0.72 include: The interface for constructing convolution kernels has been completely redesigned and now supports the dynamic modification of kernels. Internal types now have min and max attributes which contain the minimum and maximum possible finite positive values representable in that type. Pyvox is currently available as an alpha release under an open-source license and is written in ANSI C and designed to be easily portable to any Unix or Posix-compatible platform. Some programs also require the X Window System. Paul Hughett ================================================================ Paul Hughett, Ph.D. Research Associate Brain Behavior Laboratory 10th floor Gates Building Hospital of the University (215) 662-6095 (voice) of Pennsylvania (215) 662-7903 (fax) 3400 Spruce Street Philadelphia PA 19104 hughett at bbl.med.upenn.edu A rose by any other name confuses the issue. -Patrick E. Raume ================================================================ -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. From tal at typesupply.com Thu Mar 9 01:57:11 2006 From: tal at typesupply.com (Tal Leming) Date: Wed, 8 Mar 2006 19:57:11 -0500 Subject: [Image-SIG] aggdraw Path.curveto Message-ID: Hi, I'm attempting to use the aggdraw Path object and I'm running into a problem. All of my curveto calls aren't giving me the expected results. For example, with the code below I expect to get a curved line, but instead I get a series of flat lines. Am I doing something wrong? I would appreciate any information... Thanks, Tal ### import os import Image import aggdraw draw = aggdraw.Draw('RGB', (100, 100), 'white') path = aggdraw.Path() path.moveto(0, 0) path.curveto(0, 30, 20, 50, 50, 50) pen = aggdraw.Pen("black", 1) draw.path((25, 25), path, pen, None) img = Image.fromstring('RGB', (100, 100), draw.tostring()) p = os.path.join(os.path.dirname(__file__), 'curvetoTest.tif') img.save(p) From DieterKrachtus at web.de Thu Mar 9 12:31:55 2006 From: DieterKrachtus at web.de (Dieter Krachtus) Date: Thu, 09 Mar 2006 12:31:55 +0100 Subject: [Image-SIG] Question about Thumbnail-Mode. Message-ID: <4410122B.8070007@web.de> Hi, I am in science and want to understand certain things PIL does better... One can get jpg-thumbnails of images with PIL. This happens pretty fast - so PIL cannot read the complete file, but use some trick. I guess it just reads in a 2^x (i.e. 1/2, 1/4, 1/8, 1/16, ...) of the actual image-data. Just to understand how this is done, is my qustion: 1. Does PIL look into the "header" of the jpg file and finds out from where to where the actual image data goes and how the dimension (width/height in pixel) of the image is ? 2. Then whats next? Does PIL read only e.g. every 16th byte, or how is this done - if you do this - is the resulting stream of bytes still interpretable as a jpg ? 3. Is there some limit to how many pixel one can leave out ? 4. Just fill in a question you would ask and might be interesting to me ;), and answer it yourself... Cheers, jago From DieterKrachtus at web.de Thu Mar 9 14:12:36 2006 From: DieterKrachtus at web.de (Dieter Krachtus) Date: Thu, 09 Mar 2006 14:12:36 +0100 Subject: [Image-SIG] Question about Thumbnail-Mode. Message-ID: <441029C4.7090408@web.de> Hi, I am in science and want to understand certain things PIL does better... One can get jpg-thumbnails of images with PIL. This happens pretty fast - so PIL cannot read the complete file, but use some trick. I guess it just reads in a 2^x (i.e. 1/2, 1/4, 1/8, 1/16, ...) of the actual image-data. Just to understand how this is done, is my qustion: 1. Does PIL look into the "header" of the jpg file and finds out from where to where the actual image data goes and how the dimension (width/height in pixel) of the image is ? 2. Then whats next? Does PIL read only e.g. every 16th byte, or how is this done - if you do this - is the resulting stream of bytes still interpretable as a jpg ? 3. Is there some limit to how many pixel one can leave out ? 4. Just fill in a question you would ask and might be interesting to me ;), and answer it yourself... Cheers, jago From fredrik at pythonware.com Thu Mar 9 14:48:22 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 9 Mar 2006 14:48:22 +0100 Subject: [Image-SIG] Question about Thumbnail-Mode. References: <441029C4.7090408@web.de> Message-ID: Dieter Krachtus wrote: > I am in science and want to understand certain things PIL does better... > > One can get jpg-thumbnails of images with PIL. This happens pretty fast > - so PIL cannot read the complete file, but use some trick. I guess it > just reads in a 2^x (i.e. 1/2, 1/4, 1/8, 1/16, ...) of the actual > image-data. Just to understand how this is done, is my qustion: > > 1. Does PIL look into the "header" of the jpg file and finds out from > where to where the actual image data goes and how the dimension > (width/height in pixel) of the image is ? yes. > 2. Then whats next? Does PIL read only e.g. every 16th byte, or how is > this done - if you do this - is the resulting stream of bytes still > interpretable as a jpg ? it's a lot tricker than that: the JPEG data stream represents image data not as a bunch of separate pixels, but as a set of frequency coefficients, which, when combined, can be used to reconstruct the original image (in pretty much the same way as you can generate a square wave by summing enough sine waves; see http://en.wikipedia.org/wiki/Square_wave). the frequency transform is made on 8x8 tiles, so you get a distinct set of coefficients for each 8x8 box in the source image. (to get lossy compression, JPEG simply uses fewer bits to store the coefficients than they really need; e.g. instead of storing a full range of, say, 0-1000 for a high-frequency coefficient, the file may only use 0, 300, 600, and 900. this lets you store the coefficient in 2 bits instead of 10.) to quickly generate thumbnails from JPEG images from the coefficients, PIL simply ignores some of the coefficients. to generate an 1/8 image, PIL uses the "DC component" from the frequency transform directly (which corre- sponds to the average value for the entire 8x8 box). for 1/2 and 1/4 images, PIL only enough frequency components to generate a 4x4 or 2x2 tile. there's a lot more to JPEG than I've described here; if you want to learn more about JPEG, the wikipedia entry is quite good: http://en.wikipedia.org/wiki/JPEG hope this helps! From DieterKrachtus at web.de Thu Mar 9 13:29:24 2006 From: DieterKrachtus at web.de (Dieter Krachtus) Date: Thu, 09 Mar 2006 13:29:24 +0100 Subject: [Image-SIG] Question about Thumbnail-Mode. Message-ID: <44101FA4.4090808@web.de> Hi, I am in science and want to understand certain things PIL does better... One can get jpg-thumbnails of images with PIL. This happens pretty fast - so PIL cannot read the complete file, but use some trick. I guess it just reads in a 2^x (i.e. 1/2, 1/4, 1/8, 1/16, ...) of the actual image-data. Just to understand how this is done, is my qustion: 1. Does PIL look into the "header" of the jpg file and finds out from where to where the actual image data goes and how the dimension (width/height in pixel) of the image is ? 2. Then whats next? Does PIL read only e.g. every 16th byte, or how is this done - if you do this - is the resulting stream of bytes still interpretable as a jpg ? 3. Is there some limit to how many pixel one can leave out ? 4. Just fill in a question you would ask and might be interesting to me ;), and answer it yourself... Cheers, jago From fredrik at pythonware.com Thu Mar 9 14:55:56 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 9 Mar 2006 14:55:56 +0100 Subject: [Image-SIG] aggdraw Path.curveto References: Message-ID: Tal Leming wrote: > I'm attempting to use the aggdraw Path object and I'm running into a > problem. All of my curveto calls aren't giving me the expected > results. For example, with the code below I expect to get a curved > line, but instead I get a series of flat lines. Am I doing something > wrong? probably not. it's most likely a bug; the path stuff is a relatively recent addition, and pro- bably not fully tested. I'll take a look. From dieter.vanderelst at gmail.com Fri Mar 10 10:15:45 2006 From: dieter.vanderelst at gmail.com (Dieter Vanderelst) Date: Fri, 10 Mar 2006 10:15:45 +0100 Subject: [Image-SIG] Vigra image processing library Message-ID: <441143C1.6080808@gmail.com> Hi, I would like to know whether there are people that have been using the Vigra image processing library with python (http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/) ? If you have would it be possible to tell me how you did this? Did you use Swig? Or are there other (easier) options available? Regards, Dieter From codebase at web.de Fri Mar 10 12:53:10 2006 From: codebase at web.de (CodeBase) Date: Fri, 10 Mar 2006 12:53:10 +0100 Subject: [Image-SIG] _imaging extension was built for another version of Python Message-ID: <441168A6.8050101@web.de> Hi all, I would like to use PIL in a Python script that does some document automation work in Open Office under Windows XP. When I try to run some of the PIL utilities, I get an error "Image.py:64: RuntimeWarning: The _imaging extension was built for another version of Python; most PIL functions will be disabled" The Python version that comes bundled with Open Office 2.0.1 is 2.3.4, so I downloaded PIL 1.1.5 for Python 2.3 from http://effbot.org/downloads/PIL-1.1.5.win32-py2.3.exe and installed it. As it didn't find the Python installation by itself, I had to register it myself with the register script from http://effbot.org/zone/python-register.htm What am I doing wrong ?? TIA, CU S> From ovlach at nanobyte.cz Sat Mar 11 00:43:08 2006 From: ovlach at nanobyte.cz (Ondrej Vlach) Date: Sat, 11 Mar 2006 00:43:08 +0100 Subject: [Image-SIG] Problem with JPEG output Message-ID: <200603110043.11154.ovlach@nanobyte.cz> Hello, I have a little problem if I use optimize or progession with JPEG. I have a simple source: import Image im = Image.open("/tmp/thumbnail.jpg") im.save('/tmp/thumbnail2.jpg', "JPEG", optimize = 1) which output this: Suspension not allowed here Traceback (most recent call last): File "test.py", line 5, in ? im.save('/tmp/thumbnail2.jpg', "JPEG", optimize = 1) File "/usr/lib/python2.4/site-packages/PIL/Image.py", line 1331, in save save_handler(self, fp, filename) File "/usr/lib/python2.4/site-packages/PIL/JpegImagePlugin.py", line 409, in _save ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)]) File "/usr/lib/python2.4/site-packages/PIL/ImageFile.py", line 493, in _save raise IOError("encoder error %d when writing image file" % s) IOError: encoder error -2 when writing image file version: Imaging-1.1.6a1-20051211 Anyone knowns why this source output this exception and how fix-it? Btw: Sorry for my english -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 191 bytes Desc: not available Url : http://mail.python.org/pipermail/image-sig/attachments/20060311/0849ce64/attachment.pgp From fredrik at pythonware.com Sat Mar 11 11:03:45 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 11 Mar 2006 11:03:45 +0100 Subject: [Image-SIG] Problem with JPEG output References: <200603110043.11154.ovlach@nanobyte.cz> Message-ID: Ondrej Vlach wrote: > IOError: encoder error -2 when writing image file > > version: Imaging-1.1.6a1-20051211 > > Anyone knowns why this source output this exception and how fix-it? here's an explanation and a workaround: http://mail.python.org/pipermail/image-sig/1999-August/000816.html From ronald at sipkema-digital.com Sat Mar 11 15:54:38 2006 From: ronald at sipkema-digital.com (Ronald Sipkema) Date: Sat, 11 Mar 2006 15:54:38 +0100 Subject: [Image-SIG] Vigra image processing library In-Reply-To: <441143C1.6080808@gmail.com> References: <441143C1.6080808@gmail.com> Message-ID: Dieter Vanderelst wrote: > I would like to know whether there are people that have been using the > Vigra image processing library with python > (http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/) ? > > If you have would it be possible to tell me how you did this? Did you > use Swig? Or are there other (easier) options available? I used Boost.Python in combination with the numarray c-API to export some algorithms I wrote in Vigra to be exported to python on the image level; I don't think exporting Vigra on a lower level than that is either feasible nor preferable: numarray support in python is quite good and Vigra's templated C++ design is going to be hard to pythonize anyway. OF course you could use Numeric or PIL or any other library that supports images to represent your images in python and then have bindings to run Vigra algorithms on those. --Ronald From fredrik at pythonware.com Sun Mar 12 16:11:25 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 12 Mar 2006 16:11:25 +0100 Subject: [Image-SIG] _imaging extension was built for another version ofPython References: <441168A6.8050101@web.de> Message-ID: "CodeBase" wrote: > When I try to run some of the PIL utilities, I get an error > "Image.py:64: RuntimeWarning: The _imaging extension was built for > another version of Python; most PIL functions will be disabled" > > The Python version that comes bundled with Open Office 2.0.1 is 2.3.4, > so I downloaded PIL 1.1.5 for Python 2.3 from > http://effbot.org/downloads/PIL-1.1.5.win32-py2.3.exe > and installed it. As it didn't find the Python installation by itself, I > had to register it myself with the register script from > http://effbot.org/zone/python-register.htm > > What am I doing wrong ?? the error message means exactly what it says, so it sure looks as if Python's picking up some _imaging.pyd file that doesn't match the Python interpreter you're using. have you verified that you don't have some old _imaging file lying around somewhere ? another possibility is that the bundled version is built in some non- standard way, so that external extensions won't work. it might be a good idea to search the OO forums for clues... From cardona at ucla.edu Tue Mar 14 20:52:13 2006 From: cardona at ucla.edu (Albert Cardona) Date: Tue, 14 Mar 2006 11:52:13 -0800 Subject: [Image-SIG] trouble with -O3 flag Message-ID: <200603141152.13753.cardona@ucla.edu> Dear listers, I am having trouble with a custom C python module. The module works just fine when compiling it locally and running it directly in a sort of debugging mode, but it doesn't when running compiled as the python module that it is, with "python setup.py build_ext". I see that the -O3 flag is on (along with the -g flag, doesn't make much sense) and I wonder how can one disactivate the -O3 flag, so that I can see whether there's any trouble from this direction. My platform: kubuntu GNU/Linux-ppc Breezy, GCC 4.0.2, python 2.3.5 Further, I have trouble finding the documentation for the Python C API in regard to compiling modules. What I've found about python 2.3.5 is very incomplete. I would appreciate some links to proper documentation websites, if it exists. Albert -- Albert Cardona Molecular Cell Developmental Biology University of California Los Angeles Tel +1 310 2067376 Programming: http://www.pensament.net/java/ Research: http://www.mcdb.ucla.edu/Research/Hartenstein/ Web design: http://www.pixelets.com From fredrik at pythonware.com Wed Mar 15 08:18:50 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 15 Mar 2006 08:18:50 +0100 Subject: [Image-SIG] trouble with -O3 flag References: <200603141152.13753.cardona@ucla.edu> Message-ID: Albert Cardona wrote: > I am having trouble with a custom C python module. The module works just fine > when compiling it locally and running it directly in a sort of debugging > mode, but it doesn't when running compiled as the python module that it is, > with "python setup.py build_ext". I see that the -O3 flag is on (along with > the -g flag, doesn't make much sense) and I wonder how can one disactivate > the -O3 flag, so that I can see whether there's any trouble from this > direction. you might have more success if you post to a more general python forum; I'd recommend comp.lang.python: http://www.python.org/community/lists/ > Further, I have trouble finding the documentation for the Python C API in > regard to compiling modules. What I've found about python 2.3.5 is very > incomplete. I would appreciate some links to proper documentation websites, > if it exists. most people use distutils, which is described in the "distributing python modules" and "installing python modules" handbooks: http://docs.python.org/dist/dist.html http://docs.python.org/inst/inst.html and has its own mailing list: http://www.python.org/community/sigs/current/distutils-sig/ hope this helps! From oliphant.travis at ieee.org Fri Mar 17 09:14:44 2006 From: oliphant.travis at ieee.org (Travis E. Oliphant) Date: Fri, 17 Mar 2006 01:14:44 -0700 Subject: [Image-SIG] Pyvox release 0.72 now available In-Reply-To: <200603071953.k27Jr5NN012029@mercur.uphs.upenn.edu> References: <200603071953.k27Jr5NN012029@mercur.uphs.upenn.edu> Message-ID: Paul Hughett wrote: > > The source distribution kit for Pyvox version 0.72 is now available > from > > http://www.med.upenn.edu/bbl/downloads/pyvox/ > > Thanks for releasing all of your work and for the generous license. Do you know if and/or when your library will be interoperable with NumPy? The new array interface http://numeric.scipy.org/#array_interface makes this quite easy. Perhaps the PIL could also learn to export and import the array interface to finally get copy-less data-transfer with NumPy arrays. On a related note. It would be nice if we could figure out better ways to work together on the basic object layers for image and volume processing (in my mind that's what NumPy array's are most useful for). But, I'm thrilled with all the algorithm activity and appreciate all the work that is done. Best regards, -Travis Oliphant From hughett at bbl.med.upenn.edu Fri Mar 17 18:05:00 2006 From: hughett at bbl.med.upenn.edu (Paul Hughett) Date: Fri, 17 Mar 2006 12:05:00 -0500 Subject: [Image-SIG] Pyvox release 0.72 now available In-Reply-To: (oliphant.travis@ieee.org) References: <200603071953.k27Jr5NN012029@mercur.uphs.upenn.edu> Message-ID: <200603171705.k2HH50Tv005065@mercur.uphs.upenn.edu> Travis, > Thanks for releasing all of your work and for the generous license. My pleasure. > Do you know if and/or when your library will be interoperable with > NumPy? It's on my list of good things to do, along with 500 other items. It's been moving towards the top, since I'd like to be able to use Matplotlib with Pyvox. > The new array interface makes this quite easy. I really like the idea of having a common underlying protocol for all multi-dimensional arrays; I'm still looking at the details of this particular proposal. > Perhaps the PIL could also learn to export and import the array > interface to finally get copy-less data-transfer with NumPy arrays. Also a good idea. PIL supports many more image file formats that Pyvox ever will, so interoperability would be nice. > On a related note. It would be nice if we could figure out better > ways to work together on the basic object layers for image and > volume processing (in my mind that's what NumPy array's are most > useful for). Sounds good in theory, but I'm a bit unsure on the practical details. A good starting place would seem to be a common N-D array protocol. Do you have any other specific suggestions? Paul Hughett -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. From oliphant at ee.byu.edu Fri Mar 17 19:45:37 2006 From: oliphant at ee.byu.edu (Travis Oliphant) Date: Fri, 17 Mar 2006 11:45:37 -0700 Subject: [Image-SIG] Pyvox release 0.72 now available In-Reply-To: <200603171705.k2HH50Tv005065@mercur.uphs.upenn.edu> References: <200603071953.k27Jr5NN012029@mercur.uphs.upenn.edu> <200603171705.k2HH50Tv005065@mercur.uphs.upenn.edu> Message-ID: <441B03D1.20609@ee.byu.edu> Paul Hughett wrote: >I really like the idea of having a common underlying protocol for all >multi-dimensional arrays; I'm still looking at the details of this >particular proposal. > > I'm glad. NumPy and SciPy developers really think that this common interface is what should go into Python, rather than any one specific array implementation. The existence of PyVox, actually makes this case stronger for us, I think. Perhaps you could contribute to the discussion I started on the python-dev list. We need to make more noise to the python-dev people so they will start to put "creating a good array interface" on the top of their lists. I think we have a good start already, but more input is welcomed. >Also a good idea. PIL supports many more image file formats that Pyvox >ever will, so interoperability would be nice. > > > > > >>On a related note. It would be nice if we could figure out better >>ways to work together on the basic object layers for image and >>volume processing (in my mind that's what NumPy array's are most >>useful for). >> >> > >Sounds good in theory, but I'm a bit unsure on the practical details. >A good starting place would seem to be a common N-D array protocol. Do >you have any other specific suggestions? > > I think we agree on a good starting place. I think the specific suggestion is to get PyVox talking through the array interface (at least the simple one) and to have you make suggestions as to how the array interface might need to change. There is code in NumPy and in Numeric (24.2) that shows how to consume and export the array interface. You might also help with the PEP that's been started to get a basic N-dimensional array into Python. If this were done, then PyVox could inherit from it (in C) as could NumPy and then interoperability is a cinch since the first-part of both structures would be identical. We would welcome any of your comments on numpy-discussion at lists.sourceforge.net Thanks again for your work, -Travis From medhat_assaad at yahoo.com Tue Mar 21 19:11:38 2006 From: medhat_assaad at yahoo.com (Medhat Assaad) Date: Tue, 21 Mar 2006 10:11:38 -0800 (PST) Subject: [Image-SIG] Freetype with advanced typographic options Message-ID: <20060321181138.73002.qmail@web35602.mail.mud.yahoo.com> Hi, I am trying to use PIL to find the length of some Arabic text. These fonts usually use the open type tables, and freetype supports that as per http://www.freetype.org/opentype/index.html This is not working for me using PIL 1.1.5 on windows. I tried to create an image with the text I was trying to measure its length, and it used the correct font but it did not use the open type tables and it did not do the shaping of the arabic font (ligature substitution). Is there any way to get this working on windows? Without having to recompile stuff... I am hoping to find a precompiled package of PIL that will support that since I will not be able to compile it on my machine. Here is my small test program (probably you will need to change the font if you want to test it) ---%------------ import Image,ImageFont,ImageDraw,ImageColor im = Image.new("RGB",(500,500),"white") draw = ImageDraw.Draw(im) f = ImageFont.truetype("arabtype.ttf",48) draw.text((10,10),u"\u0627\u0628\u0627",font=f,fill="black") im.save("im.png") ---%------------- -- Thanks! Medhat Assaad __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From Richard.Madden at USherbrooke.ca Tue Mar 21 21:41:27 2006 From: Richard.Madden at USherbrooke.ca (Richard Madden) Date: Tue, 21 Mar 2006 15:41:27 -0500 Subject: [Image-SIG] TIFF endian issue Message-ID: <1142973687.11884.62.camel@eurydice.med.usherbrooke.ca> Hi all, Is there any way to search past image-sig postings? Maybe this has already been answered. I've been sent a big endian 16-bit gray scale tiff image and PIL has no problem dealing with it except for the endianess. I won't go into details since this has been clearly posted before by Zachary Pincus in the Dec 2003 archives but I can't find any follow ups. He also describes a nice workaround of getting the image via a tostring, then rebuilding it with a fromstring and the correct mode. He also points out that the plugin does know that it is big endian from the prefix - but somehow it just fails to take the correct action. Someplace. I've been looking around but the plumbing is pretty confusing... Ciao, Dick -- Dick Madden Home: 1180 rue Walton #1 Bioinformatics Coordinator Sherbrooke, QC, Canada J1H 1L1 RNA Group Room 7410-5 Phone: (819) 562 1040 Departement de microbiologie Faculte de medecine Universite de Sherbrooke 3001, 12e Avenue Nord Sherbrooke, QC, Canada J1H 5N4 Phone: (819) 820-6868 poste 12324 From ned at nedbatchelder.com Tue Mar 21 22:42:07 2006 From: ned at nedbatchelder.com (Ned Batchelder) Date: Tue, 21 Mar 2006 16:42:07 -0500 Subject: [Image-SIG] I'm confused by alpha blending. Message-ID: <4420732F.4080507@nedbatchelder.com> I'm using PIL to composite a drop shadow onto an image. The blending isn't working the way I would expect. The drop shadow image itself has all black pixels, with all of the interesting stuff happening in the alpha channel. I'm using Image.paste to draw the drop shadow, by specifying the shadow png as both the image and the mask. When I do this on a pure black image, the shadow lightens the pixels! For example, a black existing pixel gets a shadow pixel that is black with alpha value of 152 decimal. The result should be black (since both the source and the destination are black, how can the alpha channel lighten the pixel?), but it comes out with a value of 100 decimal. When I graph the background color against the resulting color (using a fixed black shadow pixel with 152 alpha), the result is linear, but as I say, it lightens black pixels inexplicably. Is there something I am doing wrong? -- Ned Batchelder, http://nedbatchelder.com From fredrik at pythonware.com Tue Mar 21 23:12:54 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 21 Mar 2006 23:12:54 +0100 Subject: [Image-SIG] I'm confused by alpha blending. References: <4420732F.4080507@nedbatchelder.com> Message-ID: Ned Batchelder wrote: > I'm using PIL to composite a drop shadow onto an image. The blending > isn't working the way I would expect. The drop shadow image itself has > all black pixels, with all of the interesting stuff happening in the > alpha channel. I'm using Image.paste to draw the drop shadow, by > specifying the shadow png as both the image and the mask. > > When I do this on a pure black image, the shadow lightens the pixels! > For example, a black existing pixel gets a shadow pixel that is black > with alpha value of 152 decimal. The result should be black (since both > the source and the destination are black, how can the alpha channel > lighten the pixel?), but it comes out with a value of 100 decimal. > > When I graph the background color against the resulting color (using a > fixed black shadow pixel with 152 alpha), the result is linear, but as I > say, it lightens black pixels inexplicably. > > Is there something I am doing wrong? sounds confusing, indeed. are you 100% sure that the source pixels are black ? what happens if you do paste("black", shadow) on a black image ? what happens on your machine if you do: >>> from PIL import Image >>> Image.VERSION '1.1.5' >>> bg = Image.new("RGB", (100, 100), "black") >>> bg.getcolors() [(10000, (0, 0, 0))] >>> shadow = Image.new("RGB", (100, 100), 0) >>> alpha = Image.new("L", (100, 100), None) >>> alpha.putdata(range(0,200,2)*100) >>> shadow.putalpha(alpha) >>> shadow.mode 'RGBA' >>> len(shadow.getcolors()) 100 >>> bg.paste(shadow, shadow) >>> bg.getcolors() [(10000, (0, 0, 0))] From fredrik at pythonware.com Tue Mar 21 23:34:35 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 21 Mar 2006 23:34:35 +0100 Subject: [Image-SIG] I'm confused by alpha blending. References: <4420732F.4080507@nedbatchelder.com> Message-ID: > are you 100% sure that the source pixels are black ? a quick way to find out is to do print shadow.convert("RGB").getcolors() From jwt at onjapan.net Wed Mar 22 01:17:02 2006 From: jwt at onjapan.net (Jim Tittsler) Date: Wed, 22 Mar 2006 09:17:02 +0900 Subject: [Image-SIG] TIFF endian issue In-Reply-To: <1142973687.11884.62.camel@eurydice.med.usherbrooke.ca> References: <1142973687.11884.62.camel@eurydice.med.usherbrooke.ca> Message-ID: <3D12700E-AC88-489E-B0C7-762F9E2AB35F@onjapan.net> On Mar 22, 2006, at 05:41, Richard Madden wrote: > Is there any way to search past image-sig postings? They are indexed by Google. From fredrik at pythonware.com Fri Mar 24 18:12:30 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 24 Mar 2006 18:12:30 +0100 Subject: [Image-SIG] I'm confused by alpha blending. References: <4420732F.4080507@nedbatchelder.com> Message-ID: >> Is there something I am doing wrong? > > sounds confusing, indeed. > > are you 100% sure > > what happens > > what happens did you get anywhere with this ? From lanasa at universalwebservices.net Sun Mar 26 19:34:23 2006 From: lanasa at universalwebservices.net (lanasa at universalwebservices.net) Date: Sun, 26 Mar 2006 11:34:23 -0600 (CST) Subject: [Image-SIG] JPEG decoder not availabel Message-ID: <1861.68.233.38.152.1143394463.squirrel@mail.zettai.net> Hi, thanks for making this support system available. I have a install libjpeg 6b, then PIL 1.1.5. When running the selftest, I get the following output: Failure in example: _info(Image.open("Images/lena.jpg")) from line #24 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 "./selftest.py", line 21, in _info im.load() File "PIL/ImageFile.py", line 180, in load d = Image._getdecoder(self.mode, d, a, self.decoderconfig) File "PIL/Image.py", line 328, in _getdecoder raise IOError("decoder %s not available" % decoder_name) IOError: decoder jpeg not available 1 items had failures: 1 of 55 in selftest.testimage ***Test Failed*** 1 failures. *** 1 tests of 55 failed. >From reading multiple posts, I see that many users have the same problem, but noone has responded with a usable solution. Any thoughts? Thanks Phil LaNasa From hsubryan at buffalo.edu Mon Mar 27 07:22:01 2006 From: hsubryan at buffalo.edu (hsubryan at buffalo.edu) Date: Mon, 27 Mar 2006 00:22:01 -0500 Subject: [Image-SIG] deleting Message-ID: <1143436921.44277679209ce@mail3.buffalo.edu> Hi, I need to save the compose image into another folder besides the one that the program is running in. Also, how can delete the prececeding images that are being saved in the current folder and only keep the new one. So for instance, the only image that would exist in the folder that the program is running is the image compose from the most update image taken. i.e compose_1 compose_2 compose_3 etc. etc. these images are being saved at a specified interval. so if compose_3 was the last image save, I would like for compose_1 and compose_2 to be deleted. This code works and allows me to save the images in one folder, but I would like to save each batch in their separate folder. any help would be greatly appreciated. thanks ..subryan from VideoCapture import Device import time, string import Image import os, sys import Image import ImageFilter import ImageChops ## Specify the amount of seconds to wait between individual captures. ## interval = raw_input('Enter the amount time between each image capture: ') ## If you get horizontal stripes or other errors in the captured picture ## (especially at high resolutions), try setting showVideoWindow=0. cam = Device(devnum=0, showVideoWindow=0) cam.setResolution(640,480) cam2 = Device(devnum=1, showVideoWindow=0) cam2.setResolution(640,480) ## cam = Device(devnum=1, showVideoWindow=1) ## cam.displayCapturePinProperties() #cam.displayCaptureFilterProperties() #cam2.displayCaptureFilterProperties() print "press 'ctrl + c' to terminate" print 'Duration is measured per seconds' interval = input('Enter the amount time between each image capture: ') i = 0 j=0 im1 = 0 im2 = 0 imsave = 0 quant = interval * .1 starttime = time.time() compose = os.path.join("compose") upstairs = os.path.join("upstairs") downstairs = os.path.join("downstairs") newfolder = os.path.save('c:robotics") newsave = 0 while 1: lasttime = now = int((time.time() - starttime) / interval) print i print j #cam.saveSnapshot(string.zfill(str(i), 2) + '.jpg') cam.saveSnapshot(upstairs + '_' + string.zfill(i, 1) + '.jpg') #cam2.saveSnapshot(string.zfill(str(j),3) + '.jpg') cam2.saveSnapshot(downstairs + '_' + string.zfill(j, 1) + '.jpg') i += 1 j += 1 #takes each image and opens them incrementally to begin filtering. #imcomp = Image.open(string.zfill(str(im1),1) + '.jpg') imcomp = Image.open(upstairs + '_' + string.zfill(im1, 1) + '.jpg') #imcomp2 = Image.open(string.zfill(str(im2),1) + '.jpg') imcomp2 = Image.open(downstairs + '_' + string.zfill(im2, 1) + '.jpg') #compares the two images, pixel by pixel, and returns the new image containing the darker values. out = ImageChops.darker(imcomp, imcomp2) # output the images into current folder while deleting. out.save(compose + '_' + string.zfill(imsave, 1) + '.jpg') #out.save(string.zfill(str(imsave), 1) + '.jpg') #save images in a new location. #newout = out.save(string.zfill(str(newsave), 1) + '.jpg') #newout.save('robotics', 'JPEG') newsave += 1 im1 += 1 im2 += 1 imsave += 1 # continues an incremental overlay for each each that is taken. while now == lasttime: now = int((time.time() - starttime) / interval) time.sleep(quant) From fredrik at pythonware.com Mon Mar 27 07:46:41 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 27 Mar 2006 07:46:41 +0200 Subject: [Image-SIG] JPEG decoder not availabel References: <1861.68.233.38.152.1143394463.squirrel@mail.zettai.net> Message-ID: lanasa at universalwebservices.net wrote: > I have a install libjpeg 6b, then PIL 1.1.5. installed how? on what platform? what does the build script say? From mich at anorg.net Tue Mar 28 17:50:15 2006 From: mich at anorg.net (michael gross) Date: Tue, 28 Mar 2006 17:50:15 +0200 (CEST) Subject: [Image-SIG] multithreading problem Message-ID: <10863.85.2.53.160.1143561015.squirrel@mail.anorg.net> hallo I am working an a opengl application which uses pil to process images before loading them as textures. because the processing cannot be done in realtime I have tried to process the pictures in a background thread using pythons threading library. unfortunately it turned out that the c extentions of pil do not support multithreading. does anyone know a pil version which supports multithreading or any other library which could be used instead. i have tried to compile pil myself but did not succeed. as fare as it should be possible to add true multithreading support to pil but I am not exactly shure how to do that. does anyone have an idea how this problem could be solved? thanks a lot for any help michael From whenney at gmail.com Wed Mar 29 02:06:42 2006 From: whenney at gmail.com (William Henney) Date: Tue, 28 Mar 2006 18:06:42 -0600 Subject: [Image-SIG] PIL: how to subclass Image? Message-ID: Dear list, I was wondering how one should best go about subclassing PIL's image class. This does not seem as straightforward as I thought it was going to be. I have managed to get something to work as follows: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ import Image class MyImage(Image.Image): """ Helper class to create empty image of desired shape """ def __init__(self, mode='L', size=None): Image.Image.__init__(self) self.mode = mode self.size = size self.im = Image.core.new(self.mode, self.size) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ which I then can subclass something like this (the details aren't important): ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ class FitsImage(MyImage, FitsData): """ A fits file with associated grayscale image, with gamma-law scaling between fmin and fmax. """ def __init__(self, ): FitsData.__init__(self, ) MyImage.__init__(self, 'L', self.size) self.putdata(self.flatnormaldata, scale=255.0) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ and then it gets used something like this: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ im = FitsImage(fitsfilename, fmin, fmax) im.transpose(Image.FLIP_TOP_BOTTOM).save("whatever.png") ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ My main worry is how robust this is to future development of PIL. Is Image.core.new() supposed to be part of the API? Is there a better way of doing this? Are there any plans to give a fully OO interface to PIL in the future? Thanks in advance for any advice, Will -- Dr William Henney, Centro de Radioastronom?a y Astrof?sica, Universidad Nacional Aut?noma de M?xico, Campus Morelia From fredrik at pythonware.com Wed Mar 29 08:42:30 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 29 Mar 2006 08:42:30 +0200 Subject: [Image-SIG] how to subclass Image? References: Message-ID: William Henney wrote: > I was wondering how one should best go about subclassing PIL's image > class. This does not seem as straightforward as I thought it was going > to be. the Image class isn't designed to be subclassed by application code. if you want custom behaviour, use a delegating wrapper. > Are there any plans to give a fully OO interface to PIL in the future? fully OO ? spent too much in Java land lately ? From fredrik at pythonware.com Wed Mar 29 08:48:48 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 29 Mar 2006 08:48:48 +0200 Subject: [Image-SIG] multithreading problem References: <10863.85.2.53.160.1143561015.squirrel@mail.anorg.net> Message-ID: "michael gross" wrote: > unfortunately it turned out that the c extentions of pil do not support > multithreading. most heavy PIL operations release the global interpreter lock (GIL), if that's what you mean. that doesn't mean that Python code using PIL will be fully multithreaded, though - the interpreter still uses the interpreter lock to serialize access to the virtual machine. there's not much I can do about that in PIL. can you provide more details on what kind of operations you're using, and what makes you think that it's PIL itself that causes the problems. From mich at anorg.net Wed Mar 29 14:56:40 2006 From: mich at anorg.net (michael gross) Date: Wed, 29 Mar 2006 14:56:40 +0200 (CEST) Subject: [Image-SIG] multithreading problem Message-ID: <63684.62.167.232.223.1143637000.squirrel@mail.anorg.net> hallo ok I have put a little program together which uses pil and opengl. the main program is showing a texture which is moving across the screen. in a second thread it is calculating a blur filter on a random image. this calculation starts after 1500 pygame ticks. on my machine I can see clearly that during the calculation the moving texture stopps for a while. I am wondering if this is because the gil is not released when culculating such a blur effect. similar things seem to happen when I use split and merge or funcitons like s[0].paste(s[0].point(lambda i: i * self.r)) in the background thread. thanks a lot for any help best michael From whenney at gmail.com Wed Mar 29 17:20:01 2006 From: whenney at gmail.com (William Henney) Date: Wed, 29 Mar 2006 09:20:01 -0600 Subject: [Image-SIG] how to subclass Image? References: Message-ID: "Fredrik Lundh" writes: > William Henney wrote: > >> I was wondering how one should best go about subclassing PIL's image >> class. This does not seem as straightforward as I thought it was going >> to be. > > the Image class isn't designed to be subclassed by application code. if > you want custom behaviour, use a delegating wrapper. > Hmm, OK. Could you give some pointers as to what you mean? A brief google indicates the term "delegating wrapper" is most common in a C# context. I didn't find much useful related to Python. Despite having read "How to Think Like a Computer Scientist", I'm afraid I still think mostly like a plain old scientist. >> Are there any plans to give a fully OO interface to PIL in the future? > > fully OO ? spent too much in Java land lately ? > LOL. Not exactly - virtually all of what little I know about OO comes from reading python documentation and sources. I've mainly been using the PyX graphics package up to now, which is pretty straight-down-the-line OO. I initially found PIL a bit confusing since sometimes you have to use a function and sometimes a method, and it was never too obvious which (at least to me). Maybe this is a cunning plan to force us to actually read the documentation :) Please don't take any of this as a criticism of PIL. I am sure you have good reasons for the design you have chosen and I greatly appreciate all the work you have put into this package, which has been very useful to me. Best Wishes Will -- Dr William Henney, Centro de Radioastronom?a y Astrof?sica, Universidad Nacional Aut?noma de M?xico, Campus Morelia From whenney at gmail.com Wed Mar 29 17:27:23 2006 From: whenney at gmail.com (William Henney) Date: Wed, 29 Mar 2006 09:27:23 -0600 Subject: [Image-SIG] how to subclass Image? References: Message-ID: William Henney writes: > "Fredrik Lundh" writes: > >> the Image class isn't designed to be subclassed by application code. if >> you want custom behaviour, use a delegating wrapper. >> > > Hmm, OK. Could you give some pointers as to what you mean? OK, no need to bother. I found the FAQ: http://www.python.org/doc/faq/programming.html#what-is-delegation That should be enough to get me going. Cheers Will -- Dr William Henney, Centro de Radioastronom?a y Astrof?sica, Universidad Nacional Aut?noma de M?xico, Campus Morelia From Michel-Olivier.Rousseau at gameloft.com Thu Mar 30 17:56:35 2006 From: Michel-Olivier.Rousseau at gameloft.com (Michel-Olivier Rousseau) Date: Thu, 30 Mar 2006 10:56:35 -0500 Subject: [Image-SIG] Converting BMP -> PNG + transparency Message-ID: <57FF253F6B05A94AAE0D87DD1E55E6B303552E1D@MAIL01.gameloft.org> Hello Image-siggers Here's my problem... I have the following code: srcImgFileName = ImageFileName + ".bmp" dstImgFileName = ImageFileName + ".png" im = Image.open(srcImgFileName) im.save(dstImgFileName) The thing is that the transparency in the .bmp file in set to 0xFF00FF... What I want to to is set the transparency index of the .png file to point the location of the color 0xFF00FF in the palette. Is there a way to do that? Thanks a lot -Oli From kappamonagare at yahoo.co.jp Sun Mar 12 16:20:37 2006 From: kappamonagare at yahoo.co.jp (Fabrice Capiez) Date: Sun, 12 Mar 2006 15:20:37 -0000 Subject: [Image-SIG] Image averaging In-Reply-To: References: Message-ID: <441435FC.90104@yahoo.co.jp> Hello List Just a call for advice. I am using the VideoCapture module to grab frames from a webcam and, to reduce the noise, I am averaging several frames instead of just taking one. (I take microscopic images so the subject does not move in between) My first attempt was to convert PIL images to Numeric arrays, average 3 or 4 of these arrays and convert back to a PIL image. This process takes quite some time so I cannot use it in practicefor my home-made capture program. The solution I have adopted right now is to take only 2 frames and use Image.blend(im1, im2, 0.5). This solution is quite fast but of course I am limited to 2 frames. Anyone has an advice on what would be a better (ie : faster) solution ? Looking forward to any advice on the subject (or any advice in genral regarding image calculations) Fabrice C. -------------------------------------- TSUKAME EIKOU! KAGAYAKE EGAO! Yahoo! JAPAN JPC OFFICIAL PARTNER INTERNET PORTAL SITE http://pr.mail.yahoo.co.jp/wintergames/ From ehagemann at comcast.net Wed Mar 29 02:18:18 2006 From: ehagemann at comcast.net (Eric Hagemann) Date: Tue, 28 Mar 2006 19:18:18 -0500 Subject: [Image-SIG] extended color space -- 16 bits per color per pixel Message-ID: <002c01c652c6$48d21e90$6401a8c0@matrix> Folks, List newbie here - looking for a way to search the archives (other than pullng them month - by - month) is there a searchable archive ? If not, I am interested in support in PIL for 48bit tiff -- files that are RGB but have 16 bits per color, not the usual 8 -- any help out there ? Any other libs that might help ? Cheers Eric -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20060328/99a1101f/attachment.htm From ned at nedbatchelder.com Wed Mar 22 00:31:36 2006 From: ned at nedbatchelder.com (Ned Batchelder) Date: Tue, 21 Mar 2006 18:31:36 -0500 Subject: [Image-SIG] I'm confused by alpha blending. In-Reply-To: References: <4420732F.4080507@nedbatchelder.com> Message-ID: <44208CD8.9020107@nedbatchelder.com> I found the problem, thanks to the code you posted. My destination image was "RGBA", and I was viewing it in a web browser. Most of the image had an opaque alpha channel, but where I had drawn the drop shadows, it had the shadow's alpha values, so the white of the browser was showing through. This isn't the most intuitive way for alpha drawing to work. I guess I could see it both ways: if the destination is opaque, it should stay opaque, or drawing pixels onto a destination takes all the values from the source. In any case, changing my destination image from RGBA to RGB solved the problem. Thanks. --Ned. Fredrik Lundh wrote: >> are you 100% sure that the source pixels are black ? >> > > a quick way to find out is to do > > print shadow.convert("RGB").getcolors() > > > > > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > > > -- Ned Batchelder, http://nedbatchelder.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20060321/ffe5ca73/attachment.htm From wrybread at gmail.com Thu Mar 23 11:41:39 2006 From: wrybread at gmail.com (Alec Bennett) Date: Thu, 23 Mar 2006 02:41:39 -0800 Subject: [Image-SIG] compile problem Message-ID: I'm trying to compile a module (VideoCapture.py) that uses a PIL font, and after compiling (both with PY2EXE and Pyinstaller) I get an error "cannot find font file". The offending line is: self.normalfont = ImageFont.load_path('helvetica-10.pil') self.boldfont = ImageFont.load_path('helvB08.pil') I've confirmed that both fonts exist, and the script works fine when uncompiled. I tried putting the font files in the same directory as the compiled EXE, but no improvement. Any help humungously appreciated. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20060323/288f4ca8/attachment.html From ned at nedbatchelder.com Fri Mar 24 20:12:42 2006 From: ned at nedbatchelder.com (Ned Batchelder) Date: Fri, 24 Mar 2006 14:12:42 -0500 Subject: [Image-SIG] I'm confused by alpha blending. In-Reply-To: References: <4420732F.4080507@nedbatchelder.com> Message-ID: <442444AA.40004@nedbatchelder.com> (I send this days ago, and was told it was subject to moderation because of a suspicious header). I found the problem, thanks to the code you posted. My destination image was "RGBA", and I was viewing it in a web browser. Most of the image had an opaque alpha channel, but where I had drawn the drop shadows, it had the shadow's alpha values, so the white of the browser was showing through. This isn't the most intuitive way for alpha drawing to work. I guess I could see it both ways: if the destination is opaque, it should stay opaque, or drawing pixels onto a destination takes all the values from the source. In any case, changing my destination image from RGBA to RGB solved the problem. Thanks. --Ned. Fredrik Lundh wrote: >>> Is there something I am doing wrong? >>> >> sounds confusing, indeed. >> >> are you 100% sure >> >> what happens >> >> what happens >> > > did you get anywhere with this ? > > > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > > > -- Ned Batchelder, http://nedbatchelder.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20060324/cb56a442/attachment.htm From fredrik at pythonware.com Thu Mar 30 23:32:26 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 30 Mar 2006 23:32:26 +0200 Subject: [Image-SIG] messages stuck in moderation queue Message-ID: I just discovered that gmail has misfiled the moderation reminders that I'm supposed to get from mailman. as usual, most of the stuff caught by mailman was spam, but there were also an unusual number of valid posts. we apologize for the inconvenience... From fredrik at pythonware.com Thu Mar 30 23:39:48 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 30 Mar 2006 23:39:48 +0200 Subject: [Image-SIG] read image into an array References: Message-ID: a long time ago, Marcin Szkudlarek wrote: > Is there a faster way to do it? For example using getdata() method of Image > class? And later how I can convert above array into Image without using slow > putpixel method? this article might help: http://effbot.org/zone/pil-numpy.htm