From fredrik at pythonware.com Sun Dec 2 14:30:11 2007 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 02 Dec 2007 14:30:11 +0100 Subject: [Image-SIG] Is getdata() or load() more efficient for accessing pixels? In-Reply-To: References: Message-ID: jorma kala wrote: > I read that the getpixel function of the PIL library is relatively slow. > Which alternative is therefore faster and more efficient, accesing the > result of getdata() as a flat list or > using the function load(), and accessing pixels through the resulting > 2-dimensional array? I suggest benchmarking this for your specific use case. From fredrik at pythonware.com Sun Dec 2 14:37:13 2007 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 02 Dec 2007 14:37:13 +0100 Subject: [Image-SIG] Find camera information from JPG image In-Reply-To: <5b6eb1490711300658w2b073a61r7639f830f54de4fa@mail.gmail.com> References: <5b6eb1490711300658w2b073a61r7639f830f54de4fa@mail.gmail.com> Message-ID: George LeCompte wrote: > How do I recover camera information such as shtter speed, focal length > from the header of a JPG image? Assuming a recent version of PIL, you can use the _getexif() method on JPEG images to get the raw EXIF information, and use the dictionaries in the ExifTags module to map from EXIT codes and back (alternatively, look up the keys in the EXIF specification). Example: >>> import Image, ExifTags >>> im = Image.open("im001.jpg") >>> im._getexif().keys() [36864, 37121, 37122, 36867, 36868, 37381, 37510, 37383, ... >>> for key, value in sorted(im._getexif().items()): ... print key, ExifTags.TAGS.get(key), value ... 271 Make Canon 272 Model Canon PowerShot A85 274 Orientation 1 282 XResolution (180, 1) 283 YResolution (180, 1) 296 ResolutionUnit 2 306 DateTime 2005:08:14 10:24:05 531 YCbCrPositioning 1 33434 ExposureTime (1, 160) 33437 FNumber (48, 10) 34665 ExifOffset 196 36864 ExifVersion 0220 36867 DateTimeOriginal 2005:08:14 10:24:05 36868 DateTimeDigitized 2005:08:14 10:24:05 ... From scarfboy at gmail.com Mon Dec 3 16:33:33 2007 From: scarfboy at gmail.com (Bart) Date: Mon, 3 Dec 2007 16:33:33 +0100 Subject: [Image-SIG] Image-SIG Digest, Vol 56, Issue 2 In-Reply-To: References: Message-ID: I've noticed that the lens type can be fetched too, but the method depends on the camera manufacturer (so basically on the make field). For example, for canon, the lenses are enumerated, see: http://www.gvsoft.homedns.org/exif/lens-type.html http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Canon.html#CameraInfo ...not that I've tried this (who knows, maybe such non-core tags are stripped by some software so are only guaranteed on camera raws), or know of camera/lense mappings that are authoritative, or include other companies. --Bart From Jim.Vickroy at noaa.gov Mon Dec 3 18:31:20 2007 From: Jim.Vickroy at noaa.gov (jv) Date: Mon, 03 Dec 2007 10:31:20 -0700 Subject: [Image-SIG] How do i import text file which has NaNs ? In-Reply-To: <2b125de60711212130s4c99ede9jcc3775cbb7f45bbf@mail.gmail.com> References: <2b125de60711212130s4c99ede9jcc3775cbb7f45bbf@mail.gmail.com> Message-ID: <004101c835d2$51ae4980$6500a8c0@questar> _____ From: image-sig-bounces at python.org [mailto:image-sig-bounces at python.org] On Behalf Of raghuram narasimhan Sent: Wednesday, November 21, 2007 10:31 PM To: image-sig at python.org Subject: [Image-SIG] How do i import text file which has NaNs ? Hi all, I have converted an ENVI image file into ASCII. The ASCII file has NaNs or NoData in them. I am not able to read the file into python since it is not able to recognize NaN. I'm not an experience python user, and hence i guess i'm not able to figure it out. Does anyone have any idea as to how i can import an ASCII file with NaNs in them ? [jv] I'm not sure this is applicable, but have you looked at the numpy extension package which has support for NaN? Hoping to hear from you, Raghu -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20071203/7cf4aebd/attachment.htm From bbaxter at wadsworth.org Mon Dec 3 16:28:13 2007 From: bbaxter at wadsworth.org (William Baxter) Date: Mon, 03 Dec 2007 10:28:13 -0500 Subject: [Image-SIG] GifImagePlugin Message-ID: <4754208D.3133523A@wadsworth.org> Does anyone have a copy of GifImagePlugin.py that can handle GIF89a? IMPORTANT NOTICE: This e-mail and any attachments may contain confidential or sensitive information which is, or may be, legally privileged or otherwise protected by law from further disclosure. It is intended only for the addressee. If you received this in error or from someone who was not authorized to send it to you, please do not distribute, copy or use it or any attachments. Please notify the sender immediately by reply e-mail and delete this from your system. Thank you for your cooperation. From Chris.Barker at noaa.gov Wed Dec 5 18:37:55 2007 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Wed, 05 Dec 2007 09:37:55 -0800 Subject: [Image-SIG] How do i import text file which has NaNs ? In-Reply-To: <004101c835d2$51ae4980$6500a8c0@questar> References: <2b125de60711212130s4c99ede9jcc3775cbb7f45bbf@mail.gmail.com> <004101c835d2$51ae4980$6500a8c0@questar> Message-ID: <4756E1F3.1040101@noaa.gov> > The ASCII file has NaNs or NoData in them. > I am not able to read the file into python since it is not able to > recognize NaN. > */[jv] I?m not sure this is applicable, but have you looked at the numpy > extension package which has support for NaN?/* numpy does support NaN, and it's an excellent choice for this kind of data anyway. It's also easy to turn a numpy array into a PIL image. However, I'm not sure it supports NaN text literals, and, if it does, it's probably not platform independent, as it uses the system library scanf(). I would check out numpy, but you may have to write the file scanning code yourself, and translate the NaN. An example might help us get other ideas. For instance, what is the ascii representation of NaN? "NaN", or something else? What system are you running on? For instance, on OS-X (Python 2.5, compiled with gcc4.0.1), this works: >>> float("NaN") nan But I don't think that works on the stock Windows Python. However, there may be another literal that does. Try: >>> import numpy as N >>> str(N.nan) 'nan' and it might tell you the literal on your system. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker at noaa.gov From Chris.Barker at noaa.gov Wed Dec 5 18:50:45 2007 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Wed, 05 Dec 2007 09:50:45 -0800 Subject: [Image-SIG] Is getdata() or load() more efficient for accessing pixels? In-Reply-To: References: Message-ID: <4756E4F5.3040607@noaa.gov> jorma kala wrote: > I read that the getpixel function of the PIL library is relatively slow. Depending on your needs, numpy may be a good bet: http://jehiah.cz/archive/creating-images-with-numpy Be sure to look at the comment below, demonstrating the new Image.fromarray() function. And you can convert a PIL image to a numpy array with no data copying: arr = numpy.asarray(PIL_image) -CHB -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker at noaa.gov From fredrik at pythonware.com Wed Dec 5 19:55:55 2007 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 05 Dec 2007 19:55:55 +0100 Subject: [Image-SIG] GifImagePlugin In-Reply-To: <4754208D.3133523A@wadsworth.org> References: <4754208D.3133523A@wadsworth.org> Message-ID: William Baxter wrote: > Does anyone have a copy of GifImagePlugin.py that can handle GIF89a? define "handle". the standard module always writes GIF87a files, but has no problems reading GIF89 files. From cfinley at u.washington.edu Wed Dec 5 22:38:38 2007 From: cfinley at u.washington.edu (Chris Finley) Date: Wed, 05 Dec 2007 13:38:38 -0800 Subject: [Image-SIG] GUI Toolkit recommendations Message-ID: <1196890718.5093.15.camel@sdf-workstation> Greetings, I'm new to Python and GUI programming (from the Perl/Web world) and would like some recommendations for GUI toolkits or reference to toolkit reviews. I'm presently looking at Glade, but that is more by happenstance than purpose. The application is a CAD program for testing and manipulating signed-distance field models. The SDF models will be created from functions or converted from polygon meshes. I'm programming more of a research tool than end-product, so the desired traits are: 1. cross-platform compatibility 2. easy to use and quick development 3. professional looking Your advise is greatly appreciated, Chris From steve at holdenweb.com Wed Dec 5 22:01:50 2007 From: steve at holdenweb.com (Steve Holden) Date: Wed, 05 Dec 2007 16:01:50 -0500 Subject: [Image-SIG] How do i import text file which has NaNs ? In-Reply-To: <4756E1F3.1040101@noaa.gov> References: <2b125de60711212130s4c99ede9jcc3775cbb7f45bbf@mail.gmail.com> <004101c835d2$51ae4980$6500a8c0@questar> <4756E1F3.1040101@noaa.gov> Message-ID: <475711BE.8090004@holdenweb.com> Christopher Barker wrote: >> The ASCII file has NaNs or NoData in them. > >> I am not able to read the file into python since it is not able to >> recognize NaN. > >> */[jv] I?m not sure this is applicable, but have you looked at the numpy >> extension package which has support for NaN?/* > > numpy does support NaN, and it's an excellent choice for this kind of > data anyway. It's also easy to turn a numpy array into a PIL image. > > However, I'm not sure it supports NaN text literals, and, if it does, > it's probably not platform independent, as it uses the system library > scanf(). > > I would check out numpy, but you may have to write the file scanning > code yourself, and translate the NaN. > > An example might help us get other ideas. For instance, what is the > ascii representation of NaN? "NaN", or something else? > > What system are you running on? For instance, on OS-X (Python 2.5, > compiled with gcc4.0.1), this works: > > >>> float("NaN") > nan > > But I don't think that works on the stock Windows Python. However, there > may be another literal that does. Try: > > >>> import numpy as N > >>> str(N.nan) > 'nan' > > and it might tell you the literal on your system. > > -Chris > Sadly not: >>> import numpy >>> str(numpy.nan) '-1.#IND' >>> float(str(numpy.nan)) Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for float(): -1.#IND >>> repr(numpy.nan) '-1.#IND' >>> regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ From leknarf at pacbell.net Thu Dec 6 00:21:21 2007 From: leknarf at pacbell.net (Scott Frankel) Date: Wed, 5 Dec 2007 15:21:21 -0800 Subject: [Image-SIG] GUI Toolkit recommendations In-Reply-To: <1196890718.5093.15.camel@sdf-workstation> References: <1196890718.5093.15.camel@sdf-workstation> Message-ID: I recently put out a not-too-dissimilar question. Responses were overwhelmingly in favor of WxPython. You could check the pythonmac- sig archives for the thread, "Eclipse + SWT + Python." Good luck! Scott On Dec 5, 2007, at 1:38 PM, Chris Finley wrote: > Greetings, > > I'm new to Python and GUI programming (from the Perl/Web world) and > would like some recommendations for GUI toolkits or reference to > toolkit > reviews. I'm presently looking at Glade, but that is more by > happenstance than purpose. > > The application is a CAD program for testing and manipulating > signed-distance field models. The SDF models will be created from > functions or converted from polygon meshes. > > I'm programming more of a research tool than end-product, so the > desired > traits are: > 1. cross-platform compatibility > 2. easy to use and quick development > 3. professional looking > > Your advise is greatly appreciated, > > Chris > > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20071205/56e57b90/attachment.htm From nadavh at visionsense.com Thu Dec 6 12:01:42 2007 From: nadavh at visionsense.com (Nadav Horesh) Date: Thu, 06 Dec 2007 13:01:42 +0200 Subject: [Image-SIG] GUI Toolkit recommendations In-Reply-To: <1196890718.5093.15.camel@sdf-workstation> References: <1196890718.5093.15.camel@sdf-workstation> Message-ID: <1196938902.27197.0.camel@nadav.envision.co.il> wxPython. Nadav. On Wed, 2007-12-05 at 13:38 -0800, Chris Finley wrote: > Greetings, > > I'm new to Python and GUI programming (from the Perl/Web world) and > would like some recommendations for GUI toolkits or reference to toolkit > reviews. I'm presently looking at Glade, but that is more by > happenstance than purpose. > > The application is a CAD program for testing and manipulating > signed-distance field models. The SDF models will be created from > functions or converted from polygon meshes. > > I'm programming more of a research tool than end-product, so the desired > traits are: > 1. cross-platform compatibility > 2. easy to use and quick development > 3. professional looking > > Your advise is greatly appreciated, > > Chris > > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20071206/789c16d7/attachment.htm From xiao at blueforge.net Fri Dec 14 02:47:38 2007 From: xiao at blueforge.net (Xiao) Date: Fri, 14 Dec 2007 09:47:38 +0800 Subject: [Image-SIG] reading part of an image Message-ID: Hi, is it possible to read only a part of an image (png or gif) by PIL? For example, an image is 20000x20000 in pixels. Is it possible for python to read only 100x100 of the picture (not loading the whole picture) and save the small part to a new png file? Any ideas would be appreciated. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20071214/c0c68b7b/attachment.htm From gwidion at mpc.com.br Sun Dec 16 12:51:21 2007 From: gwidion at mpc.com.br (Joao S. O. Bueno) Date: Sun, 16 Dec 2007 08:51:21 -0300 Subject: [Image-SIG] reading part of an image In-Reply-To: References: Message-ID: <200712160851.21279.gwidion@mpc.com.br> On Thursday 13 December 2007 22:47, Xiao wrote: > Hi, is it possible to read only a part of an image (png or gif) by > PIL? > > For example, an image is 20000x20000 in pixels. Is it possible for > python to read only 100x100 of the picture (not loading the whole > picture) and save the small part to a new png file? > > Any ideas would be appreciated. Thanks. Not with PIL straight. It could be done interfacing straight with libpng - you can check the PIL source code to check how PNG's are loaded and work your own implementation from there. Maybe it is evne possible to make "low level" calls to the classes and methods defined in PIL/PngImagePlugin.py (in the source tree) - if not, you certainly can just override some classes from that file and work your implementation. js -><_ From fredrik at pythonware.com Mon Dec 17 21:00:11 2007 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 17 Dec 2007 21:00:11 +0100 Subject: [Image-SIG] reading part of an image In-Reply-To: References: Message-ID: Xiao wrote: > Hi, is it possible to read only a part of an image (png or gif) by PIL? > > For example, an image is 20000x20000 in pixels. Is it possible for > python to read only 100x100 of the picture (not loading the whole > picture) and save the small part to a new png file? PNG and GIF files are encoded streams, so there's no way to "seek" in the actual image data. For other formats, you can check the "tile" attribute after you've opened the image, but before you've loaded it; if it contains a list of descriptors, or if the type for the descriptors is "raw", you can manipulate the "tile" list so it contains only the part you want to read, and manipulate the "size" accordingly. For an example, see: http://effbot.org/zone/pil-large-images.htm From epui at sjri.com Tue Dec 18 13:10:24 2007 From: epui at sjri.com (Gross) Date: Tue, 18 Dec 2007 12:10:24 +0000 Subject: [Image-SIG] I've had many people tell me they liked it more than JavaOne. Message-ID: <4767B8B0.6060507@carolinaturkeys.com> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20071218/a8eeb81f/attachment.htm -------------- next part -------------- A non-text attachment was scrubbed... Name: steering.gif Type: image/gif Size: 14657 bytes Desc: not available Url : http://mail.python.org/pipermail/image-sig/attachments/20071218/a8eeb81f/attachment.gif From rowen at cesmail.net Tue Dec 18 23:09:50 2007 From: rowen at cesmail.net (Russell E. Owen) Date: Tue, 18 Dec 2007 14:09:50 -0800 Subject: [Image-SIG] Get PIL version number? Message-ID: How can I query the version number of PIL from Python? Most packages have a __version__ attribute but neither the Image nor PIL package seem to have this. -- Russell From Chris.Barker at noaa.gov Wed Dec 19 00:10:49 2007 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Tue, 18 Dec 2007 15:10:49 -0800 Subject: [Image-SIG] Get PIL version number? In-Reply-To: References: Message-ID: <47685379.4050909@noaa.gov> Image.VERSION It's too bad it doesn't follow the now-common convention of __version__. This is how I found it: >>> for s in dir(Image): ... if "version" in s.lower(): print s ... VERSION >>> Image.VERSION '1.1.6' -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker at noaa.gov From danielsforummail at terra.com.br Wed Dec 19 05:05:52 2007 From: danielsforummail at terra.com.br (Daniel Felix Ferber) Date: Wed, 19 Dec 2007 02:05:52 -0200 Subject: [Image-SIG] Remove noise from high ISO photos Message-ID: <476898A0.5070708@terra.com.br> Hi! I was wondering if PIL has a filter or enhancement in order to remove noise from photos that were taked with high ISO. Gimp and ImageMagic both have such a feature and it work very good. I tried to use SMOOTH or SMOOTH_MORE filter. But there are better strategies to remove high ISO noise that try to preserve sharpness of the image. Currently I am calling ImageMagic from within my python script, but I would prefer if PIL would handle it. Is this possible in current version of PIL? Best regards, Daniel Ferber From carlos.s.santos at gmail.com Wed Dec 19 13:18:13 2007 From: carlos.s.santos at gmail.com (Carlos da Silva Santos) Date: Wed, 19 Dec 2007 10:18:13 -0200 Subject: [Image-SIG] Remove noise from high ISO photos In-Reply-To: <476898A0.5070708@terra.com.br> References: <476898A0.5070708@terra.com.br> Message-ID: <1dc6ddb60712190418r259e7477l5468008113097b53@mail.gmail.com> Daniel, I don't know much about high ISO noise, but a standard way of removing noise while preserving edges is using a median filter: http://www.pythonware.com/library/pil/handbook/imagefilter.htm If your goal is only running the whole pipeline from python, you might install the python bindings for Gimp and try to use the Gimp filter from python. I hope this helps. []s Carlos On Dec 19, 2007 2:05 AM, Daniel Felix Ferber wrote: > Hi! > > I was wondering if PIL has a filter or enhancement in order to remove > noise from photos that were taked with high ISO. Gimp and ImageMagic > both have such a feature and it work very good. > I tried to use SMOOTH or SMOOTH_MORE filter. But there are better > strategies to remove high ISO noise that try to preserve sharpness of > the image. > Currently I am calling ImageMagic from within my python script, but I > would prefer if PIL would handle it. Is this possible in current version > of PIL? > > Best regards, > Daniel Ferber > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From danielsforummail at terra.com.br Wed Dec 19 13:57:33 2007 From: danielsforummail at terra.com.br (Daniel Felix Ferber) Date: Wed, 19 Dec 2007 10:57:33 -0200 Subject: [Image-SIG] Remove noise from high ISO photos In-Reply-To: <1dc6ddb60712190418r259e7477l5468008113097b53@mail.gmail.com> References: <476898A0.5070708@terra.com.br> <1dc6ddb60712190418r259e7477l5468008113097b53@mail.gmail.com> Message-ID: <4769153D.903@terra.com.br> Hi Carlos, Thanks for the advice about median filter. I will do some experiments. When taking a photo with high ISO on a digital camera, there will be many pixels that have a random color that is completely different color from the expected one. But the photo still has a good sharpness ImageMagic uses a stategy that is similar to the median filter: it looks at the neighborhood o a pixel. If the color of the pixel is considerably different from the color of adjacent pixels, then the color of the pixel is changed to a color close to the neighborhood. If not, the pixel is preserved. It seems that the median filter always changes the color of the pixel, and I am afraid that the image might loose sharpness. I already considered using bindings for gimp, but only found information about writing gimp plugins in python. Does the binding allow me to control gimp from a python script that I run on a bash console? Best regards, Daniel Felix Ferber Carlos da Silva Santos escreveu: > Daniel, > > I don't know much about high ISO noise, but a standard way of removing > noise while preserving edges is using a median filter: > http://www.pythonware.com/library/pil/handbook/imagefilter.htm > > If your goal is only running the whole pipeline from python, you might > install the python bindings for Gimp and try to use the Gimp filter > from python. > > I hope this helps. > > []s > > Carlos > > > > On Dec 19, 2007 2:05 AM, Daniel Felix Ferber > wrote: > >> Hi! >> >> I was wondering if PIL has a filter or enhancement in order to remove >> noise from photos that were taked with high ISO. Gimp and ImageMagic >> both have such a feature and it work very good. >> I tried to use SMOOTH or SMOOTH_MORE filter. But there are better >> strategies to remove high ISO noise that try to preserve sharpness of >> the image. >> Currently I am calling ImageMagic from within my python script, but I >> would prefer if PIL would handle it. Is this possible in current version >> of PIL? >> >> Best regards, >> Daniel Ferber >> _______________________________________________ >> Image-SIG maillist - Image-SIG at python.org >> http://mail.python.org/mailman/listinfo/image-sig >> >> > > Esta mensagem foi verificada pelo E-mail Protegido Terra. > Scan engine: McAfee VirusScan / Atualizado em 18/12/2007 / Vers?o: 5.1.00/5188 > Proteja o seu e-mail Terra: http://mail.terra.com.br/ > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20071219/c8cd59af/attachment.htm From douglas at paradise.net.nz Wed Dec 19 23:38:03 2007 From: douglas at paradise.net.nz (Douglas Bagnall) Date: Thu, 20 Dec 2007 11:38:03 +1300 Subject: [Image-SIG] Remove noise from high ISO photos In-Reply-To: <4769153D.903@terra.com.br> References: <476898A0.5070708@terra.com.br> <1dc6ddb60712190418r259e7477l5468008113097b53@mail.gmail.com> <4769153D.903@terra.com.br> Message-ID: <47699D4B.9030902@paradise.net.nz> Daniel Felix Ferber wrote: > When taking a photo with high ISO on a digital camera, there will be > many pixels that have a random color that is completely different color > from the expected one. But the photo still has a good sharpness > ImageMagic uses a stategy that is similar to the median filter: it looks > at the neighborhood o a pixel. If the color of the pixel is considerably > different from the color of adjacent pixels, then the color of the pixel > is changed to a color close to the neighborhood. If not, the pixel is > preserved. > > It seems that the median filter always changes the color of the pixel, > and I am afraid that the image might loose sharpness. What you are describing could be achieved thus: 1. Take a 3x3 median image. Most pixels will hardly be changed, but the noisy ones will be. 2. find the difference between the original and the median (using ImageChops.difference). Good pixels will be black or nearly so, but the noisy ones won't be. 3. Use the difference image as a mask for pasting the median over the original. You will need to convert the difference image to grey-scale in some way, or split it into bands and do each band of the image separately. image.convert('L') is probably not the best way. You might want to make it into a threshold image (rather than have it blending proportionately to the difference). But I'm not sure how much better than a simple median it will be--after all, the pixels that this process doesn't change are exactly the pixels that the median hardly changes. In any case, the median will be much better than SMOOTH and SMOOTH_MORE. Douglas From fredrik at pythonware.com Wed Dec 19 23:56:23 2007 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 19 Dec 2007 23:56:23 +0100 Subject: [Image-SIG] Get PIL version number? In-Reply-To: <47685379.4050909@noaa.gov> References: <47685379.4050909@noaa.gov> Message-ID: Christopher Barker wrote: > Image.VERSION > > It's too bad it doesn't follow the now-common convention of __version__. PIL is older than most Python conventions, and PIL's programming API tends to be *extremely* stable (on purpose). (Note that the style guide says that "__version__" should contain the VCS revision number, which isn't that helpful. It also says that the __name__ form is for magic stuff. And for completeness, Python's own version number is of course found in "sys.version". Consistency...) From Chris.Barker at noaa.gov Thu Dec 20 01:24:22 2007 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Wed, 19 Dec 2007 16:24:22 -0800 Subject: [Image-SIG] Get PIL version number? In-Reply-To: References: <47685379.4050909@noaa.gov> Message-ID: <4769B636.4040204@noaa.gov> Fredrik Lundh wrote: > Christopher Barker wrote: >> It's too bad it doesn't follow the now-common convention of __version__. > > PIL is older than most Python conventions, yes, it sure is. > and PIL's programming API tends to be *extremely* stable (on purpose). Which is much appreciated. > (Note that the style guide says that "__version__" should contain the > VCS revision number, which isn't that helpful. It also says that the > __name__ form is for magic stuff. And for completeness, Python's own > version number is of course found in "sys.version". Consistency...) All quite true, but like it or not, __version__ has become pretty common. Would it be so bad to have: __version__ = VERSION in there somewhere? One less question to the mailing list is a good thing.... -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker at noaa.gov From danielsforummail at terra.com.br Thu Dec 20 13:34:40 2007 From: danielsforummail at terra.com.br (danielsforummail) Date: Thu, 20 Dec 2007 10:34:40 -0200 Subject: [Image-SIG] Remove noise from high ISO photos Message-ID: Hi Douglas, thanks for the advices. I will give them a try. Best regards, Daniel Ferber ---------- Cabe?alho original ----------- De: "Douglas Bagnall" douglas at paradise.net.nz Para: "Daniel Felix Ferber" danielsforummail at terra.com.br, image-sig at python.org C?pia: Data: Thu, 20 Dec 2007 11:38:03 +1300 Assunto: Re: [Image-SIG] Remove noise from high ISO photos > Daniel Felix Ferber wrote: > > > When taking a photo with high ISO on a digital camera, there will be > > many pixels that have a random color that is completely different color > > from the expected one. But the photo still has a good sharpness > > ImageMagic uses a stategy that is similar to the median filter: it looks > > at the neighborhood o a pixel. If the color of the pixel is considerably > > different from the color of adjacent pixels, then the color of the pixel > > is changed to a color close to the neighborhood. If not, the pixel is > > preserved. > > > > It seems that the median filter always changes the color of the pixel, > > and I am afraid that the image might loose sharpness. > > > What you are describing could be achieved thus: > > 1. Take a 3x3 median image. Most pixels will hardly be changed, but the > noisy ones will be. > > 2. find the difference between the original and the median (using > ImageChops.difference). Good pixels will be black or nearly so, but the > noisy ones won't be. > > 3. Use the difference image as a mask for pasting the median over the > original. You will need to convert the difference image to grey-scale > in some way, or split it into bands and do each band of the image > separately. image.convert('L') is probably not the best way. You might > want to make it into a threshold image (rather than have it blending > proportionately to the difference). > > But I'm not sure how much better than a simple median it will be--after > all, the pixels that this process doesn't change are exactly the pixels > that the median hardly changes. > > In any case, the median will be much better than SMOOTH and SMOOTH_MORE. > > > Douglas > > > Esta mensagem foi verificada pelo E-mail Protegido Terra. > Scan engine: McAfee VirusScan / Atualizado em 19/12/2007 / Vers?o: 5.1.00/5189 > Proteja o seu e-mail Terra: http://mail.terra.com.br/ > From donn.ingle at gmail.com Thu Dec 20 15:09:20 2007 From: donn.ingle at gmail.com (Donn) Date: Thu, 20 Dec 2007 16:09:20 +0200 Subject: [Image-SIG] PIL ImageFont segfault mystery Message-ID: <200712201609.20665.donn.ingle@gmail.com> Hello, Here's the story: * python-imaging Version: 1.1.6-1 * Python 2.4 and 2.5 * Kubuntu Gnu/Linux 7.10 This is the code snippet that causes a segfault: font = ImageFont.truetype("path/to/Anatevka Caps.ttf", points, index=0) print "getname:", font.getname() # <- App dies here. To reproduce: It does not happen often, but there are some oddball fonts from my deep murky past that I have kept around for testing and they kill it quick. I don't know if I can attach items to this list, so will await interest. I cannot really narrow this down much more. It looks like the family name is missing (see info at end), which might be the bug. When I try [font = ImageFont.truetype(paf, points,index=0, encoding="armn") ] or any of the other encodings (which I can't really find a good list of) the effect is still the same. Naturally, having an segfault means there ain't no way to catch it within Python! Regards, \d Font info: crashme2:$ ftinfo -la Anatevka\ Caps.ttf Anatevka Caps.ttf: 0 face Anatevka Caps.ttf: 0: 0 charmap: Apple, Unicode defaut semantics Anatevka Caps.ttf: 0: 1 charmap: Macintosh, Roman Anatevka Caps.ttf: 0: 2 charmap: Microsoft, Unicode Anatevka Caps.ttf: 0: header: HASH(0x8350614) Anatevka Caps.ttf: 0: horizontal: HASH(0x8350740) Anatevka Caps.ttf: 0: max_Contours: 11 Anatevka Caps.ttf: 0: max_Points: 117 Anatevka Caps.ttf: 0: num_Faces: 1 Anatevka Caps.ttf: 0: num_Glyphs: 251 Anatevka Caps.ttf: 0: os2: HASH(0x8350824) Anatevka Caps.ttf: 0: postscript: HASH(0x83509bc) Anatevka Caps.ttf: 0: header: CheckSum_Adjust: -1410471583 Anatevka Caps.ttf: 0: header: Created: ARRAY(0x8350668) Anatevka Caps.ttf: 0: header: Flags: 0 Anatevka Caps.ttf: 0: header: Font_Direction: 2 Anatevka Caps.ttf: 0: header: Font_Revision: 65536 Anatevka Caps.ttf: 0: header: Glyph_Data_Format: 0 Anatevka Caps.ttf: 0: header: Index_To_Loc_Format: 1 Anatevka Caps.ttf: 0: header: Lowest_Rec_PPEM: 3 Anatevka Caps.ttf: 0: header: Mac_Style: 0 Anatevka Caps.ttf: 0: header: Magic_Number: 1594834165 Anatevka Caps.ttf: 0: header: Modified: ARRAY(0x8350698) Anatevka Caps.ttf: 0: header: Table_Version: 65536 Anatevka Caps.ttf: 0: header: Units_Per_EM: 4096 Anatevka Caps.ttf: 0: header: xMax: 3424 Anatevka Caps.ttf: 0: header: xMin: -574 Anatevka Caps.ttf: 0: header: yMax: 2693 Anatevka Caps.ttf: 0: header: yMin: -573 Anatevka Caps.ttf: 0: horizontal: Ascender: 2693 Anatevka Caps.ttf: 0: horizontal: Descender: -573 Anatevka Caps.ttf: 0: horizontal: Line_Gap: 300 Anatevka Caps.ttf: 0: horizontal: Reserved0: 0 Anatevka Caps.ttf: 0: horizontal: Reserved1: 0 Anatevka Caps.ttf: 0: horizontal: Reserved2: 0 Anatevka Caps.ttf: 0: horizontal: Reserved3: 0 Anatevka Caps.ttf: 0: horizontal: Reserved4: 0 Anatevka Caps.ttf: 0: horizontal: Version: 65536 Anatevka Caps.ttf: 0: horizontal: advance_Width_Max: 3809 Anatevka Caps.ttf: 0: horizontal: caret_Slope_Rise: 1 Anatevka Caps.ttf: 0: horizontal: caret_Slope_Run: 0 Anatevka Caps.ttf: 0: horizontal: metric_Data_Format: 0 Anatevka Caps.ttf: 0: horizontal: min_Left_Side_Bearing: -574 Anatevka Caps.ttf: 0: horizontal: min_Right_Side_Bearing: -971 Anatevka Caps.ttf: 0: horizontal: number_Of_HMetrics: 248 Anatevka Caps.ttf: 0: horizontal: xMax_Extent: 3424 Anatevka Caps.ttf: 0: 0 name: Apple, Unicode defaut semantics, unknown 0, Copyright notice: ............................................................ Anatevka Caps.ttf: 0: 1 name: Apple, Unicode defaut semantics, unknown 0, Font Family name: ............ Anatevka Caps.ttf: 0: 2 name: Apple, Unicode defaut semantics, unknown 0, Font Subfamily name: Anatevka Caps.ttf: 0: 3 name: Apple, Unicode defaut semantics, unknown 0, Unique font identifier: ................ Anatevka Caps.ttf: 0: 4 name: Apple, Unicode defaut semantics, unknown 0, Full font name: ............ Anatevka Caps.ttf: 0: 5 name: Apple, Unicode defaut semantics, unknown 0, Version string: ............ Anatevka Caps.ttf: 0: 6 name: Apple, Unicode defaut semantics, unknown 0, Postscript name for the font: ............ Anatevka Caps.ttf: 0: 7 name: Apple, Unicode defaut semantics, unknown 0, Trademark: .......... Anatevka Caps.ttf: 0: 8 name: Macintosh, Roman, English, Copyright notice: Copyright 1999 DATA BECKER GmbH & Co. KG. All Rights Reserved Anatevka Caps.ttf: 0: 9 name: Macintosh, Roman, English, Font Family name: Anatevka Caps Anatevka Caps.ttf: 0: 10 name: Macintosh, Roman, English, Font Subfamily name: Anatevka Caps.ttf: 0: 11 name: Macintosh, Roman, English, Unique font identifier: PAW-Anatevka Caps Anatevka Caps.ttf: 0: 12 name: Macintosh, Roman, English, Full font name: Anatevka Caps Anatevka Caps.ttf: 0: 13 name: Macintosh, Roman, English, Version string: Version 1.50 Anatevka Caps.ttf: 0: 14 name: Macintosh, Roman, English, Postscript name for the font: Anatevka Caps Anatevka Caps.ttf: 0: 15 name: Macintosh, Roman, English, Trademark: DATA BECKER Anatevka Caps.ttf: 0: 16 name: Microsoft, Unicode, English - United States, Copyright notice: Copyright 1999 DATA BECKER GmbH & Co. KG. All Rights Reserved Anatevka Caps.ttf: 0: 17 name: Microsoft, Unicode, English - United States, Font Family name: Anatevka Caps Anatevka Caps.ttf: 0: 18 name: Microsoft, Unicode, English - United States, Font Subfamily name: Anatevka Caps.ttf: 0: 19 name: Microsoft, Unicode, English - United States, Unique font identifier: PAW-Anatevka Caps Anatevka Caps.ttf: 0: 20 name: Microsoft, Unicode, English - United States, Full font name: Anatevka Caps Anatevka Caps.ttf: 0: 21 name: Microsoft, Unicode, English - United States, Version string: Version 1.50 Anatevka Caps.ttf: 0: 22 name: Microsoft, Unicode, English - United States, Postscript name for the font: Anatevka Caps Anatevka Caps.ttf: 0: 23 name: Microsoft, Unicode, English - United States, Trademark: DATA BECKER Anatevka Caps.ttf: 0: os2: code page range: Anatevka Caps.ttf: 0: os2: unicode range: Anatevka Caps.ttf: 0: os2: xAvgCharWidth = 1369 Anatevka Caps.ttf: 0: os2: usWeightClass: Normal (Regular) Anatevka Caps.ttf: 0: os2: usWidthClass : Medium (normal) Anatevka Caps.ttf: 0: os2: fsSelection : REGULAR Anatevka Caps.ttf: 0: os2: achVendID: Alts Anatevka Caps.ttf: 0: os2: fsSelection: 64 Anatevka Caps.ttf: 0: os2: fsType: 1 Anatevka Caps.ttf: 0: os2: panose: 0x00 0x00 0x04 0x00 0x00 0x00 0x00 0x00 0x00 0x00 Anatevka Caps.ttf: 0: os2: sFamilyClass: 0 Anatevka Caps.ttf: 0: os2: sTypoAscender: 2307 Anatevka Caps.ttf: 0: os2: sTypoDescender: -1789 Anatevka Caps.ttf: 0: os2: sTypoLineGap: 300 Anatevka Caps.ttf: 0: os2: ulCodePageRange1: 0 Anatevka Caps.ttf: 0: os2: ulCodePageRange2: 0 Anatevka Caps.ttf: 0: os2: ulUnicodeRange1: 0 Anatevka Caps.ttf: 0: os2: ulUnicodeRange2: 0 Anatevka Caps.ttf: 0: os2: ulUnicodeRange3: 0 Anatevka Caps.ttf: 0: os2: ulUnicodeRange4: 0 Anatevka Caps.ttf: 0: os2: usFirstCharIndex: 32 Anatevka Caps.ttf: 0: os2: usLastCharIndex: 64258 Anatevka Caps.ttf: 0: os2: usWeightClass: 400 Anatevka Caps.ttf: 0: os2: usWidthClass: 5 Anatevka Caps.ttf: 0: os2: usWinAscent: 2693 Anatevka Caps.ttf: 0: os2: usWinDescent: 573 Anatevka Caps.ttf: 0: os2: version: 0 Anatevka Caps.ttf: 0: os2: xAvgCharWidth: 1369 Anatevka Caps.ttf: 0: os2: yStrikeoutPosition: 1120 Anatevka Caps.ttf: 0: os2: yStrikeoutSize: 204 Anatevka Caps.ttf: 0: os2: ySubscriptXOffset: 0 Anatevka Caps.ttf: 0: os2: ySubscriptXSize: 512 Anatevka Caps.ttf: 0: os2: ySubscriptYOffset: 586 Anatevka Caps.ttf: 0: os2: ySubscriptYSize: 512 Anatevka Caps.ttf: 0: os2: ySuperscriptXOffset: 0 Anatevka Caps.ttf: 0: os2: ySuperscriptXSize: 512 Anatevka Caps.ttf: 0: os2: ySuperscriptYOffset: 2300 Anatevka Caps.ttf: 0: os2: ySuperscriptYSize: 512 Anatevka Caps.ttf: 0: postscript: FormatType: 131072 Anatevka Caps.ttf: 0: postscript: isFixedPitch: 0 Anatevka Caps.ttf: 0: postscript: italicAngle: 0 Anatevka Caps.ttf: 0: postscript: maxMemType1: 0 Anatevka Caps.ttf: 0: postscript: maxMemType42: 0 Anatevka Caps.ttf: 0: postscript: minMemType1: 0 Anatevka Caps.ttf: 0: postscript: minMemType42: 0 Anatevka Caps.ttf: 0: postscript: underlinePosition: -400 Anatevka Caps.ttf: 0: postscript: underlineThickness: 160 From donn.ingle at gmail.com Sat Dec 22 14:30:14 2007 From: donn.ingle at gmail.com (Donn) Date: Sat, 22 Dec 2007 15:30:14 +0200 Subject: [Image-SIG] PIL ImageFont segfault mystery In-Reply-To: <200712201609.20665.donn.ingle@gmail.com> References: <200712201609.20665.donn.ingle@gmail.com> Message-ID: <200712221530.14941.donn.ingle@gmail.com> No takers? I'll have a look for the bug report link online. \d From fredrik at pythonware.com Sat Dec 22 15:23:23 2007 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 22 Dec 2007 15:23:23 +0100 Subject: [Image-SIG] PIL ImageFont segfault mystery In-Reply-To: <200712221530.14941.donn.ingle@gmail.com> References: <200712201609.20665.donn.ingle@gmail.com> <200712221530.14941.donn.ingle@gmail.com> Message-ID: Donn wrote: > No takers? I'll have a look for the bug report link online. seeing the bug report isn't necessarily the same thing as having time to work on a fix ;-) my guess is that the file uses some less common file format feature, which causes either freetype or the _imagingft binding to choke, but I need a copy of the font file to be sure (either mail it to me, or post it somewhere and mail me a link). cheers /F From fredrik at pythonware.com Sun Dec 23 20:38:08 2007 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 23 Dec 2007 20:38:08 +0100 Subject: [Image-SIG] PIL ImageFont segfault mystery In-Reply-To: References: <200712201609.20665.donn.ingle@gmail.com> <200712221530.14941.donn.ingle@gmail.com> Message-ID: Fredrik Lundh wrote: > seeing the bug report isn't necessarily the same thing as having time to > work on a fix ;-) as I suspected, the offending files was missing some optional fields; freetype2 handled that nicely, but _imagingft module didn't expect the fields to be NULL. here's a tentative patch: $ svn diff _imagingft.c Index: _imagingft.c =================================================================== --- _imagingft.c (revision 3345) +++ _imagingft.c (working copy) @@ -422,10 +422,11 @@ /* attributes */ if (!strcmp(name, "family")) - return PyString_FromString(self->face->family_name); + return PyString_FromString(self->face->family_name ? + self->face->family_name : ""); if (!strcmp(name, "style")) - return PyString_FromString(self->face->style_name); - + return PyString_FromString(self->face->style_name ? + self->face->style_name : ""); if (!strcmp(name, "ascent")) return PyInt_FromLong(PIXEL(self->face->size->metrics.ascender)); if (!strcmp(name, "descent")) (might be a better idea to return None in this case, but the above will at least prevent the crash). From donn.ingle at gmail.com Mon Dec 24 09:24:31 2007 From: donn.ingle at gmail.com (Donn) Date: Mon, 24 Dec 2007 10:24:31 +0200 Subject: [Image-SIG] PIL ImageFont segfault mystery In-Reply-To: References: <200712201609.20665.donn.ingle@gmail.com> Message-ID: <200712241024.31700.donn.ingle@gmail.com> Fredrik, I dropped off the Internet (I have a fragile ISP :( ) and did not get your mail until a moment ago. Thanks for looking at this. I am not at all informed about how patches get used and, more importantly, how they make their way into the final repos used by distros. Is there any way to get _imagingft.c fixed so that old users worldwide get an update, or will this fix only come out in new versions of PIL from this point on? I ask because I am facing a choice of 1) just waiting and using my short time to code my app then relying on the fix being "out there", or 2) Trying to grok and compile PIL and then house it in a sub-directory of my app and distribute it as a "module" within my app. Thanks for the help! \d PS: Not to muddy the waters, but PIL is the only effective FT2 interface for Python and I was wondering if it would be possible to expose more meta information about fonts than family and style? There are other snippets of info in there like number of faces, copyright, foundry and so forth. Would it be possible to add these too? From donn.ingle at gmail.com Tue Dec 25 18:56:10 2007 From: donn.ingle at gmail.com (Donn) Date: Tue, 25 Dec 2007 19:56:10 +0200 Subject: [Image-SIG] Python MemoryError on a ttf font In-Reply-To: <200712251936.32314.donn.ingle@gmail.com> References: <200712251936.32314.donn.ingle@gmail.com> Message-ID: <200712251956.10318.donn.ingle@gmail.com> More info, I noticed that if you render only one character, like "A", it works. It crashes on "TE", but not "T". I tried various combinations, but the picture is not clear. It sure doesn't like the capital "T" :) \d > Hi again, > I thought I'd let you know about another font that's causing an error. The > font is attached. Here's the code that I used: From donn.ingle at gmail.com Wed Dec 26 15:40:23 2007 From: donn.ingle at gmail.com (Donn) Date: Wed, 26 Dec 2007 16:40:23 +0200 Subject: [Image-SIG] ImageFont Unicode Decode error Message-ID: <200712261640.23347.donn.ingle@gmail.com> Hello, Trying to open a ttf file with a non-standard character in it (u'\xe5') causes an error, no matter what I pass to encoding: enc="unic" enc="unicode" enc="utf8" etc. font = ImageFont.truetype( paf, 64, index=i , encoding=enc ) The error: File "/usr/lib/python2.5/site-packages/PIL/ImageFont.py", line 205, in truetype return FreeTypeFont(filename, size, index, encoding) File "/usr/lib/python2.5/site-packages/PIL/ImageFont.py", line 121, in __init__ self.font = _imagingft.getfont(file, size, index, encoding) UnicodeEncodeError: 'ascii' codec can't encode character u'\xe5' in position 66: ordinal not in range(128) Is there something I'm doing wrong, or is this a bug? \d From donn.ingle at gmail.com Tue Dec 25 18:36:32 2007 From: donn.ingle at gmail.com (Donn) Date: Tue, 25 Dec 2007 19:36:32 +0200 Subject: [Image-SIG] Python MemoryError on a ttf font Message-ID: <200712251936.32314.donn.ingle@gmail.com> Hi again, I thought I'd let you know about another font that's causing an error. The font is attached. Here's the code that I used: paf = "/home/donn/06.FontStore/TTFS/O/Onsoku Seinen Plane.ttf" text = "Test Text" font = ImageFont.truetype( paf, 64, index=0, encoding="unicode" ) pilheight = int( font.getsize( text )[1] ) pilimage = Image.new("RGB", (500,pilheight), (255,255,255)) drawnFont = ImageDraw.Draw( pilimage ) # This line causes a MemoryError: drawnFont.text((0,0) , text, font=font, fill=0 ) Is there any way to tell ahead of time (i.e. without having to render it with.text) that it's a candidate for error? Regards, Donn. -------------- next part -------------- A non-text attachment was scrubbed... Name: Onsoku Seinen Plane.ttf Type: application/x-font-ttf Size: 67244 bytes Desc: not available Url : http://mail.python.org/pipermail/image-sig/attachments/20071225/055c7253/attachment-0001.bin From junk at ysengrin.com Thu Dec 27 01:47:10 2007 From: junk at ysengrin.com (junk at ysengrin.com) Date: Wed, 26 Dec 2007 16:47:10 -0800 Subject: [Image-SIG] [PIL 1.1.6] bug with python 2.51 but not with python 2.44 Message-ID: <4772F60E.3000000@ysengrin.com> Hi, the same code runs fine in python 2.44 but fails with python 2.51 File "/usr/local/lib/python2.5/site-packages/PIL/Image.py", line 783, in filter filter = filter() AttributeError: Kernel instance has no __call__ method contact me if you need more info yomgui From fredrik at pythonware.com Thu Dec 27 11:19:07 2007 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 27 Dec 2007 11:19:07 +0100 Subject: [Image-SIG] [PIL 1.1.6] bug with python 2.51 but not with python 2.44 In-Reply-To: <4772F60E.3000000@ysengrin.com> References: <4772F60E.3000000@ysengrin.com> Message-ID: junk at ysengrin.com wrote: > the same code runs fine in python 2.44 but fails with python 2.51 > > File "/usr/local/lib/python2.5/site-packages/PIL/Image.py", line 783, in filter > filter = filter() > AttributeError: Kernel instance has no __call__ method > > contact me if you need more info are you perhaps importing things both from "PIL" and from the path itself? (e.g. mixing "from PIL import Image" with "import Image"?). does PIL's installation directory appear in sys.path? if you cannot make this work, try changing if not isinstance(filter, Filter): filter = filter() to if type(filter) is type(Filter): filter = filter() in Image.py. From fredrik at pythonware.com Thu Dec 27 12:52:37 2007 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 27 Dec 2007 12:52:37 +0100 Subject: [Image-SIG] [PIL 1.1.6] bug with python 2.51 but not with python 2.44 In-Reply-To: References: <4772F60E.3000000@ysengrin.com> Message-ID: Fredrik Lundh wrote: > if you cannot make this work, try changing > > if not isinstance(filter, Filter): > filter = filter() > > to > > if type(filter) is type(Filter): > filter = filter() > > in Image.py. or, better: if callable(filter): filter = filter() From donn.ingle at gmail.com Thu Dec 27 16:46:35 2007 From: donn.ingle at gmail.com (Donn) Date: Thu, 27 Dec 2007 17:46:35 +0200 Subject: [Image-SIG] ImageFont Unicode Decode error In-Reply-To: <194b7da00712260710v6cab83afv82f67948a18c97b3@mail.gmail.com> References: <200712261640.23347.donn.ingle@gmail.com> <194b7da00712260710v6cab83afv82f67948a18c97b3@mail.gmail.com> Message-ID: <200712271746.36038.donn.ingle@gmail.com> > I don't know, but may be PIL needs to have the Byte Order Mark for handling > unicode. Not 100% sure what you are saying. That character is ( I don't know if it will travel ) "?" and I can open files that contain it with my other python stuff like codes.open etc. Are you suggesting a solution to me or thinking aloud :) I'm on Kubuntu Gnu/Linux 7.10 with Python 2.5 \d > Hello, > Trying to open a ttf file with a non-standard character in it (u'\xe5') > causes an error, no matter what I pass to encoding: > > enc="unic" > enc="unicode" > enc="utf8" > etc. > font = ImageFont.truetype( paf, 64, index=i , encoding=enc ) > > The error: > File "/usr/lib/python2.5/site-packages/PIL/ImageFont.py", line 205, in > truetype > return FreeTypeFont(filename, size, index, encoding) > File "/usr/lib/python2.5/site-packages/PIL/ImageFont.py", line 121, in > __init__ > self.font = _imagingft.getfont(file, size, index, encoding) > UnicodeEncodeError: 'ascii' codec can't encode character u'\xe5' in > position > 66: ordinal not in range(128) > > > Is there something I'm doing wrong, or is this a bug? > > \d