From karsten.hiddemann at mathematik.uni-dortmund.de Thu May 1 01:49:25 2008 From: karsten.hiddemann at mathematik.uni-dortmund.de (Karsten Hiddemann) Date: Thu, 01 May 2008 01:49:25 +0200 Subject: [Image-SIG] Updated ImagePlugin for the SGI file format Message-ID: <48190585.1070306@mathematik.uni-dortmund.de> Attached is an updated ImagePlugin for PIL to read (some) RLE-compressed SGI images. I needed to load RLE-compressed images for a program of mine and didn't like that I had to use PythonMagick for this. William Baxter asked about this on the list about half a year ago as well, I believe. The former SGI ImagePlugin used the wrong orientation when loading SGI images, too. It took me quite some time to come up with a way to extend the image loading mechanism of PIL. What I came up with is possibly quite a hack, but the best I could do by reading the source code for ImageFile.py, TiffImagePlugin.py and Unpack.c as reference. I didn't find out how to implement a custom decoder instead of the default "raw" encoder, as there seemed to be a lack of documentation for this? You'll find a couple of FIXME tags in the code where I didn't know how to tell PIL what I wanted to do, for example when it comes to loading some 16 bit channel data. Proper options for the tile list are still a mystery to me, since Unpack.c has some modes like "xxx;L" and "xxx;16B" which don't seem to be supported by the raw decoder yet, or at least I couldn't find the right combination of self.mode and "raw" read mode. I tested this against a couple of *.sgi and *.rgba images that I found via filewatcher.com and it worked fine on those that it supported. Some nasty unsupported images can be found at Toby Thain's Telegraphics site where he keeps a SGI format plugin for Photoshop. For example, only "normal" Colormaps are supported at the moment, although things like dithered images wouldn't be too hard to add (though obsolete). I didn't have the chance to test greyscale images, but they should load okay. I don't know what the requirements are for using this code, as this is just my second program in Python and I have no idea how portable my code is towards older versions of Python. I have developed it under Python 2.4.4 myself and would expect that one would need at least Python 2.0. Any comments on this, new testdata for monochrome or dithered images, or tips for to address some of my FIXME's are highly welcome. In case this gets added to the official PIL codebase, I have found a couple of other ImagePlugins while searching for reference code on the net that I'd propose to add: - Bob Ippolito made plugins for the Mac OS X icns file format and for the SoftImage format, however it seems like only the IcnsImagePlugin.py was added. The other one can be found at https://svn.red-bean.com/bob/SoftimageImage/trunk/ If you Google for the filename you'll find that some others have found interest in it, too. - John Wright has code for a plugin online which can read and write Nokia operator logos in the OTB and GMS format: http://www.dryfish.org/projects/NokiaImagePlugin.py.html - Oliver Jowett developed a plugin to read a variety of DDS texture files. The original page is gone, but can still be observed in archive.org, the code has been picked up and improved by two separate parties for some "Dark Age of Camelot" projects. Here are some links: http://web.archive.org/web/20031205022205/http://www.randomly.org/projects/mapper/index.html (archived version of the original site for the code) http://www.ceejbot.com/DAoC/ (a fixed version of the DAoC Mapper) http://www.ceejbot.com/DAoC/tools/DdsImageFile.py (download there) http://nathrach.republicofnewhome.org/mappergui.html#reqs (download MapperGUI 2.4) The two versions of this plugin differ in only six lines, it seems that in the original source code some color channels were switched. Cheers, Karsten Hiddemann -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: SgiImagePlugin.py URL: From karsten.hiddemann at mathematik.uni-dortmund.de Thu May 1 18:36:22 2008 From: karsten.hiddemann at mathematik.uni-dortmund.de (Karsten Hiddemann) Date: Thu, 01 May 2008 18:36:22 +0200 Subject: [Image-SIG] Simple ICO => PNG conversion problem Message-ID: <4819F186.9080405@mathematik.uni-dortmund.de> The IcoImagePlugin is among the oldest code in PIL. Have a look at it, all it does is finding out where the InfoHeader for the biggest icon starts in the file (since an icon file can contain more than one image), calls the BMP plugin with that, and then adjusts the image height. This closely matches the structure in http://www.daubnet.com/formats/ICO.html which is for pre-WinXP icon formats, I think. PIL plain ignores the transparency which comes from the AND mask inherent to the ICO format. The IcoImagePlugin should be consequently rewritten from scratch to support things like the ContainerIO, if somebody cares. If you look at http://www.blitzbasic.com/Community/posts.php?topic=75770 or the Wikipedia article for the ICO file format you'll see that XP as well as Vista extended the file format. But unless somebody does this, here's a way for you to get the transparency right when loading your icon: i = Image.open("favicon.ico") d, e, o, a = i.tile[0] s = file("favicon.ico").read() mask = Image.fromstring('1', i.size, s[o+e[2]*e[3]:], "raw", ('1;I', 4, -1)) i.putalpha(mask) i.save("test.png") Cheers, Karsten From Chris.Barker at noaa.gov Fri May 2 18:07:09 2008 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Fri, 02 May 2008 09:07:09 -0700 Subject: [Image-SIG] Please test PIL package on OS-X In-Reply-To: <6101F578-702B-4D0C-A4E0-9E137DB7C854@kyngchaos.com> References: <480D3058.8070501@hawaii.edu> <9911419a0804222302x1e417cbdxfde399f1907f5f47@mail.gmail.com> <1d1e6ea70804230201t14a9e381qd3cee6be6ca47224@mail.gmail.com> <480F69B6.6050203@noaa.gov> <96c9d6a80804231001v20d48c0x2463a6f0ec1fc551@mail.gmail.com> <96c9d6a80804231004y16d0d7bbk14f313330676252f@mail.gmail.com> <480F6F72.80307@noaa.gov> <96c9d6a80804231025s13bb7fa7u92b37fdaac3bb8b3@mail.gmail.com> <4810B62F.1020908@noaa.gov> <9A733E3D-A01E-4688-8D3B-7310844BA3DA@kyngchaos.com> <4810E0A6.9000005@noaa.gov> <53FF4D70-9B44-40BD-B802-FDCDA8E2A7E6@kyngchaos.com> <48111DE4.1000902@noaa.gov> <6101F578-702B-4D0C-A4E0-9E137DB7C854@kyngchaos.com> Message-ID: <481B3C2D.2090801@noaa.gov> Hi all, I've been experimenting with building PIL for OS-X in a new way, providing the dependencies through William Kyngesburye's Unix Compatability frameworks: http://www.kyngchaos.com/wiki/software:frameworks See earlier posts on the MacPython lists for details. The short version is that the Frameworks provide universal versions of a bunch of libraries that PIL and other Python packages (Matplotlib, etc) rely on. They are an easy click install. The motivation for this is that the dependencies are otherwise very tricky to build correctly for Universal python builds. The result is a PIL package that installs easily on PPC an Intel systems, and can be bundles up with py2app to provide a Universal stand alone application. I've built the installer, written a simple test app, and built an app out of that. They all work on the PPC 10.4 and Intel 10.4 systems I have to test -- I'd love others to test them as well. on this ftp site: ftp://ftp.orr.noaa.gov/public/HMRD/Python You will find: SimplePILTest.py : the test script PILTest.zip: the test application -- it should run with nothing else installed on any 10.4+ system PIL-1.1.6-py2.5-macosx10.4.mpkg.zip : The PIL package installer, for python.org python2.5 framework build. It depends on the following frameworks: FreeType_Framework-2.3.5-3.dmg: Freetype UnixImageIO_Framework-1.0.22a.dmg: various image libs, jpeg, etc. Please test on your machine, and let me know if they work! If they do, then we could build versions for Apple's Python 2.5 on OS-X 10.5, and maybe bundle up the Frameworks inside the PIL package installer for one-click installation. And do the same thing for Matplotlib, and ??? -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 karsten.hiddemann at mathematik.uni-dortmund.de Fri May 2 23:38:44 2008 From: karsten.hiddemann at mathematik.uni-dortmund.de (Karsten Hiddemann) Date: Fri, 02 May 2008 23:38:44 +0200 Subject: [Image-SIG] Please test PIL package on OS-X References: 481B3C2D.2090801@noaa.gov Message-ID: <481B89E4.1010007@mathematik.uni-dortmund.de> Here is my experience with it on a Mac OS X 10.5.2 system: - clicked on the SimplePILTest thing. Nothing happens. Is it broken? - I try to start it via Terminal: $ ./SimplePILTest.app/Contents/MacOS/python Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] 'import site' failed; use -v for traceback Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04) [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> ^D $ ./SimplePILTest.app/Contents/MacOS/python -v Could not find platform independent libraries Could not find platform dependent libraries Consider setting $PYTHONHOME to [:] # installing zipimport hook import zipimport # builtin # installed zipimport hook 'import site' failed; traceback: ImportError: No module named site Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04) [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> - I try to install PIL now. First the FreeType framework, then the UnixImageIO framework. Installs okay. Then I try to install PIL: The installer tells me that "PIL requires System Python 2.5 to install." - To my surprise (I am new to this whole Mac experience) Python 2.5.1 is already preinstalled on my system. But PIL doesn't want to install on that. So I download the Python 2.5.2 build from python.org and install that. After this, the PIL package installs fine. - Now I try to run the script by hand: $ python SimplePILTest.py SafetyGirl1-small.jpg Processing: SafetyGirl1-small.jpg It is a JPEG, (461, 615), RGB image writing out a version with some text on it: Traceback (most recent call last): File "SimplePILTest.py", line 17, in font = ImageFont.truetype("veraBd.ttf", 60) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/PIL/ImageFont.py", line 205, in truetype return FreeTypeFont(filename, size, index, encoding) File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/PIL/ImageFont.py", line 121, in __init__ self.font = _imagingft.getfont(file, size, index, encoding) IOError: cannot open resource - It needs the font file, which isn't in there. So I do: $ cd SimplePILTest.app/Contents/Resources/ $ python SimplePILTest.py ../../../SafetyGirl1-small.jpg #Processing: ../../../SafetyGirl1-small.jpg It is a JPEG, (461, 615), RGB image writing out a version with some text on it: - It works, it actually produced a watermarked image! Wait, that means that I should have just dropped the image on the App? (tries) Yes, that works, too. Maybe I should have tested that before installing Python 2.5.2 and PIL and the other frameworks to test the standalone version. So, to sum it up: It does work, very nice work. But you should have described a little better what one is supposed to do to test it. ;) What I dislike: There's no way to uninstall these thing again right now. From Chris.Barker at noaa.gov Sat May 3 01:14:18 2008 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Fri, 02 May 2008 16:14:18 -0700 Subject: [Image-SIG] Please test PIL package on OS-X In-Reply-To: <481B89E4.1010007@mathematik.uni-dortmund.de> References: <481B3C2D.2090801@noaa.gov> <481B89E4.1010007@mathematik.uni-dortmund.de> Message-ID: <481BA04A.7020705@noaa.gov> Karsten Hiddemann wrote: > Here is my experience with it on a Mac OS X 10.5.2 system: Thanks for trying it: > - clicked on the SimplePILTest thing. Nothing happens. Is it broken? oops, sorry, I didn't tell you what to do with it! Drag and drop a *.jpg on it -- it should make a copy with "Watermark" printed in top, in the upper left hand corner. You can also open the "Console" app, and it should give you a bit of output. Sorry, I didn't want to complicate the test with a gui toolkit. > - I try to start it via Terminal: > > $ ./SimplePILTest.app/Contents/MacOS/python I don't expect that to work. > So I download the Python 2.5.2 build from python.org and install > that. After this, the PIL package installs fine. Yes, this installer is built for the python.org build, not the Apple one -- we could do that to, but I don't have 10.5, so I can't do it. > - Now I try to run the script by hand: > > $ python SimplePILTest.py SafetyGirl1-small.jpg > "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/PIL/ImageFont.py", > line 205, in truetype > return FreeTypeFont(filename, size, index, encoding) > File > "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/PIL/ImageFont.py", > line 121, in __init__ > self.font = _imagingft.getfont(file, size, index, encoding) > IOError: cannot open resource > > - It needs the font file, which isn't in there. So I do: Correct -- arrg! sorry about this, the font is bundled with the *.app, but I didn't give you it. > $ cd SimplePILTest.app/Contents/Resources/ > $ python SimplePILTest.py ../../../SafetyGirl1-small.jpg > #Processing: ../../../SafetyGirl1-small.jpg > It is a JPEG, (461, 615), RGB image > writing out a version with some text on it: > > - It works, it actually produced a watermarked image! Wait, that means > that I should have just dropped the image on the App? (tries) Yes, that > works, too. Maybe I should have tested that before installing Python > 2.5.2 and PIL and the other frameworks to test the standalone version. That would have been nice. > So, to sum it up: It does work, very nice work. But you should have > described a little better what one is supposed to do to test it. ;) Yes, I should have -- sorry. Thank you for being so persistent! > What I dislike: There's no way to uninstall these thing again right now. Blame Apple for that -- these are standard Apple packages. Anyway, I think you can simply remove them by hand. You need to delete: /Library/Frameworks/Python.framework/ (if you don't want to keep using it) /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/PIL (if you only want to remove PIL) /Library/Frameworks/UnixImageIO.framework/ /Library/Frameworks/FreeType.framework/ If you do remove all those, would you mind testing the .app again, just to make sure? Thanks for testing. -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 rfritz at u.washington.edu Sun May 4 01:49:38 2008 From: rfritz at u.washington.edu (R Fritz) Date: Sat, 3 May 2008 16:49:38 -0700 Subject: [Image-SIG] Is anyone doing HDR image processing with Python? Message-ID: <3CCE99E5-6B2B-42E9-B9ED-43D42D12C8BE@u.washington.edu> Hi! I'm a newbie here, and I'm here because I find myself starting to do HDR work & would really like to use Python to do it. Anyone else here trying it? Or heard of it? Or anything? Randolph Fritz design machine group architecture department university of washington rfritz at u.washington.edu From gwidion at mpc.com.br Sun May 4 10:22:23 2008 From: gwidion at mpc.com.br (Joao S. O. Bueno) Date: Sun, 4 May 2008 05:22:23 -0300 Subject: [Image-SIG] Is anyone doing HDR image processing with Python? In-Reply-To: <3CCE99E5-6B2B-42E9-B9ED-43D42D12C8BE@u.washington.edu> References: <3CCE99E5-6B2B-42E9-B9ED-43D42D12C8BE@u.washington.edu> Message-ID: <200805040522.23639.gwidion@mpc.com.br> On Saturday 03 May 2008, R Fritz wrote: > Hi! I'm a newbie here, and I'm here because I find myself starting > to do HDR work & would really like to use Python to do it. Anyone > else here trying it? Or heard of it? Or anything? > Hi - I don? know of anything specific for HDR,but I'd try doing it with GEGL - and, yes, there are python bindings for it (www.gegl.org - you have to enter bindings/python in the tarball tree and make install the python bindings after isntalling gegl) js -><- > Randolph Fritz > design machine group > architecture department > university of washington > rfritz at u.washington.edu > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig From sou2k at yahoo.com Mon May 5 08:45:44 2008 From: sou2k at yahoo.com (sounav maikap) Date: Sun, 4 May 2008 23:45:44 -0700 (PDT) Subject: [Image-SIG] Fw: Searching an Image pattern inside another image Message-ID: <236108.57022.qm@web53912.mail.re2.yahoo.com> Has anybody tried any fast algo to find an image inside another using PIL?? -SM ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ From eric.germaneau at epfl.ch Fri May 9 16:07:40 2008 From: eric.germaneau at epfl.ch (Eric Germaneau) Date: Fri, 09 May 2008 16:07:40 +0200 Subject: [Image-SIG] oepn a float image Message-ID: <48245AAC.5030108@epfl.ch> Dear all, I been trying to open a 32-bit (float) tif image with PIL without any success. I've tried: fp = open("mytest32.tif", "rb") im = Image.open(fp) or im = Image.fromstring("F", (512,512), "mytest32.tif", "raw", "F;32NF", 1,1) or im = Image.fromstring("F", (512,512), "mytest32.tif", "bit", 32,8,3 ,0,1) I'm able to open an 8-bit image with fp = open("mytest8.tif", "rb") im = Image.open(fp) Can you please explain to me hoe to proceed with an 32-bit image? Whether you are interested, images (8-bit and 32-bit) are located here: http://marie.epfl.ch/germanea/mytest8.tif http://marie.epfl.ch/germanea/mytest32.tif I thank you in advance, Eric. -- /Vivre dans la conscience du Tao Se lib?rer du mental /--- Thierry Cha?bli --- Dr. ?ric Germaneau Ecole polytechnique f?d?rale de Lausanne (EPFL) FSB - IPMC Laboratoire de Cristallographie (LCr) BSP 518 CH-1015 Lausanne Switzerland eric.germaneau at epfl.ch /Tel./: +41 (0)21 / 693 06 36 /Fax./: +41 (0)21 / 693 05 04 /msn/: aihaike at hotmail.com /skype/: aihaike / Please consider the environment before printing this email. Consid?rez svp l'environnement avant d'imprimer cet email. / -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric.germaneau at epfl.ch Sat May 10 18:21:40 2008 From: eric.germaneau at epfl.ch (Eric Germaneau) Date: Sat, 10 May 2008 18:21:40 +0200 Subject: [Image-SIG] Help with PIL Message-ID: <4825CB94.8010707@epfl.ch> Dear all, I been trying to open a 32-bit (float) tif image with PIL without any success. I've tried: fp = open("mytest32.tif", "rb") im = Image.open(fp) or im = Image.fromstring("F", (512,512), "mytest32.tif", "raw", "F;32NF", 1,1) or im = Image.fromstring("F", (512,512), "mytest32.tif", "bit", 32,8,3 ,0,1) I'm able to open an 8-bit image with fp = open("mytest8.tif", "rb") im = Image.open(fp) Can you please explain to me hoe to proceed with an 32-bit image? Whether you are interested, images (8-bit and 32-bit) are located here: http://marie.epfl.ch/germanea/mytest8.tif http://marie.epfl.ch/germanea/mytest32.tif I thank you in advance, Eric. -- /Vivre dans la conscience du Tao Se lib?rer du mental /--- Thierry Cha?bli --- Dr. ?ric Germaneau Ecole polytechnique f?d?rale de Lausanne (EPFL) FSB - IPMC Laboratoire de Cristallographie (LCr) BSP 518 CH-1015 Lausanne Switzerland eric.germaneau at epfl.ch /Tel./: +41 (0)21 / 693 06 36 /Fax./: +41 (0)21 / 693 05 04 /msn/: aihaike at hotmail.com /skype/: aihaike / Please consider the environment before printing this email. Consid?rez svp l'environnement avant d'imprimer cet email. / -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric.germaneau at epfl.ch Sun May 11 01:07:00 2008 From: eric.germaneau at epfl.ch (Eric Germaneau) Date: Sun, 11 May 2008 01:07:00 +0200 Subject: [Image-SIG] pil and ImageJ Message-ID: <48262A94.2070304@epfl.ch> Dear PIL users, ImageJ is able to read 8-bit or 32-bit images and to change LUT as well. I'm wondering how to do the same thing with PIL. Is it possible to load/use lut file provided with ImageJ? Does someone has any idea? Best regards, Eric. -- / Vivre dans la conscience du Tao Se lib?rer du mental / --- Thierry Cha?bli --- Dr. ?ric Germaneau Ecole polytechnique f?d?rale de Lausanne (EPFL) FSB - IPMC Laboratoire de Cristallographie (LCr) BSP 518 CH-1015 Lausanne Switzerland eric.germaneau at epfl.ch /Tel./: +41 (0)21 / 693 06 36 /Fax./: +41 (0)21 / 693 05 04 /msn/: aihaike at hotmail.com /skype/: aihaike / Please consider the environment before printing this email. Consid?rez svp l'environnement avant d'imprimer cet email. / -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric.germaneau at epfl.ch Sun May 11 14:14:09 2008 From: eric.germaneau at epfl.ch (Eric Germaneau) Date: Sun, 11 May 2008 14:14:09 +0200 Subject: [Image-SIG] Help with PIL In-Reply-To: <4825CB94.8010707@epfl.ch> References: <4825CB94.8010707@epfl.ch> Message-ID: <4826E311.8050403@epfl.ch> Dear all, I've successfully load my image doing: *f = open(inFile, 'rb') allData = f.read() f.close() im = Image.fromstring("F", (512,512), allData, "raw", "F", 0,1)* Now I have to change the grayscale color to an other gradient like "Cyan hot" in imageJ. Eric. Eric Germaneau wrote: > Dear all, > > I been trying to open a 32-bit (float) tif image with PIL without any > success. > I've tried: > > fp = open("mytest32.tif", "rb") > im = Image.open(fp) > > or > > im = Image.fromstring("F", (512,512), "mytest32.tif", "raw", "F;32NF", > 1,1) > > or > > im = Image.fromstring("F", (512,512), "mytest32.tif", "bit", 32,8,3 ,0,1) > > I'm able to open an 8-bit image with > > fp = open("mytest8.tif", "rb") > im = Image.open(fp) > > Can you please explain to me hoe to proceed with an 32-bit image? > Whether you are interested, images (8-bit and 32-bit) are located > here: > > http://marie.epfl.ch/germanea/mytest8.tif > http://marie.epfl.ch/germanea/mytest32.tif > > I thank you in advance, > > Eric. > > -- > /Vivre dans la conscience du Tao > Se lib?rer du mental > /--- > Thierry Cha?bli --- > > Dr. ?ric Germaneau > Ecole polytechnique f?d?rale de Lausanne (EPFL) > FSB - IPMC > Laboratoire de Cristallographie (LCr) > BSP 518 > CH-1015 Lausanne > Switzerland > eric.germaneau at epfl.ch > /Tel./: +41 (0)21 / 693 06 36 > /Fax./: +41 (0)21 / 693 05 04 > /msn/: aihaike at hotmail.com > /skype/: aihaike > > / Please consider the environment before printing this email. > Consid?rez svp l'environnement avant d'imprimer cet email. / > > ------------------------------------------------------------------------ > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > -- / Vivre dans la conscience du Tao Se lib?rer du mental / --- Thierry Cha?bli --- Dr. ?ric Germaneau Ecole polytechnique f?d?rale de Lausanne (EPFL) FSB - IPMC Laboratoire de Cristallographie (LCr) BSP 518 CH-1015 Lausanne Switzerland eric.germaneau at epfl.ch /Tel./: +41 (0)21 / 693 06 36 /Fax./: +41 (0)21 / 693 05 04 /msn/: aihaike at hotmail.com /skype/: aihaike / Please consider the environment before printing this email. Consid?rez svp l'environnement avant d'imprimer cet email. / -------------- next part -------------- An HTML attachment was scrubbed... URL: From jmcKamey at neatreceipts.com Mon May 12 16:02:55 2008 From: jmcKamey at neatreceipts.com (Jon McKamey) Date: Mon, 12 May 2008 10:02:55 -0400 Subject: [Image-SIG] PIL and target processors and OSX, oh-my! Message-ID: <45E36921B695A14FA56A34F29424A1EC01257874@Apollo.neatreceipts.local> Hey all, I'm trying to get PIL and mod_python to run on apache2 on a Mac running OSX 10.5 To give some background, httpd is build with 4 target processors, so everything loaded by it (mod_python, PIL, etc) has to be built to handle all 4 target processors. Including all PIL and it's libraries. I am to the point where PIL has been rebuilt for the 4 target processors. If I run otool on it, I get the list of modules it loads, and not all of them are built for the 4 processors, some of which appear to be OS built-in libraries. So, the point I am stuck at: It's not clear to me how and what to do to rebuild those modules, and it's not clear to me if it's even safe to rebuild and replace those modules with 4 processor versions of the files. Has anyone reading this done this before? Is that safe to do? If not, what are the risks? And if so, can anyone recommend a toolset to do the rebuilding? Macports? Download the source and go? Any other suggestions or advice on this tricky topic? Thanks in advance for any and all help. PIL rocks, and I can't wait to (finally) get it integrated. - Jon McKamey -------------- next part -------------- An HTML attachment was scrubbed... URL: From Tim.Arnold at sas.com Wed May 14 17:28:04 2008 From: Tim.Arnold at sas.com (Tim Arnold) Date: Wed, 14 May 2008 11:28:04 -0400 Subject: [Image-SIG] saving dpi for png Message-ID: hi, I found it difficult to discover how to set the dpi for png images with pil, so I'd like to suggest an addition to the documentation: ------------------------------------------------------------- You can read the metadata in a png file as follows: im = Image.open('myfile.png') print im.info ##or just one value, for example: #print im.info['dpi'] You cannot change the values in the info dictionary directly, but you can set the values by using options on the save method: im1.save('mynewfile.png','PNG',dpi=(300,300)) You can see the results by opening and reading the info dictionary again: im2.open('mynewfile.png') print im2.info['dpi'] --------------------------------------------------------- I'm no expert and there may be a better way to accomplish this, but it got me what I needed. I think it's a fairly common situation. thanks, --Tim Arnold From Chris.Barker at noaa.gov Thu May 15 19:23:26 2008 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Thu, 15 May 2008 10:23:26 -0700 Subject: [Image-SIG] PIL and target processors and OSX, oh-my! In-Reply-To: <45E36921B695A14FA56A34F29424A1EC01257874@Apollo.neatreceipts.local> References: <45E36921B695A14FA56A34F29424A1EC01257874@Apollo.neatreceipts.local> Message-ID: <482C718E.50102@noaa.gov> Jon McKamey wrote: > I?m trying to get PIL and mod_python to run on apache2 on a Mac running > OSX 10.5 To give some background, httpd is build with 4 target > processors, so everything loaded by it (mod_python, PIL, etc) has to be > built to handle all 4 target processors. Including all PIL and it?s > libraries. I am to the point where PIL has been rebuilt for the 4 target > processors. If I run otool on it, I get the list of modules it loads, > and not all of them are built for the 4 processors, some of which appear > to be OS built-in libraries. > > So, the point I am stuck at: It?s not clear to me how and what to do to > rebuild those modules, and it?s not clear to me if it?s even safe to > rebuild and replace those modules with 4 processor versions of the > files. I wouldn't. Also, I'm a bit confused. The Apple-supplied built-in ones should be dynamic libs, and I thought those only had to be built for the processor you are running on. Which libs are you having issues with? Anyway, I wouldn't replace ANY system libs. If the system ones won't work for you, you'll probably need to build your own versions of them, install them elsewhere, and make sure PIL links to those. > Macports? Last I heard MacPorts and Fink don't do any multi-processor building. Which leaves you with: > Download the source and go? The problem there is that many (most) libs don't build Universal out of the box, so you need o go in and hack the MakeFiles. I've only done dual mode builds (PPC and Intel, 32bit), but I imagine it's a similar deal. One trick is going to be if Configure sets anything about 32 vs. 64 bits, then you may run into issues. I think most of the endian issues have been addressed in the major libraries. I'd try this question on the pythonmac list -- it's really more a Mac issue than a PIL one. Good luck! -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 jmcKamey at neatreceipts.com Thu May 15 19:45:36 2008 From: jmcKamey at neatreceipts.com (Jon McKamey) Date: Thu, 15 May 2008 13:45:36 -0400 Subject: [Image-SIG] PIL and target processors and OSX, oh-my! In-Reply-To: <482C718E.50102@noaa.gov> Message-ID: <45E36921B695A14FA56A34F29424A1EC012C75BA@Apollo.neatreceipts.local> After not getting a response, I sent this missive to the mod_python list as well. They recommended 'thinning' the application, as is outlined in the modwsgi tutorial for OSX. http://code.google.com/p/modwsgi/wiki/InstallationOnMacOSX That seems to work, and got things going. It also includes a good explanation of exactly what the underlying problems was, in case my question was not so clear. - Jon McKamey -----Original Message----- From: Christopher Barker [mailto:Chris.Barker at noaa.gov] Sent: Thursday, May 15, 2008 1:23 PM To: Jon McKamey; image-sig at python.org Subject: Re: [Image-SIG] PIL and target processors and OSX, oh-my! Jon McKamey wrote: > I'm trying to get PIL and mod_python to run on apache2 on a Mac running > OSX 10.5 To give some background, httpd is build with 4 target > processors, so everything loaded by it (mod_python, PIL, etc) has to be > built to handle all 4 target processors. Including all PIL and it's > libraries. I am to the point where PIL has been rebuilt for the 4 target > processors. If I run otool on it, I get the list of modules it loads, > and not all of them are built for the 4 processors, some of which appear > to be OS built-in libraries. > > So, the point I am stuck at: It's not clear to me how and what to do to > rebuild those modules, and it's not clear to me if it's even safe to > rebuild and replace those modules with 4 processor versions of the > files. I wouldn't. Also, I'm a bit confused. The Apple-supplied built-in ones should be dynamic libs, and I thought those only had to be built for the processor you are running on. Which libs are you having issues with? Anyway, I wouldn't replace ANY system libs. If the system ones won't work for you, you'll probably need to build your own versions of them, install them elsewhere, and make sure PIL links to those. > Macports? Last I heard MacPorts and Fink don't do any multi-processor building. Which leaves you with: > Download the source and go? The problem there is that many (most) libs don't build Universal out of the box, so you need o go in and hack the MakeFiles. I've only done dual mode builds (PPC and Intel, 32bit), but I imagine it's a similar deal. One trick is going to be if Configure sets anything about 32 vs. 64 bits, then you may run into issues. I think most of the endian issues have been addressed in the major libraries. I'd try this question on the pythonmac list -- it's really more a Mac issue than a PIL one. Good luck! -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 Thu May 15 20:19:19 2008 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Thu, 15 May 2008 11:19:19 -0700 Subject: [Image-SIG] PIL and target processors and OSX, oh-my! In-Reply-To: <45E36921B695A14FA56A34F29424A1EC012C75BA@Apollo.neatreceipts.local> References: <45E36921B695A14FA56A34F29424A1EC012C75BA@Apollo.neatreceipts.local> Message-ID: <482C7EA7.8060208@noaa.gov> Jon McKamey wrote: > After not getting a response, I sent this missive to the mod_python list > as well. They recommended 'thinning' the application, as is outlined in > the modwsgi tutorial for OSX. > > http://code.google.com/p/modwsgi/wiki/InstallationOnMacOSX > > That seems to work, and got things going. It also includes a good > explanation of exactly what the underlying problems was, in case my > question was not so clear. That's a well written page. thanks. It does clarify one point -- I don't' think you needed quad-architecture libs -- what you needed was 64-bit libs. It's a bit sad that apparently Apple didn't provide 64 bit versions of some of their libs, though it may be that you built a 32 bit PIL, so it was linked against 32bit libs. -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 johannes.stromberg at gmail.com Fri May 16 10:22:23 2008 From: johannes.stromberg at gmail.com (=?ISO-8859-1?Q?Johannes_Str=F6mberg?=) Date: Fri, 16 May 2008 10:22:23 +0200 Subject: [Image-SIG] Unsharp mask? Message-ID: Hello, Is there an unsharp mask filter in PIL (I can not find any) or can I create it by combining other filters (that would require Gaussian blur but I can not find that either)? /Johannes From kevin at cazabon.com Fri May 16 19:05:44 2008 From: kevin at cazabon.com (Kevin Cazabon) Date: Fri, 16 May 2008 19:05:44 +0200 Subject: [Image-SIG] Unsharp mask? In-Reply-To: References: Message-ID: I wrote a module for that, but you'll have to compile it for your distribution. Attached (sorry!). I've asked Fredrik to consider adding these functions to the core PIL code in the past, but for some reason he's never discussed it further... maybe there are IP issues, I don't know. Kevin. -------------- next part -------------- A non-text attachment was scrubbed... Name: PIL_usm.py Type: text/x-python-script Size: 2704 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: PILusm.cpp Type: application/octet-stream Size: 16858 bytes Desc: not available URL: -------------- next part -------------- On 16 May 2008, at 10:22, Johannes Str?mberg wrote: > Hello, > > Is there an unsharp mask filter in PIL (I can not find any) or can I > create it by combining other filters (that would require Gaussian blur > but I can not find that either)? > > /Johannes > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig From spe.stani.be at gmail.com Sat May 17 01:59:13 2008 From: spe.stani.be at gmail.com (Stani Michiels) Date: Sat, 17 May 2008 01:59:13 +0200 Subject: [Image-SIG] bold and italics of ttf fonts Message-ID: <1210982353.17995.4.camel@x30> Is it possible with PIL to use the bold and italics of a ttf font if there are no bold or italics fontfile present on the system. My application Phatch let the user choose from all installed font files from a drop down list. For example the font Purisa does not have ttf files for bold or italics but openoffice manages to create these fonts somehow? http://launchpadlibrarian.net/14091782/Screenshot-1.png Is there a solution for pil to modify ttf fonts to bold or italics? Or is this impossible? Stani http://photobatch.stani.be From ned at nedbatchelder.com Sat May 17 02:48:00 2008 From: ned at nedbatchelder.com (Ned Batchelder) Date: Fri, 16 May 2008 20:48:00 -0400 Subject: [Image-SIG] bold and italics of ttf fonts In-Reply-To: <1210982353.17995.4.camel@x30> References: <1210982353.17995.4.camel@x30> Message-ID: <482E2B40.1040109@nedbatchelder.com> I don't know how OpenOffice creates the other variants. Some programs (Firefox, for example) use double-striking to embolden a font, and skewing to create a false italic. The screenshot you show could be a skewed italic, but the bold is clearly not just double-struck. I would be interested to hear of other peoples' solutions to these problems. I've used skewing for italics, and it works well if you work over-sized and subsample down to get good antialiasing. --Ned. Stani Michiels wrote: > Is it possible with PIL to use the bold and italics of a ttf font if > there are no bold or italics fontfile present on the system. > My application Phatch let the user choose from all installed font files > from a drop down list. For example the font Purisa does not have ttf > files for bold or italics but openoffice manages to create these fonts > somehow? > http://launchpadlibrarian.net/14091782/Screenshot-1.png > > Is there a solution for pil to modify ttf fonts to bold or italics? Or > is this impossible? > > Stani > > http://photobatch.stani.be > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > > -- Ned Batchelder, http://nedbatchelder.com From johannes.stromberg at gmail.com Sat May 17 13:50:31 2008 From: johannes.stromberg at gmail.com (=?ISO-8859-1?Q?Johannes_Str=F6mberg?=) Date: Sat, 17 May 2008 13:50:31 +0200 Subject: [Image-SIG] Unsharp mask? In-Reply-To: References: Message-ID: Thanks, it looks like exactly what I need. Strange that it has not been added to the PIL core. IP issues? Now I have to figure out how to build the module on Windows. /Johannes On Fri, May 16, 2008 at 7:05 PM, Kevin Cazabon wrote: > I wrote a module for that, but you'll have to compile it for your > distribution. Attached (sorry!). > > I've asked Fredrik to consider adding these functions to the core PIL code > in the past, but for some reason he's never discussed it further... maybe > there are IP issues, I don't know. > > Kevin. > > > > On 16 May 2008, at 10:22, Johannes Str?mberg wrote: > >> Hello, >> >> Is there an unsharp mask filter in PIL (I can not find any) or can I >> create it by combining other filters (that would require Gaussian blur >> but I can not find that either)? >> >> /Johannes >> _______________________________________________ >> Image-SIG maillist - Image-SIG at python.org >> http://mail.python.org/mailman/listinfo/image-sig > > > From johannes.stromberg at gmail.com Sat May 17 14:35:55 2008 From: johannes.stromberg at gmail.com (=?ISO-8859-1?Q?Johannes_Str=F6mberg?=) Date: Sat, 17 May 2008 14:35:55 +0200 Subject: [Image-SIG] Unsharp mask? In-Reply-To: References: Message-ID: It was simple getting it to work using a simple setup.py script: from distutils.core import setup, Extension setup(name='PIL_usm', version='1.0', py_modules = ['PIL_usm'], ext_modules=[Extension('PILusm', ['PILusm.cpp'], include_dirs=['.\Imaging-1.1.6\libImaging'])], # where my PIL includes are ) /Johannes On Sat, May 17, 2008 at 1:50 PM, Johannes Str?mberg wrote: > Thanks, it looks like exactly what I need. > > Strange that it has not been added to the PIL core. IP issues? > > Now I have to figure out how to build the module on Windows. > > /Johannes > > On Fri, May 16, 2008 at 7:05 PM, Kevin Cazabon wrote: >> I wrote a module for that, but you'll have to compile it for your >> distribution. Attached (sorry!). >> >> I've asked Fredrik to consider adding these functions to the core PIL code >> in the past, but for some reason he's never discussed it further... maybe >> there are IP issues, I don't know. >> >> Kevin. >> >> >> >> On 16 May 2008, at 10:22, Johannes Str?mberg wrote: >> >>> Hello, >>> >>> Is there an unsharp mask filter in PIL (I can not find any) or can I >>> create it by combining other filters (that would require Gaussian blur >>> but I can not find that either)? >>> >>> /Johannes >>> _______________________________________________ >>> Image-SIG maillist - Image-SIG at python.org >>> http://mail.python.org/mailman/listinfo/image-sig >> >> >> > From JSpurny at seznam.cz Mon May 19 11:35:25 2008 From: JSpurny at seznam.cz (=?iso-8859-2?Q?Jan=20Spurn=FD?=) Date: Mon, 19 May 2008 11:35:25 +0200 (CEST) Subject: [Image-SIG] using PIL from different module Message-ID: <702.1229-32011-1687412756-1211189725@seznam.cz> Hi, I'm writing C module for python and there are few functions which are accepting PIL Images and they should return new PIL images. When I modify given PIL image, it's fine, but I would really like to return new Image and there's a problem - when returning a new PIL image, I need to create it and therefore use functions like ImagingNew. However this does not work - compilation of my module works just fine, but after importing module from python I get: ImportError: mymodule.so: undefined symbol: ImagingNew thanks for any suggestions Jan Spurny From frederic.mantegazza at gbiloba.org Mon May 19 12:21:36 2008 From: frederic.mantegazza at gbiloba.org (=?ISO-8859-1?Q?Fr=E9d=E9ric?=) Date: Mon, 19 May 2008 12:21:36 +0200 (CEST) Subject: [Image-SIG] using PIL from different module In-Reply-To: <702.1229-32011-1687412756-1211189725@seznam.cz> Message-ID: Le 19/5/2008, "Jan Spurn?" a ?crit: >I'm writing C module for python and there are few functions which are accepting PIL Images and they should return new PIL images. When I modify given PIL image, it's fine, but I would really like to return new Image and there's a problem - when returning a new PIL image, I need to create it and therefore use functions like ImagingNew. However this does not work - compilation of my module works just fine, but after importing module from python I get: > >ImportError: mymodule.so: undefined symbol: ImagingNew I don't have answer to your question, but a workarround is to create the image in the upper python module, and give the reference (I guess you have a pure python imported by the final user, and which uses the C module)... From sou2k at yahoo.com Thu May 22 17:32:05 2008 From: sou2k at yahoo.com (sounav maikap) Date: Thu, 22 May 2008 08:32:05 -0700 (PDT) Subject: [Image-SIG] NSImage to PIL Message-ID: <757692.77235.qm@web53911.mail.re2.yahoo.com> Can anybody throw light how to convert a NSImage object to PIL image object. Many thanks in advance. -Sounav From hyperspace at westnet.com.au Mon May 26 19:14:34 2008 From: hyperspace at westnet.com.au (Rodrigo) Date: Tue, 27 May 2008 01:14:34 +0800 Subject: [Image-SIG] PNG Pixels to Hex/Binary Message-ID: <4314C242CB044F298F67EBD4A44616F6@Hal> Hi all, I've been trying to convert a line of pixels in PNG format, into a binary file. So if the first pixel is #ffff12 it will write the first part of the filename.txt ffff12. if second pixel is #15dc3f it will write the next as 15dc3f. So if I do a hex edit of filename.txt it will show "ffff1215dc3f". Would appreciate your help in code for this. Thanks :D -------------- next part -------------- An HTML attachment was scrubbed... URL: From karsten.hiddemann at mathematik.uni-dortmund.de Mon May 26 23:54:24 2008 From: karsten.hiddemann at mathematik.uni-dortmund.de (Karsten Hiddemann) Date: Mon, 26 May 2008 23:54:24 +0200 Subject: [Image-SIG] PNG Pixels to Hex/Binary In-Reply-To: <4314C242CB044F298F67EBD4A44616F6@Hal> References: <4314C242CB044F298F67EBD4A44616F6@Hal> Message-ID: <483B3190.8070908@mathematik.uni-dortmund.de> Rodrigo schrieb: > I?ve been trying to convert a line of pixels in PNG format, into a > binary file. So if the first pixel is #ffff12 it will write the first > part of the filename.txt ffff12. if second pixel is #15dc3f it will > write the next as 15dc3f. So if I do a hex edit of filename.txt it will > show ?ffff1215dc3f?. Would appreciate your help in code for this. from PIL import Image import sys if __name__=="__main__": im = Image.open("image.png") for p in im.getdata(): sys.stdout.write("%02x%02x%02x" % p) From karsten.hiddemann at mathematik.uni-dortmund.de Tue May 27 01:50:54 2008 From: karsten.hiddemann at mathematik.uni-dortmund.de (Karsten Hiddemann) Date: Tue, 27 May 2008 01:50:54 +0200 Subject: [Image-SIG] PNG Pixels to Hex/Binary In-Reply-To: <2F417FA99D1540B486EC1292995E2E8D@Hal> References: <4314C242CB044F298F67EBD4A44616F6@Hal> <483B3190.8070908@mathematik.uni-dortmund.de> <2F417FA99D1540B486EC1292995E2E8D@Hal> Message-ID: <483B4CDE.6050502@mathematik.uni-dortmund.de> Rodrigo schrieb: > I ended up editing it to this... however I have the hex code showing in > text, Basically it should be a binary file in the end, not a text file - > apologies for the confusion. Perhaps the original that you wrote Karsten > did that, however it was outputting to the screen and not a file. No, that's exactly what I intended it to do since you wrote something about text files and HTML color codes. Seems what you really want is: from PIL import Image if __name__=="__main__": im = Image.open("image.png") out = file('image.raw', 'w') out.write(im.tostring()) From karsten.hiddemann at mathematik.uni-dortmund.de Tue May 27 11:57:06 2008 From: karsten.hiddemann at mathematik.uni-dortmund.de (Karsten Hiddemann) Date: Tue, 27 May 2008 11:57:06 +0200 Subject: [Image-SIG] NSImage to PIL In-Reply-To: <757692.77235.qm@web53911.mail.re2.yahoo.com> References: <757692.77235.qm@web53911.mail.re2.yahoo.com> Message-ID: <483BDAF2.1090002@mathematik.uni-dortmund.de> sounav maikap schrieb: > Can anybody throw light how to convert a NSImage object to PIL image object. I really have no idea about Cocoa code, but looking at http://theocacao.com/document.page/350 it seems like you can create a TIFFRepresentation / imageRepWithData of your image and then feed that into PIL via Image.fromstring(). Regards, Karsten From jwienke at techfak.uni-bielefeld.de Sat May 31 15:17:44 2008 From: jwienke at techfak.uni-bielefeld.de (Johannes Wienke) Date: Sat, 31 May 2008 15:17:44 +0200 Subject: [Image-SIG] Extending PIL for YUV support. Message-ID: <48414FF8.2070207@techfak.uni-bielefeld.de> Hi, for my application I need to provide images in YUV format. Is there a simple way to extend the functionality of PIL to YUV images? Converting to YUV using a conversion matrix is not the problem, but then the mode is wrong and so on. Thanks Johannes -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 260 bytes Desc: OpenPGP digital signature URL: