From fredrik at pythonware.com Mon May 3 21:03:40 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 3 May 2010 21:03:40 +0200 Subject: [Image-SIG] Image perspective with PIL In-Reply-To: References: Message-ID: I've added the documentation from the original patch to this page: http://effbot.org/tag/pil.Image.Image.transform The next text is attached below. im.transform(size, PERSPECTIVE, data) im.transform(size, PERSPECTIVE, data, filter) Applies a perspective transform to the image, and places the result in a new image with the given size. Data is a 8-tuple (a, b, c, d, e, f, g, h) which contains the coefficients for a perspective transform. For each pixel (x, y) in the output image, the new value is taken from a position (a x + b y + c)/(g x + h y + 1), (d x + e y + f)/(g x + h y + 1) in the input image, rounded to nearest pixel. This function can be used to change the 2D perspective of the original image. On Wed, Apr 28, 2010 at 11:59 PM, PyProg PyProg wrote: > Hello, > > I would like to apply an image perspective. > > The syntax of PIL in this regard seems to be: > > im.transform (self, size, PERSPECTIVE, data = None, resample = 0, fill = 1) > > I want to know exactly what to include in data. > > Can you give me an example ?. > > Thank you in advance. > > a + > > -- > http://ekd.tuxfamily.org > http://ekdm.wordpress.com > http://lprod.org/wiki/doku.php/video:encodage:avchd_converter > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From francisboon at googlemail.com Tue May 4 22:16:41 2010 From: francisboon at googlemail.com (Fran Boon) Date: Tue, 4 May 2010 13:16:41 -0700 Subject: [Image-SIG] PIL 1.1.7 bug with Windows 7 64-bit: _imagingft.pyd side-by-side Message-ID: I had to downgrade PIL to 1.1.6 on my 64-bit Windows 7 system with Python-2.6 due to this error. This module wouldn't load due to a side-by-side error (http://blogs.msdn.com/junfeng/archive/2006/04/14/576314.aspx) sxstrace output below, but it doesn't seem helpful to me... Best Wishes, Fran. ================= Begin Activation Context Generation. Input Parameter: Flags = 0 ProcessorArchitecture = Wow32 CultureFallBacks = en-US;en ManifestPath = C:\Bin\Python26\lib\site-packages\PIL\_imagingft.pyd AssemblyDirectory = C:\Bin\Python26\lib\site-packages\PIL\ Application Config File = ----------------- INFO: Parsing Manifest File C:\Bin\Python26\lib\site-packages\PIL\_imagingft.pyd. INFO: Manifest Definition Identity is (null). INFO: Reference: Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8" INFO: Reference: Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8" INFO: Resolving reference Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8". INFO: Resolving reference for ProcessorArchitecture WOW64. INFO: Resolving reference for culture Neutral. INFO: Applying Binding Policy. INFO: No publisher policy found. INFO: No binding policy redirect found. INFO: Begin assembly probing. INFO: Did not find the assembly in WinSxS. INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_32\Microsoft.VC90.CRT\9.0.21022.8__1fc8b3b9a1e18e3b\Microsoft.VC90.CRT.DLL. INFO: Did not find manifest for culture Neutral. INFO: End assembly probing. INFO: Resolving reference for ProcessorArchitecture x86. INFO: Resolving reference for culture Neutral. INFO: Applying Binding Policy. INFO: Find publisher policy at C:\Windows\WinSxS\manifests\x86_policy.9.0.microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4926_none_f47c47b2f658b4a8.manifest INFO: Publisher Policy redirected assembly version. INFO: Post policy assembly identity is Microsoft.VC90.CRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.30729.4926". INFO: Begin assembly probing. INFO: Attempt to probe manifest at C:\Windows\WinSxS\manifests\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4926_none_508ed732bcbc0e5a.manifest. INFO: Manifest found at C:\Windows\WinSxS\manifests\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4926_none_508ed732bcbc0e5a.manifest. INFO: End assembly probing. INFO: Resolving reference Microsoft.VC90.CRT.mui,language="*",processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.30729.4926". INFO: Resolving reference for ProcessorArchitecture WOW64. INFO: Resolving reference for culture en-US. INFO: Applying Binding Policy. INFO: No publisher policy found. INFO: No binding policy redirect found. INFO: Begin assembly probing. INFO: Did not find the assembly in WinSxS. INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_32\Microsoft.VC90.CRT.mui\9.0.30729.4926_en-US_1fc8b3b9a1e18e3b\Microsoft.VC90.CRT.mui.DLL. INFO: Did not find manifest for culture en-US. INFO: End assembly probing. INFO: Resolving reference for culture en. INFO: Applying Binding Policy. INFO: No publisher policy found. INFO: No binding policy redirect found. INFO: Begin assembly probing. INFO: Did not find the assembly in WinSxS. INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_32\Microsoft.VC90.CRT.mui\9.0.30729.4926_en_1fc8b3b9a1e18e3b\Microsoft.VC90.CRT.mui.DLL. INFO: Did not find manifest for culture en. INFO: End assembly probing. INFO: Resolving reference for ProcessorArchitecture x86. INFO: Resolving reference for culture en-US. INFO: Applying Binding Policy. INFO: No publisher policy found. INFO: No binding policy redirect found. INFO: Begin assembly probing. INFO: Did not find the assembly in WinSxS. INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_32\Microsoft.VC90.CRT.mui\9.0.30729.4926_en-US_1fc8b3b9a1e18e3b\Microsoft.VC90.CRT.mui.DLL. INFO: Did not find manifest for culture en-US. INFO: End assembly probing. INFO: Resolving reference for culture en. INFO: Applying Binding Policy. INFO: No publisher policy found. INFO: No binding policy redirect found. INFO: Begin assembly probing. INFO: Did not find the assembly in WinSxS. INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_32\Microsoft.VC90.CRT.mui\9.0.30729.4926_en_1fc8b3b9a1e18e3b\Microsoft.VC90.CRT.mui.DLL. INFO: Did not find manifest for culture en. INFO: End assembly probing. INFO: Resolving reference Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8". INFO: Resolving reference for ProcessorArchitecture WOW64. INFO: Resolving reference for culture Neutral. INFO: Applying Binding Policy. INFO: No publisher policy found. INFO: No binding policy redirect found. INFO: Begin assembly probing. INFO: Did not find the assembly in WinSxS. INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_32\Microsoft.VC90.DebugCRT\9.0.21022.8__1fc8b3b9a1e18e3b\Microsoft.VC90.DebugCRT.DLL. INFO: Did not find manifest for culture Neutral. INFO: End assembly probing. INFO: Resolving reference for ProcessorArchitecture x86. INFO: Resolving reference for culture Neutral. INFO: Applying Binding Policy. INFO: No publisher policy found. INFO: No binding policy redirect found. INFO: Begin assembly probing. INFO: Did not find the assembly in WinSxS. INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_32\Microsoft.VC90.DebugCRT\9.0.21022.8__1fc8b3b9a1e18e3b\Microsoft.VC90.DebugCRT.DLL. INFO: Attempt to probe manifest at C:\Bin\Python26\lib\site-packages\PIL\Microsoft.VC90.DebugCRT.DLL. INFO: Attempt to probe manifest at C:\Bin\Python26\lib\site-packages\PIL\Microsoft.VC90.DebugCRT.MANIFEST. INFO: Attempt to probe manifest at C:\Bin\Python26\lib\site-packages\PIL\Microsoft.VC90.DebugCRT\Microsoft.VC90.DebugCRT.DLL. INFO: Attempt to probe manifest at C:\Bin\Python26\lib\site-packages\PIL\Microsoft.VC90.DebugCRT\Microsoft.VC90.DebugCRT.MANIFEST. INFO: Did not find manifest for culture Neutral. INFO: End assembly probing. ERROR: Cannot resolve reference Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8". ERROR: Activation Context generation failed. End Activation Context Generation. From cannon.el at gmail.com Wed May 5 06:12:43 2010 From: cannon.el at gmail.com (Laura & Edward Cannon) Date: Tue, 4 May 2010 21:12:43 -0700 Subject: [Image-SIG] weird windows 7 error with ImageFont Message-ID: I am running python 2.6.4 (32 bit) on windows 7 Home Premium (64 bit). I installed PIL 1.1.7 a few months ago from the official installer. I sat down today and tried to load a font using the ImageFont.truetype function. I get the following error. ImportError: The _imagingft C module is not installed I have had no other errors, and have used the other modules extensively with this install. Any ideas as to what the problem might be? Thanks Edward From olt at bogosoft.com Wed May 5 11:00:52 2010 From: olt at bogosoft.com (Oliver Tonnhofer) Date: Wed, 5 May 2010 11:00:52 +0200 Subject: [Image-SIG] weird windows 7 error with ImageFont In-Reply-To: References: Message-ID: <0AA7CF02-F7D2-4BC1-BA6E-9E4B38711021@bogosoft.com> On 05.05.2010, at 06:12, Laura & Edward Cannon wrote: > I am running python 2.6.4 (32 bit) on windows 7 Home Premium (64 bit). > I installed PIL 1.1.7 a few months ago from the official installer. I > sat down today and tried to load a font using the ImageFont.truetype > function. I get the following error. > ImportError: The _imagingft C module is not installed > I have had no other errors, and have used the other modules > extensively with this install. Any ideas as to what the problem might > be? The Windows binaries for 1.1.7 where not compiled with FreeType support. You need to downgrade to 1.1.6 or build you own packages. Regards, Oliver From fredrik at pythonware.com Wed May 5 13:48:48 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 5 May 2010 13:48:48 +0200 Subject: [Image-SIG] weird windows 7 error with ImageFont In-Reply-To: <0AA7CF02-F7D2-4BC1-BA6E-9E4B38711021@bogosoft.com> References: <0AA7CF02-F7D2-4BC1-BA6E-9E4B38711021@bogosoft.com> Message-ID: What binaries are we talking about? I'm pretty sure the effbot.org binaries have _imagingft in them, at least: $ unzip -v PIL-1.1.7.win32-py2.6.exe ... 324608 Defl:N 170249 48% 11-02-09 13:42 5462e136 PLATLIB/PIL/_imaging.pyd 101376 Defl:N 51319 49% 11-02-09 13:42 cdd53308 PLATLIB/PIL/_imagingcms.pyd 396288 Defl:N 225835 43% 11-02-09 13:42 bab256eb PLATLIB/PIL/_imagingft.pyd 15872 Defl:N 6022 62% 11-02-09 13:42 e9836738 PLATLIB/PIL/_imagingmath.pyd 8704 Defl:N 4165 52% 11-02-09 13:42 899b8d80 PLATLIB/PIL/_imagingtk.pyd ... (I think there's a sanity test for this in the upload tools, but I'm not 100% sure about that) No Windows box within reach right now, so I cannot check if there's some other problem with the ft module On Wed, May 5, 2010 at 11:00 AM, Oliver Tonnhofer wrote: > > On 05.05.2010, at 06:12, Laura & Edward Cannon wrote: > >> I am running python 2.6.4 (32 bit) on windows 7 Home Premium (64 bit). >> I installed PIL 1.1.7 a few months ago from the official installer. I >> sat down today and tried to load a font using the ImageFont.truetype >> function. I get the following error. >> ImportError: The _imagingft C module is not installed >> I have had no other errors, and have used the other modules >> extensively with this install. Any ideas as to what the problem might >> be? > > The Windows binaries for 1.1.7 where not compiled with FreeType support. You > need to downgrade to 1.1.6 or build you own packages. > > Regards, > Oliver > > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From francisboon at googlemail.com Wed May 5 15:57:32 2010 From: francisboon at googlemail.com (Fran Boon) Date: Wed, 5 May 2010 06:57:32 -0700 Subject: [Image-SIG] weird windows 7 error with ImageFont In-Reply-To: References: <0AA7CF02-F7D2-4BC1-BA6E-9E4B38711021@bogosoft.com> Message-ID: On 5 May 2010 04:48, Fredrik Lundh wrote: > What binaries are we talking about? ?I'm pretty sure the effbot.org > binaries have _imagingft in them, at least: The file is there, but won't import on my Windows 7 64-bit Python-2.6 machine. The Application log shows a Side-by-Side error: http://blogs.msdn.com/junfeng/archive/2006/04/14/576314.aspx sxstrace output can be provided, but it doesn't seem helpful to me... Downgrading to 1.1.6 worked for me. Best Wishes, Fran. From cannon.el at gmail.com Wed May 5 17:00:59 2010 From: cannon.el at gmail.com (Laura & Edward Cannon) Date: Wed, 5 May 2010 08:00:59 -0700 Subject: [Image-SIG] weird windows 7 error with ImageFont In-Reply-To: References: <0AA7CF02-F7D2-4BC1-BA6E-9E4B38711021@bogosoft.com> Message-ID: running the selftest.py I find the following output: -------------------------------------------------------------------- PIL 1.1.7 TEST SUMMARY -------------------------------------------------------------------- Python modules loaded from C:\Python26\lib\site-packages\PIL Binary modules loaded from C:\Python26\lib\site-packages\PIL -------------------------------------------------------------------- --- PIL CORE support ok --- TKINTER support ok --- JPEG support ok --- ZLIB (PNG/ZIP) support ok *** FREETYPE2 support not installed --- LITTLECMS support ok -------------------------------------------------------------------- Running selftest: --- 57 tests passed. I tried installing freetype2 from the GnuWin people (http://gnuwin32.sourceforge.net/packages/freetype.htm) but that didn't seem to help, even with a reinstall of PIL. Do I need to try to recompile PIL or do something else? sxstrace output doesn't seem helpful to me either, unfortunately most of my C experience is on other OS's, but I'm willing to play around. Edward On Wed, May 5, 2010 at 6:57 AM, Fran Boon wrote: > On 5 May 2010 04:48, Fredrik Lundh wrote: >> What binaries are we talking about? ?I'm pretty sure the effbot.org >> binaries have _imagingft in them, at least: > > The file is there, but won't import on my Windows 7 64-bit Python-2.6 machine. > The Application log shows a Side-by-Side error: > http://blogs.msdn.com/junfeng/archive/2006/04/14/576314.aspx > > sxstrace output can be provided, but it doesn't seem helpful to me... > > Downgrading to 1.1.6 worked for me. > > Best Wishes, > Fran. > From paul at paulross.demon.co.uk Wed May 5 22:42:23 2010 From: paul at paulross.demon.co.uk (Paul Ross) Date: Wed, 5 May 2010 21:42:23 +0100 Subject: [Image-SIG] Mac support for PIL Message-ID: Hi there and I'm sorry to bother you but... I know that PIL is Windows-centric but is there any chance that it will support Snow Leopard on Apple Mac some time soon? I have been trying to build PIL from source on Snow Leopard without success as it appears to only support PNG and not other image formats such as JPEG. I have googled for the answer for a couple of hours now and tried many ad-hoc things (deleting PIL, installing libjpeg etc. etc.) but I always just get "IOError: decoder jpeg not available" whenever I try and manipulate JPEG images Many thanks if you can help me hack PIL to build on a Mac! Paul. From yury at shurup.com Fri May 7 17:05:02 2010 From: yury at shurup.com (Yury V. Zaytsev) Date: Fri, 07 May 2010 17:05:02 +0200 Subject: [Image-SIG] Mac support for PIL In-Reply-To: References: Message-ID: <1273244702.7594.94.camel@mypride> Hi! On Wed, 2010-05-05 at 21:42 +0100, Paul Ross wrote: > > I know that PIL is Windows-centric but is there any chance that it will > support Snow Leopard on Apple Mac some time soon? Windows-centric?! > I have googled for the answer for a couple of hours now and tried many > ad-hoc things (deleting PIL, installing libjpeg etc. etc.) but I > always just get "IOError: decoder jpeg not available" whenever I try > and manipulate JPEG images Basically you have to build and install libjpeg and other decoders from source or use a package management system, such as Fink or Macports, then rebuild PIL against them. If you want more help, ask specific questions. -- Sincerely yours, Yury V. Zaytsev From fredrik at pythonware.com Fri May 7 17:09:24 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 7 May 2010 17:09:24 +0200 Subject: [Image-SIG] Mac support for PIL In-Reply-To: References: Message-ID: Do you have the necessary support libraries on your machine? (see the README file). There are prebuilt versions out there too; maybe some Mac hackers can chime in and point you to the latest and greatest. On Wed, May 5, 2010 at 10:42 PM, Paul Ross wrote: > Hi there and I'm sorry to bother you but... > > I know that PIL is Windows-centric but is there any chance that it will support Snow Leopard on Apple Mac some time soon? > > I have been trying to build PIL from source on Snow Leopard without success as it appears to only support PNG and not other image formats such as JPEG. > > I have googled for the answer for a couple of hours now and tried many ad-hoc things (deleting PIL, installing libjpeg etc. etc.) but I always just get "IOError: decoder jpeg not available" whenever I try and manipulate JPEG images > > Many thanks if you can help me hack PIL to build on a Mac! > > Paul. > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From janssen at parc.com Fri May 7 18:19:27 2010 From: janssen at parc.com (Bill Janssen) Date: Fri, 7 May 2010 09:19:27 PDT Subject: [Image-SIG] Mac support for PIL In-Reply-To: References: Message-ID: <42230.1273249167@parc.com> Paul Ross wrote: > Hi there and I'm sorry to bother you but... > > I know that PIL is Windows-centric but is there any chance that it will support Snow Leopard on Apple Mac some time soon? > > I have been trying to build PIL from source on Snow Leopard without success as it appears to only support PNG and not other image formats such as JPEG. Works for me. I build libjpeg, libpng, libfreetype, etc. from source first, and install them, then build PIL. Haven't tried it with 10.6.3, though. You have to edit the PIL setup.py file, and put the paths to the library directories in it, though, before building PIL. Bill From Chris.Barker at noaa.gov Fri May 7 18:50:26 2010 From: Chris.Barker at noaa.gov (Chris Barker) Date: Fri, 07 May 2010 09:50:26 -0700 Subject: [Image-SIG] Mac support for PIL In-Reply-To: References: Message-ID: <4BE444D2.1030703@noaa.gov> Fredrik Lundh wrote: > Do you have the necessary support libraries on your machine? (see the > README file). > > There are prebuilt versions out there too; maybe some Mac hackers can > chime in and point you to the latest and greatest. I'd ask on the pyhthonmac SIG list. Maybe someone there has or will produce a binary ( I have NO time for it right now! ) If you do want to do it yourself, the easiest way to get the libs is macports. Bill Janssen wrote: > Works for me. I build libjpeg, libpng, libfreetype, etc. from source > first, and install them, then build PIL. Haven't tried it with 10.6.3, > though. Bill, any chance you could put together a binary installer -- it would be a nice service to the community. -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 adrian.prw at gmail.com Fri May 7 18:35:01 2010 From: adrian.prw at gmail.com (Adrian Price-Whelan) Date: Fri, 7 May 2010 12:35:01 -0400 Subject: [Image-SIG] Mac support for PIL In-Reply-To: <42230.1273249167@parc.com> References: <42230.1273249167@parc.com> Message-ID: <722070BC-9C8D-4EE4-8D14-ADE783D32983@gmail.com> I'm using Snow Leopard version 10.6.3 - I didn't have to do any hacks to get it working once I had the necessary dependancies installed. -- Adrian Price-Whelan http://cosmo.nyu.edu/~apw235 On May 7, 2010, at 12:19 PM, Bill Janssen wrote: > Paul Ross wrote: > >> Hi there and I'm sorry to bother you but... >> >> I know that PIL is Windows-centric but is there any chance that it will support Snow Leopard on Apple Mac some time soon? >> >> I have been trying to build PIL from source on Snow Leopard without success as it appears to only support PNG and not other image formats such as JPEG. > > Works for me. I build libjpeg, libpng, libfreetype, etc. from source > first, and install them, then build PIL. Haven't tried it with 10.6.3, > though. > > You have to edit the PIL setup.py file, and put the paths to the library > directories in it, though, before building PIL. > > Bill > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig From songuke at gmail.com Sat May 8 05:58:03 2010 From: songuke at gmail.com (Son Hua) Date: Sat, 08 May 2010 11:58:03 +0800 Subject: [Image-SIG] Image warping in Python or PIL Message-ID: <4BE4E14B.1070903@gmail.com> Hi, Can anybody show me some hints on how to implement an image warping function efficiently in Python or PIL? Suppose we have a function f(x, y) -> (x', y') that warps a pixel location (x, y) to (x', y'). Because (x', y') may end up to be non-integer, and many (x, y) can map to the same (x', y'), reverse mapping is used. That is at every destination pixel (x', y'), we go and find the original pixel location (x, y) by taking (x, y) = f_1(x', y'), where f_1 is the inverse function of f. Suppose the inverse function f_1 is given. So, for each pixel in the destination image, we can map to a non-integer pixel in the source image. Therefore, we must bilinear interpolate at the source location for the color. I know that doing this pixel per pixel in Python is very slow. For example: for i in xrange(height): for j in xrange(width): (x, y) = f_1(j, i) # 1. Check if (x, y) is inside the source image. If out of boundary, skip. # 2. Bilinear sampling at (x, y) at the source image to obtain color C # 3. Paste the color C into (i, j) location in the destination image. # next... I'm doing this warping as the final stage of an image mosaicking program. The size of the image is quite big, about 8000x2000. So, any ideas about how to make it fast, except implementing the whole thing in C? As I also used the dictionary data structure available in Python, so integrating C here may be painful. Thank you in advance. Best regards, SH. From fredrik at pythonware.com Sat May 8 13:49:14 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 8 May 2010 13:49:14 +0200 Subject: [Image-SIG] Image warping in Python or PIL In-Reply-To: <4BE4E14B.1070903@gmail.com> References: <4BE4E14B.1070903@gmail.com> Message-ID: On Sat, May 8, 2010 at 5:58 AM, Son Hua wrote: > Hi, > > Can anybody show me some hints on how to implement an image warping function > efficiently in Python or PIL? Suppose we have a function f(x, y) -> (x', y') > that warps a pixel location (x, y) to (x', y'). Because (x', y') may end up > to be non-integer, and many (x, y) can map to the same (x', y'), reverse > mapping is used. That is at every destination pixel (x', y'), we go and find > the original pixel location (x, y) by taking (x, y) = f_1(x', y'), where f_1 > is the inverse function of f. > > Suppose the inverse function f_1 is given. So, for each pixel in the > destination image, we can map to a non-integer pixel in the source image. > Therefore, we must bilinear interpolate at the source location for the > color. The transform(MESH) operation might be what you need. http://effbot.org/tag/PIL.Image.Image.transform Instead of mapping between individual pixels, cover the output image with a grid, and calculate the source pixels for the corners of each grid rectangle (forming a quadrilateral area). Pass in the resulting list of (grid rectangle, quadrilateral) pairs to transform(MESH), and it'll take care of the rest. (you can use a generator to produce mesh pairs on the fly) The result is (usually) an approximation, with the maximum error controlled by the grid resolution. From olt at bogosoft.com Sat May 8 14:38:17 2010 From: olt at bogosoft.com (Oliver Tonnhofer) Date: Sat, 8 May 2010 14:38:17 +0200 Subject: [Image-SIG] Image warping in Python or PIL In-Reply-To: References: <4BE4E14B.1070903@gmail.com> Message-ID: On 08.05.2010, at 13:49, Fredrik Lundh wrote: > The transform(MESH) operation might be what you need. > > http://effbot.org/tag/PIL.Image.Image.transform > > Instead of mapping between individual pixels, cover the output image > with a grid, and calculate the source pixels for the corners of each > grid rectangle (forming a quadrilateral area). Pass in the resulting > list of (grid rectangle, quadrilateral) pairs to transform(MESH), and > it'll take care of the rest. That's what I used to transform maps/aerial images from one coordinate system to another. http://bitbucket.org/olt/mapproxy/src/142/mapproxy/core/image.py#cl-553 > The result is (usually) an approximation, with the maximum error > controlled by the grid resolution. I did tests with 1500x1500px and there where no improvements beyond 8x8. The performance is really great. Even faster than GDAL which is a C library for exactly this kind of image processing. Regards, Oliver From paul at paulross.demon.co.uk Sat May 8 21:04:31 2010 From: paul at paulross.demon.co.uk (Paul Ross) Date: Sat, 8 May 2010 20:04:31 +0100 Subject: [Image-SIG] Mac support for PIL In-Reply-To: <1273244702.7594.94.camel@mypride> References: <1273244702.7594.94.camel@mypride> Message-ID: Thanks, and sorry, what I meant to say is that PIP is really easy to install on windows but a bit of a trial on Mac. There are loads of blog entries around, which perhaps reflects the trouble that people are having. Many of these entries are highly version specific and have a less than unity probability of success (I tried three before I managed to get things working). Judging by the comment on most blogs other people are in the same boat as I. FWIW this is what eventually worked for me: Based on: http://rezmuh.sixceedinc.com/2009/04/setting-up-pil-with-libjpeg-on-mac-os-x-leopard.html I got and installed MacPorts-1.8.2-10.6-SnowLeopard.dmg from: http://distfiles.macports.org/MacPorts/ Then in Imaging-1.1.7: In setup.py changed the JPEG_ROOT to: JPEG_ROOT = "/opt/local/lib/libjpeg.dylib" Then: sudo python setup.py build --force sudo python setup.py install I would not guarantee this will work for others! Thanks for the help and thanks for such a great product as PIL Regards, Paul. FWIW I s On 7 May 2010, at 16:05, Yury V. Zaytsev wrote: > Hi! > > On Wed, 2010-05-05 at 21:42 +0100, Paul Ross wrote: >> >> I know that PIL is Windows-centric but is there any chance that it will >> support Snow Leopard on Apple Mac some time soon? > > Windows-centric?! > >> I have googled for the answer for a couple of hours now and tried many >> ad-hoc things (deleting PIL, installing libjpeg etc. etc.) but I >> always just get "IOError: decoder jpeg not available" whenever I try >> and manipulate JPEG images > > Basically you have to build and install libjpeg and other decoders from > source or use a package management system, such as Fink or Macports, > then rebuild PIL against them. > > If you want more help, ask specific questions. > > -- > Sincerely yours, > Yury V. Zaytsev > From janssen at parc.com Sat May 8 23:48:50 2010 From: janssen at parc.com (Bill Janssen) Date: Sat, 8 May 2010 14:48:50 PDT Subject: [Image-SIG] Mac support for PIL In-Reply-To: References: <1273244702.7594.94.camel@mypride> Message-ID: <49414.1273355330@parc.com> Here's the fragment of my csh script which builds PIL. I unpack PIL, libpng, libjpeg, libfreetype, and libtiff in a directory, then build them with this. Note that the key in building PIL is to replace the reference to "/sw" with the pointer to where you want to install it, in this example "/usr/local". You may need to run this as sudo, depending on what else you've done to your Python installation -- this one's keyed to the standard /usr/bin/python. Bill ================================================================================ setenv distdir /usr/local cd libpng-* ./configure --prefix=${distdir} make make install cd ../jpeg* ./configure --prefix=${distdir} make make install make install-lib make install-headers ranlib ${distdir}/lib/libjpeg.a setenv CPPFLAGS "-I${distdir}/include" setenv LDFLAGS "-L${distdir}/lib" setenv CXXFLAGS "-I${distdir}/include" cd ../tiff-* ./configure --prefix=${distdir} --without-x make make install cd ../freetype-2.* # first, get rid of erroneous mac flag cp include/freetype/config/ftconfig.h /tmp/build-mac-uplib-tmp-$$ rm -f include/freetype/config/ftconfig.h sed -e 's/#define FT_MACINTOSH 1/#undef FT_MACINTOSH/' < /tmp/build-mac-uplib-tmp-$$ > include/freetype/config/ftconfig.h # next, enable the bytecode interpreter rm -f /tmp/build-mac-uplib-tmp-$$ cp include/freetype/config/ftoption.h /tmp/build-mac-uplib-tmp-$$ rm -f include/freetype/config/ftoption.h sed -e 's;/\* #define TT_CONFIG_OPTION_BYTECODE_INTERPRETER \*/;#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER;' < /tmp/build-mac-uplib-tmp-$$ > include/freetype/config/ftoption.h # now build ./configure --prefix=${distdir} make make install cp ${distdir}/include/ft2build.h ${distdir}/include/freetype2/ cd ../Imaging-1.1.* rm -f /tmp/build-mac-uplib-tmp-$$ cp setup.py /tmp/build-mac-uplib-tmp-$$ sed -e "s;/sw;${distdir};" < /tmp/build-mac-uplib-tmp-$$ > setup.py /usr/bin/python setup.py build /usr/bin/python setup.py install ================================================================================ From erwin94 at gmx.net Sun May 9 03:47:20 2010 From: erwin94 at gmx.net (David) Date: Sun, 9 May 2010 03:47:20 +0200 Subject: [Image-SIG] PIL bug: Antialias.c bicubic filter error Message-ID: <03B44E09-0554-4A98-A86A-3ED63DC85E96@gmx.net> Hi, this is not that important because a is zero at the moment, but this line in the bicubic_filter return (((a * x) - 5*a) * x + 8) * x - 4*a; should be return (((a * x) - 5*a) * x + 8*a) * x - 4*a; hope this helps, David. From contact at xavierho.com Sun May 9 04:03:48 2010 From: contact at xavierho.com (Xavier Ho) Date: Sun, 9 May 2010 12:03:48 +1000 Subject: [Image-SIG] PIL bug: Antialias.c bicubic filter error In-Reply-To: <03B44E09-0554-4A98-A86A-3ED63DC85E96@gmx.net> References: <03B44E09-0554-4A98-A86A-3ED63DC85E96@gmx.net> Message-ID: On Sun, May 9, 2010 at 11:47 AM, David wrote: > return (((a * x) - 5*a) * x + 8*a) * x - 4*a; > Hello David, I just factored out from your patch, as a comment to your post. ((x - 5) * x + 8) * a * x - 4*a; Cheers, Xav -------------- next part -------------- An HTML attachment was scrubbed... URL: From yon.thierbach at googlemail.com Thu May 13 15:58:33 2010 From: yon.thierbach at googlemail.com (Yon Thierbach) Date: Thu, 13 May 2010 15:58:33 +0200 Subject: [Image-SIG] How to install PIL Message-ID: <3F5B2D2D-5134-4C62-A681-A5F0903EB2F3@googlemail.com> Hi, I just switch from windows to a MAC OS 10.6 snow leopard. I was looking for a app to be able to use my corel draw files and I found inkskape. When I try to import .cdr files I?m asked to install python converter. I found your page downloaded something and installed something but I?m not sure how to do it correctly. I know you probably are smiling right now but could you please send me a detailed how to to get this done? I really would appreciate it! Thanks a lot Regards Yon From chollapete at gmail.com Thu May 13 17:57:07 2010 From: chollapete at gmail.com (Mark Twenhafel) Date: Thu, 13 May 2010 08:57:07 -0700 Subject: [Image-SIG] Does libjpeg-8a work in PIL? Message-ID: Hi- I saw the recent "Mac Support for PIL" thread in the archives. Interestingly, I had the same problem a few months ago, when I last tried to build this functionality. Just a quick question for now: does jpeg-8a work as a drop-in replacement for jpeg-6a or -6b, in terms of not breaking PIL-1.1.7? The README file that came with PIL-1.1.7 specifically states libjpeg (6a or 6b) as a dependency. However, at the www.ijg.org site, only jpegsrc.v8a.tar.gz seems to be available in the /files directory. Thanks, Mark -------------- next part -------------- An HTML attachment was scrubbed... URL: From spe.stani.be at gmail.com Thu May 13 18:57:53 2010 From: spe.stani.be at gmail.com (Stani) Date: Thu, 13 May 2010 18:57:53 +0200 Subject: [Image-SIG] weird windows 7 error with ImageFont In-Reply-To: <0AA7CF02-F7D2-4BC1-BA6E-9E4B38711021@bogosoft.com> References: <0AA7CF02-F7D2-4BC1-BA6E-9E4B38711021@bogosoft.com> Message-ID: On Wed, May 5, 2010 at 11:00 AM, Oliver Tonnhofer wrote: > > On 05.05.2010, at 06:12, Laura & Edward Cannon wrote: > >> I am running python 2.6.4 (32 bit) on windows 7 Home Premium (64 bit). >> I installed PIL 1.1.7 a few months ago from the official installer. I >> sat down today and tried to load a font using the ImageFont.truetype >> function. I get the following error. >> ImportError: The _imagingft C module is not installed >> I have had no other errors, and have used the other modules >> extensively with this install. Any ideas as to what the problem might >> be? > > The Windows binaries for 1.1.7 where not compiled with FreeType support. You > need to downgrade to 1.1.6 or build you own packages. The problem is only with the PIL 1.1.7-py26 installer. It works fine with the PIL-1.1.7-py25 installer. -- Phatch Photo Batch Processor - http://photobatch.stani.be SPE Python IDE - http://pythonide.stani.be From fredrik at pythonware.com Thu May 13 19:07:52 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 13 May 2010 19:07:52 +0200 Subject: [Image-SIG] Does libjpeg-8a work in PIL? In-Reply-To: References: Message-ID: I haven't tested it specifically, but from a quick look at the release notes, they don't seem to have changed any API:s, so it should work. In case you need the original, a copy of it seems to be available from here: http://code.google.com/p/quirkysoft/downloads/detail?name=jpegsrc.v6b.tar.gz (libjpeg 6 sources should also be available from most linux distribution repos; it's widely used) On Thu, May 13, 2010 at 5:57 PM, Mark Twenhafel wrote: > Hi- > > I saw the recent "Mac Support for PIL" thread in the archives. > Interestingly, I had the same problem a few months ago, when I last tried to > build this functionality. > > Just a quick question for now: does jpeg-8a work as a drop-in replacement > for jpeg-6a or -6b, in terms of not breaking PIL-1.1.7?? The README file > that came with PIL-1.1.7 specifically states libjpeg (6a or 6b) as a > dependency.? However, at the www.ijg.org site, only jpegsrc.v8a.tar.gz seems > to be available in the /files directory. > > Thanks, > Mark > > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > From chollapete at gmail.com Fri May 14 17:22:47 2010 From: chollapete at gmail.com (Mark Twenhafel) Date: Fri, 14 May 2010 08:22:47 -0700 Subject: [Image-SIG] Installing libjpeg Message-ID: Hi-- Follow-up to yesterday's question. Also, thanks to Fredrik Lundh for off-list assistance. At one point, I was momentarily speechless when I turned from an email back to the documentation I was reading and noticed that both were authored by the same, Mr. Lundh. :-) >From yesterday, I progressed to attempting to create an image object from within the Python interpreter using the call ImageTk.PhotoImage(file="filename.jpg"). This call threw an exception: "IOError: decoder jpeg not available" at line 375 in _getdecoder; specifically, "raise IOError("decoder %s not available" % decoder_name)" in file "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/Image.py". Mr Lundh offered this advice: This usually indicates that you've ended up with multiple _imaging.so binaries on the machine, and that the test and your script picks up different ones. Try adding print Image.core.__file__ to your script and make sure that the output is what you expect. At this point, my working hypothesis is that I did not install libjpeg correctly. I'm working on OS X Tiger. What I did was download "jpegsrc.v8a.tar.gz"; double-click in my download window in Firefox to untar; move the untarred "jpeg-8" folder to /Application; open Terminal and cd'ed to /Applications/jpeg-8; finally, I ran "./configure", "make", and "make install". It could be--and I don't know--that this install procedure did not correctly add libjpeg to my Python 2.6 installation or that I need to rebuild site-packages/PIL/_imaging.so in order to link-in libjpeg. Any direction would be appreciated. Thanks. Mark T. -- ________________ barackobama.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From chollapete at gmail.com Fri May 14 17:31:04 2010 From: chollapete at gmail.com (Mark Twenhafel) Date: Fri, 14 May 2010 08:31:04 -0700 Subject: [Image-SIG] Installing libjpeg In-Reply-To: References: Message-ID: On Fri, May 14, 2010 at 8:22 AM, Mark Twenhafel wrote: > Hi-- > > Follow-up to yesterday's question. Also, thanks to Fredrik Lundh for > off-list assistance. At one point, I was momentarily speechless when I > turned from an email back to the documentation I was reading and noticed > that both were authored by the same, Mr. Lundh. :-) > > From yesterday, I progressed to attempting to create an image object from > within the Python interpreter using the call > ImageTk.PhotoImage(file="filename.jpg"). This call threw an exception: > "IOError: decoder jpeg not available" at line 375 in _getdecoder; > specifically, "raise IOError("decoder %s not available" % decoder_name)" in > file > "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/Image.py". > > Mr Lundh offered this advice: > This usually indicates that you've ended up with multiple _imaging.so > binaries on the machine, and that the test and your script picks up > different ones. > > Try adding > > print Image.core.__file__ > > to your script and make sure that the output is what you expect. > > At this point, my working hypothesis is that I did not install libjpeg > correctly. I'm working on OS X Tiger. What I did was download > "jpegsrc.v8a.tar.gz"; double-click in my download window in Firefox to > untar; move the untarred "jpeg-8" folder to /Application; open Terminal and > cd'ed to /Applications/jpeg-8; finally, I ran "./configure", "make", and > "make install". > > It could be--and I don't know--that this install procedure did not > correctly add libjpeg to my Python 2.6 installation or that I need to > rebuild site-packages/PIL/_imaging.so in order to link-in libjpeg. Any > direction would be appreciated. > > Thanks. > > Mark T. > Belated point of clarification: I subsequently installed PIL using the these instructions: $ cd Imaging-1.1.7 $ python setup.py build_ext -i $ python selftest.py I just noticed that the file "site-packages/PIL/_imaging.so" was created last October. If so, would be be possible or likely that this was built using the version of libjpeg that didn't install on my machine? If this is correct, what is the best way to proceed? My first inclination is to delete the directory site-packages/PIL and reinstall. Good or bad idea? Thanks, Mark -- ________________ barackobama.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From Chris.Barker at noaa.gov Fri May 14 20:16:11 2010 From: Chris.Barker at noaa.gov (Chris Barker) Date: Fri, 14 May 2010 11:16:11 -0700 Subject: [Image-SIG] Installing libjpeg In-Reply-To: References: Message-ID: <4BED936B.5040209@noaa.gov> Mark Twenhafel wrote: > Try adding > > print Image.core.__file__ > > to your script and make sure that the output is what you expect. what was the result of that? > At this point, my working hypothesis is that I did not install libjpeg > correctly. I'm working on OS X Tiger. What I did was download > "jpegsrc.v8a.tar.gz"; double-click in my download window in Firefox to > untar; move the untarred "jpeg-8" folder to /Application; open Terminal > and cd'ed to /Applications/jpeg-8; finally, I ran "./configure", "make", > and "make install". > > It could be--and I don't know--that this install procedure did not > correctly add libjpeg to my Python 2.6 installation no it wouldn't have done that. > or that I need to > rebuild site-packages/PIL/_imaging.so in order to link-in libjpeg. indeed you do. > Belated point of clarification: I subsequently installed PIL using the > these instructions: > $ cd Imaging-1.1.7 > $ python setup.py build_ext -i > $ python selftest.py that should have built a new PIL, but it won't have installed it. Did the selftest run OK? > I just noticed that the file "site-packages/PIL/_imaging.so" was created > last October. which is why you are getting an old one here. > If so, would be be possible or likely that this was built > using the version of libjpeg that didn't install on my machine? yup. > If this > is correct, what is the best way to proceed? My first inclination is to > delete the directory site-packages/PIL and reinstall. yup -- you may not even need to delete, but it won't hurt. Take a look for a new _imaging.so that you should have just built. If you really want to know what it's linked to, try: $ otool -L _imaging.so But you might just do: setup.py install and see if it now works. We really do need to get a Mac binary built! -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 Sat May 15 15:22:29 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 15 May 2010 15:22:29 +0200 Subject: [Image-SIG] PIL windows binaries for Python 2.7b2 now available Message-ID: Available from the usual place: http://effbot.org/downloads/#pil From fredrik at pythonware.com Sun May 16 12:37:08 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 16 May 2010 12:37:08 +0200 Subject: [Image-SIG] Does libjpeg-8a work in PIL? In-Reply-To: References: Message-ID: Looks like they just replaced 8a with 8b. I've built and tested PIL with the 8b release, and all my JPEG tests seem to work just fine, so it should be safe to use. On Thu, May 13, 2010 at 7:07 PM, Fredrik Lundh wrote: > I haven't tested it specifically, but from a quick look at the release > notes, they don't seem to have changed any API:s, so it should work. > > In case you need the original, a copy of it seems to be available from here: > > http://code.google.com/p/quirkysoft/downloads/detail?name=jpegsrc.v6b.tar.gz > > (libjpeg 6 sources should also be available from most linux > distribution repos; it's widely used) > > > > On Thu, May 13, 2010 at 5:57 PM, Mark Twenhafel wrote: >> Hi- >> >> I saw the recent "Mac Support for PIL" thread in the archives. >> Interestingly, I had the same problem a few months ago, when I last tried to >> build this functionality. >> >> Just a quick question for now: does jpeg-8a work as a drop-in replacement >> for jpeg-6a or -6b, in terms of not breaking PIL-1.1.7?? The README file >> that came with PIL-1.1.7 specifically states libjpeg (6a or 6b) as a >> dependency.? However, at the www.ijg.org site, only jpegsrc.v8a.tar.gz seems >> to be available in the /files directory. >> >> Thanks, >> Mark >> >> _______________________________________________ >> Image-SIG maillist ?- ?Image-SIG at python.org >> http://mail.python.org/mailman/listinfo/image-sig >> >> > From pyprog05 at gmail.com Sun May 16 18:51:10 2010 From: pyprog05 at gmail.com (PyProg PyProg) Date: Sun, 16 May 2010 18:51:10 +0200 Subject: [Image-SIG] Image perspective with PIL In-Reply-To: References: Message-ID: 2010/5/3 Fredrik Lundh : > I've added the documentation from the original patch to this page: > > ?http://effbot.org/tag/pil.Image.Image.transform > > The next text is attached below. > > > > im.transform(size, PERSPECTIVE, data) > > im.transform(size, PERSPECTIVE, data, filter) > > Applies a perspective transform to the image, and places the result > in a new image with the given size. > > Data is a 8-tuple (a, b, c, d, e, f, g, h) which contains the > coefficients for a perspective transform. For each pixel (x, y) > in the output image, the new value is taken from a position > (a x + b y + c)/(g x + h y + 1), (d x + e y + f)/(g x + h y + 1) > in the input image, rounded to nearest pixel. > > This function can be used to change the 2D perspective of the > original image. Hello The problem is that I do not understand what that means: "which Contains the coefficients for a perspective transform ... "... and in particular what exactly match a, b, c, d, e, f, g and h. If you are patient (excuse me), can you explain with precision (and a didactic, for someone who has trouble like me) what these data (and possibly with an example of processing with good values for a, b, c, d, e, f , g and h). Thank you in advance. a+ -- http://ekd.tuxfamily.org http://ekdm.wordpress.com http://lprod.org/wiki/doku.php/video:encodage:avchd_converter From edward at unicornschool.org Sun May 16 20:01:20 2010 From: edward at unicornschool.org (Edward Cannon) Date: Sun, 16 May 2010 11:01:20 -0700 Subject: [Image-SIG] Image perspective with PIL In-Reply-To: References: Message-ID: a,b,c,d,e,f,g,h are the coefficients of the perspective transform. look at http://alumni.media.mit.edu/~cwren/interpolator/ for a brief introduction (look for the fraction formula x= (ax+by+c)/(gx=hy+1) On Sun, May 16, 2010 at 9:51 AM, PyProg PyProg wrote: > 2010/5/3 Fredrik Lundh : > >> I've added the documentation from the original patch to this page: >> >> ?http://effbot.org/tag/pil.Image.Image.transform >> >> The next text is attached below. >> >> >> >> im.transform(size, PERSPECTIVE, data) >> >> im.transform(size, PERSPECTIVE, data, filter) >> >> Applies a perspective transform to the image, and places the result >> in a new image with the given size. >> >> Data is a 8-tuple (a, b, c, d, e, f, g, h) which contains the >> coefficients for a perspective transform. For each pixel (x, y) >> in the output image, the new value is taken from a position >> (a x + b y + c)/(g x + h y + 1), (d x + e y + f)/(g x + h y + 1) >> in the input image, rounded to nearest pixel. >> >> This function can be used to change the 2D perspective of the >> original image. > > Hello > > The problem is that I do not understand what that means: "which > Contains the coefficients for a perspective transform ... "... and in > particular what exactly match a, b, c, d, e, f, g and h. > > If you are patient (excuse me), can you explain with precision (and a > didactic, for someone who has trouble like me) what these data (and > possibly with an example of processing with good values for a, b, c, > d, e, f , g and h). > > Thank you in advance. > > a+ > > -- > http://ekd.tuxfamily.org > http://ekdm.wordpress.com > http://lprod.org/wiki/doku.php/video:encodage:avchd_converter > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From chollapete at gmail.com Mon May 17 20:58:47 2010 From: chollapete at gmail.com (Mark Twenhafel) Date: Mon, 17 May 2010 11:58:47 -0700 Subject: [Image-SIG] Installing libjpeg Message-ID: Chris--I thought I had mailed this Friday, but it never appeared in image-sig, so here goes again. I'll continue with the interleaved response-style. Thanks for the help--for my part, I'm working through K&R, hoping that this will teach me enough about compiling and linking C to puzzle out why this package isn't installing seamlessly. Mark >Mark Twenhafel wrote: >>* Try adding *>>* *>>* print Image.core.__file__ *>>* *>>* to your script and make sure that the output is what you expect. *> >what was the result of that? redpoint:~/sandbox/python/persfin1 mark$ python Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39) [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import Image >>> print Image.core.__file__ /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so >>> > >>* At this point, my working hypothesis is that I did not install libjpeg *>>* correctly. I'm working on OS X Tiger. What I did was download *>>* "jpegsrc.v8a.tar.gz"; double-click in my download window in Firefox to *>>* untar; move the untarred "jpeg-8" folder to /Application; open Terminal *>>* and cd'ed to /Applications/jpeg-8; finally, I ran "./configure", "make", *>>* and "make install". *>>* *>>* It could be--and I don't know--that this install procedure did not *>>* correctly add libjpeg to my Python 2.6 installation *> >no it wouldn't have done that. > >*> or that I need to *>>* rebuild site-packages/PIL/_imaging.so in order to link-in libjpeg. *> >indeed you do. > >>* Belated point of clarification: I subsequently installed PIL using the *>>* these instructions: *>>* $ cd Imaging-1.1.7 *>>* $ python setup.py build_ext -i *>>* $ python selftest.py *> >that should have built a new PIL, but it won't have installed it. > >Did the selftest run OK? redpoint:/Applications/Imaging-1.1.7 mark$ python selftest.py -------------------------------------------------------------------- PIL 1.1.7 TEST SUMMARY -------------------------------------------------------------------- Python modules loaded from ./PIL Binary modules loaded from ./PIL -------------------------------------------------------------------- --- PIL CORE support ok --- TKINTER support ok --- JPEG support ok --- ZLIB (PNG/ZIP) support ok --- FREETYPE2 support ok *** LITTLECMS support not installed -------------------------------------------------------------------- Running selftest: --- 57 tests passed. redpoint:/Applications/Imaging-1.1.7 mark$ > >>* I just noticed that the file "site-packages/PIL/_imaging.so" was created *>>* last October. *> >which is why you are getting an old one here. The last few lines of a long listing of PIL follow: -rw-r--r-- 1 root admin 3047 Oct 11 2009 XpmImagePlugin.pyc -rw-r--r-- 1 root admin 231 Dec 3 2006 __init__.py -rw-r--r-- 1 root admin 180 Oct 11 2009 __init__.pyc -rw-r--r-- 1 root admin 1406408 Oct 11 2009 _imaging.so -rw-r--r-- 1 root admin 87420 Oct 11 2009 _imagingft.so -rw-r--r-- 1 root admin 89240 Oct 11 2009 _imagingmath.so -rw-r--r-- 1 root admin 54056 Oct 11 2009 _imagingtk.so redpoint:/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL mark$ > >>* If so, would be be possible or likely that this was built *>>* using the version of libjpeg that didn't install on my machine? *> >yup. > >>* If this *>>* is correct, what is the best way to proceed? My first inclination is to *>>* delete the directory site-packages/PIL and reinstall. *> >yup -- you may not even need to delete, but it won't hurt. > >Take a look for a new _imaging.so that you should have just built. If >you really want to know what it's linked to, try: > >$ otool -L _imaging.so Interpreting this is beyond me, at this point: redpoint:/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL mark$ otool -L _imaging.so _imaging.so: /usr/local/lib/libjpeg.7.dylib (compatibility version 8.0.0, current version 8.0.0) /opt/local/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.9) redpoint:/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL mark$ > >But you might just do: > >setup.py install > >and see if it now works. The following code still produces the following exception: redpoint:~/sandbox/python/persfin1 mark$ cat ./mwm.py #!/usr/local/bin/python from Tkinter import * import Image import ImageTk class Application(Frame): def __init__(self, master=None): Frame.__init__(self, master) self.grid() self.createWidgets() def createWidgets(self): self.cnv = Canvas(self) self.img = ImageTk.PhotoImage(Image.open("/Applications/Imaging-1.1.7/Images/lena.jpg")) cvnitem = self.cnv.create_image(100, 100, image=self.img) self.cnv.grid() app = Application() app.master.title("Sample application") app.mainloop() redpoint:~/sandbox/python/persfin1 mark$ ./mwm.py Traceback (most recent call last): File "./mwm.py", line 18, in app = Application() File "./mwm.py", line 10, in __init__ self.createWidgets() File "./mwm.py", line 14, in createWidgets self.img = ImageTk.PhotoImage(Image.open("/Applications/Imaging-1.1.7/Images/lena.jpg")) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/ImageTk.py", line 116, in __init__ self.paste(image) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/ImageTk.py", line 166, in paste im.load() File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/ImageFile.py", line 180, in load d = Image._getdecoder(self.mode, d, a, self.decoderconfig) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/Image.py", line 375, in _getdecoder raise IOError("decoder %s not available" % decoder_name) IOError: decoder jpeg not available redpoint:~/sandbox/python/persfin1 mark$ > >We really do need to get a Mac binary built! > >-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 > Thanks to anyone looking at this. Like I said, I want to get this running, but I'm not asking anyone to do my own debugging. I'll keep hacking away at this at my level. Mark -------------- next part -------------- An HTML attachment was scrubbed... URL: From Chris.Barker at noaa.gov Tue May 18 01:36:25 2010 From: Chris.Barker at noaa.gov (Chris Barker) Date: Mon, 17 May 2010 16:36:25 -0700 Subject: [Image-SIG] Installing libjpeg In-Reply-To: References: Message-ID: <4BF1D2F9.2060609@noaa.gov> Mark Twenhafel wrote: > Chris--I thought I had mailed this Friday, but it never appeared in image-sig, > so here goes again. I'll continue with the interleaved response-style. Thanks > for the help--for my part, I'm working through K&R, I doubt K&R will help there -- I'd look for something about gcc. Even though tis isn't linux, I learned a lot form "Linux Application Development". You can probably find a reference on linking on OS-X -- it does some things differently. good luck. -CHB hoping that this will teach > > me enough about compiling and linking C to puzzle out why this package isn't > installing seamlessly. > > Mark > >>Mark Twenhafel wrote: >>>/ Try adding > />>/ > />>/ print Image.core.__file__ > > />>/ > />>/ to your script and make sure that the output is what you expect. > /> >>what was the result of that? > > redpoint:~/sandbox/python/persfin1 mark$ python > Python 2.6.2 (r262:71600, Apr 16 2009, 09:17:39) > > [GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin > Type "help", "copyright", "credits" or "license" for more information. >>>> import Image >>>> print Image.core.__file__ > > /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so >>>> > > >> >>>/ At this point, my working hypothesis is that I did not install libjpeg > />>/ correctly. I'm working on OS X Tiger. What I did was download > > />>/ "jpegsrc.v8a.tar.gz"; double-click in my download window in Firefox to > />>/ untar; move the untarred "jpeg-8" folder to /Application; open Terminal > />>/ and cd'ed to /Applications/jpeg-8; finally, I ran "./configure", "make", > > />>/ and "make install". > />>/ > />>/ It could be--and I don't know--that this install procedure did not > />>/ correctly add libjpeg to my Python 2.6 installation > > /> >>no it wouldn't have done that. >> >>/> or that I need to > />>/ rebuild site-packages/PIL/_imaging.so in order to link-in libjpeg. > /> >>indeed you do. >> > >>>/ Belated point of clarification: I subsequently installed PIL using the > />>/ these instructions: > />>/ $ cd Imaging-1.1.7 > />>/ $ python setup.py build_ext -i > > />>/ $ python selftest.py > /> >>that should have built a new PIL, but it won't have installed it. >> >>Did the selftest run OK? > > redpoint:/Applications/Imaging-1.1.7 mark$ python selftest.py > > -------------------------------------------------------------------- > PIL 1.1.7 TEST SUMMARY > -------------------------------------------------------------------- > Python modules loaded from ./PIL > Binary modules loaded from ./PIL > > -------------------------------------------------------------------- > --- PIL CORE support ok > --- TKINTER support ok > --- JPEG support ok > --- ZLIB (PNG/ZIP) support ok > --- FREETYPE2 support ok > *** LITTLECMS support not installed > > -------------------------------------------------------------------- > Running selftest: > --- 57 tests passed. > redpoint:/Applications/Imaging-1.1.7 mark$ > > >> >>>/ I just noticed that the file "site-packages/PIL/_imaging.so" was created > > />>/ last October. > /> >>which is why you are getting an old one here. > > The last few lines of a long listing of PIL follow: > > -rw-r--r-- 1 root admin 3047 Oct 11 2009 XpmImagePlugin.pyc > > -rw-r--r-- 1 root admin 231 Dec 3 2006 __init__.py > -rw-r--r-- 1 root admin 180 Oct 11 2009 __init__.pyc > -rw-r--r-- 1 root admin 1406408 Oct 11 2009 _imaging.so > -rw-r--r-- 1 root admin 87420 Oct 11 2009 _imagingft.so > > -rw-r--r-- 1 root admin 89240 Oct 11 2009 _imagingmath.so > -rw-r--r-- 1 root admin 54056 Oct 11 2009 _imagingtk.so > redpoint:/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL mark$ > > > > >> >>>/ If so, would be be possible or likely that this was built > />>/ using the version of libjpeg that didn't install on my machine? > /> >>yup. >> >>>/ If this > > />>/ is correct, what is the best way to proceed? My first inclination is to > />>/ delete the directory site-packages/PIL and reinstall. > /> >>yup -- you may not even need to delete, but it won't hurt. > >> >>Take a look for a new _imaging.so that you should have just built. If >>you really want to know what it's linked to, try: >> >>$ otool -L _imaging.so > > > Interpreting this is beyond me, at this point: > > > redpoint:/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL mark$ otool -L _imaging.so > _imaging.so: > /usr/local/lib/libjpeg.7.dylib (compatibility version 8.0.0, current version 8.0.0) > > /opt/local/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.3) > /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 88.3.9) > redpoint:/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL mark$ > > > > >> >>But you might just do: >> >>setup.py install >> >>and see if it now works. > > The following code still produces the following exception: > > redpoint:~/sandbox/python/persfin1 mark$ cat ./mwm.py > > #!/usr/local/bin/python > from Tkinter import * > import Image > import ImageTk > > class Application(Frame): > def __init__(self, master=None): > Frame.__init__(self, master) > self.grid() > > self.createWidgets() > > def createWidgets(self): > self.cnv = Canvas(self) > self.img = ImageTk.PhotoImage(Image.open("/Applications/Imaging-1.1.7/Images/lena.jpg")) > cvnitem = self.cnv.create_image(100, 100, image=self.img) > > self.cnv.grid() > > app = Application() > app.master.title("Sample application") > app.mainloop() > > redpoint:~/sandbox/python/persfin1 mark$ ./mwm.py > Traceback (most recent call last): > File "./mwm.py", line 18, in > > app = Application() > File "./mwm.py", line 10, in __init__ > self.createWidgets() > File "./mwm.py", line 14, in createWidgets > self.img = ImageTk.PhotoImage(Image.open("/Applications/Imaging-1.1.7/Images/lena.jpg")) > > File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/ImageTk.py", line 116, in __init__ > self.paste(image) > File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/ImageTk.py", line 166, in paste > > im.load() > File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/ImageFile.py", line 180, in load > d = Image._getdecoder(self.mode, d, a, self.decoderconfig) > File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/Image.py", line 375, in _getdecoder > > raise IOError("decoder %s not available" % decoder_name) > IOError: decoder jpeg not available > redpoint:~/sandbox/python/persfin1 mark$ > > >> >>We really do need to get a Mac binary built! > >> >>-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 > >> > > Thanks to anyone looking at this. Like I said, I want to get this running, but I'm not asking > anyone to do my own debugging. I'll keep hacking away at this at my level. > > Mark > > -- 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 tom.blackmore at arctictiger.se Tue May 18 09:18:19 2010 From: tom.blackmore at arctictiger.se (Tom Blackmore) Date: Tue, 18 May 2010 09:18:19 +0200 Subject: [Image-SIG] (no subject) Message-ID: Hi. I'm new to the PIL library and having problems while converting 24 bits png to gif. While the conversion works fine from an image quality perspective, the resultant gif image size is very large. Much larger than the original 24 bit png! Carrying out the same conversion in other image programs (irfanview, gimp) produces an image of about a quarter of the size as my code. I use the following code to carry out the conversion. img = Image.open(self.input) img = img.convert('RGB').convert('P', palette=Image.ADAPTIVE) img.save(self.output,"gif") I use an adaptive palette since I'm converting maps and dithering reduces the quality. Any tips/suggestions are welcome. Kind regards Tom -- Tom Blackmore www.arctictiger.se V?sterkvarnsv?gen 7, 73493 Kolb?ck Tfn. 073-8413456 From jamie.portsmouth at havok.com Tue May 18 12:32:33 2010 From: jamie.portsmouth at havok.com (Jamie Portsmouth) Date: Tue, 18 May 2010 11:32:33 +0100 Subject: [Image-SIG] PIL 1.1.7 doesn't work on Windows 7 64-bit, right? Message-ID: Hi, I installed PIL 1.1.7, on Windows 7 64 bit. import Image works fine. But: import _imaging gives >>> import _imaging Traceback (most recent call last): File "", line 1, in ImportError: DLL load failed: %1 is not a valid Win32 application. Known issue? Any workaround? Jamie -------------- next part -------------- An HTML attachment was scrubbed... URL: From chollapete at gmail.com Sat May 22 00:29:10 2010 From: chollapete at gmail.com (Mark Twenhafel) Date: Fri, 21 May 2010 15:29:10 -0700 Subject: [Image-SIG] Installing libjpeg Message-ID: Hi-- I just wanted to close out this thread, for the benefit of anyone reading the archives in the future. The problem was solved by following Chris Barker's advice/observation that the files "site-packages/PIL/_imaging*.so" needed to be deleted and then the PIL package rebuilt. That is exactly what I did, and PIL is now working. The wildcard "_imaging*.so" matched the four shared-object files seen in the listing, shown in my earlier post. I deleted those four files and then rebuilt them by executing "python setup.py install" in the Imaging-1.1.7 directory. Apparently, the install script doesn't delete these files if they already exist; unfortunately, they had been linked to a version of libjpeg that didn't work on my box. Deleting and rebuilding the four "_imaging*.so" files allowed the new shared-object files to link to the new version of libjpeg that I had installed, which *does* work on my box. Thanks to Chris, and to Fredrik for his earlier assistance. Hope I haven't clogged up too much bandwidth with my novice-level approach. Mark T. -------------- next part -------------- An HTML attachment was scrubbed... URL: From saman01us at yahoo.com Sat May 22 04:24:37 2010 From: saman01us at yahoo.com (Ali Mohseni) Date: Fri, 21 May 2010 19:24:37 -0700 (PDT) Subject: [Image-SIG] PIL Message-ID: <380283.15997.qm@web180110.mail.gq1.yahoo.com> I downloaded and installed pil. In the interpreter window, when I type "import image" I get the following error message: "No Module name image" If I type import math it works fine. Can anyone help me please? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From vze2tncc at verizon.net Sun May 23 01:26:01 2010 From: vze2tncc at verizon.net (Troy Nixon) Date: Sat, 22 May 2010 19:26:01 -0400 Subject: [Image-SIG] Loading Imaging 1.1.7 Message-ID: Hello, I?ve purchased the Hair Designer Texture Creator for Mac and I?m having problems understanding how to add this file to my Poser Program. Please help. Thanks, Troy Nixon -------------- next part -------------- An HTML attachment was scrubbed... URL: From edward at unicornschool.org Sun May 23 16:51:47 2010 From: edward at unicornschool.org (Edward Cannon) Date: Sun, 23 May 2010 07:51:47 -0700 Subject: [Image-SIG] PIL In-Reply-To: <380283.15997.qm@web180110.mail.gq1.yahoo.com> References: <380283.15997.qm@web180110.mail.gq1.yahoo.com> Message-ID: please provide python and pil version numbers, what OS you are using, and how you installed it, (prebuilt binary or build from source) On Fri, May 21, 2010 at 7:24 PM, Ali Mohseni wrote: > > I downloaded and installed pil. > In the interpreter window, when I type "import image" I get the following error message: > "No Module name image" > > If I type import math it works fine. > Can anyone help me please? > Thanks > > > > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From edward at unicornschool.org Sun May 23 16:53:44 2010 From: edward at unicornschool.org (Edward Cannon) Date: Sun, 23 May 2010 07:53:44 -0700 Subject: [Image-SIG] Loading Imaging 1.1.7 In-Reply-To: References: Message-ID: you have posted to the wrong list. this list is about image processing in the Python programing language. Try contacting the software vendor for help. On Sat, May 22, 2010 at 4:26 PM, Troy Nixon wrote: > Hello, > I?ve purchased the Hair Designer Texture Creator for Mac and I?m having > problems understanding how to add this file to my Poser Program. ?Please > help. > Thanks, > Troy Nixon > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > From halbert at halwitz.org Sun May 23 17:25:06 2010 From: halbert at halwitz.org (Dan Halbert) Date: Sun, 23 May 2010 11:25:06 -0400 Subject: [Image-SIG] PIL In-Reply-To: <380283.15997.qm@web180110.mail.gq1.yahoo.com> References: <380283.15997.qm@web180110.mail.gq1.yahoo.com> Message-ID: <4BF948D2.20309@halwitz.org> On 5/21/2010 10:24 PM, Ali Mohseni wrote: > I downloaded and installed pil. > In the interpreter window, when I type "import image" I get the > following error message: > "No Module name image" Capitalization is important. Did you type "Image" or "image"? Try: import Image and also from PIL import Image Dan From nicolas at famillepinault.fr Sun May 23 09:41:56 2010 From: nicolas at famillepinault.fr (Nicolas Pinault) Date: Sun, 23 May 2010 09:41:56 +0200 Subject: [Image-SIG] PIL In-Reply-To: <380283.15997.qm@web180110.mail.gq1.yahoo.com> References: <380283.15997.qm@web180110.mail.gq1.yahoo.com> Message-ID: <4BF8DC44.4080302@famillepinault.fr> import Image Nicolas Le 22/05/2010 04:24, Ali Mohseni a ?crit : > I downloaded and installed pil. > In the interpreter window, when I type "import image" I get the > following error message: > "No Module name image" > > If I type import math it works fine. > Can anyone help me please? > Thanks > > > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark.wendell at gmail.com Sun May 23 11:23:55 2010 From: mark.wendell at gmail.com (Mark Wendell) Date: Sun, 23 May 2010 18:53:55 +0930 Subject: [Image-SIG] PIL In-Reply-To: <380283.15997.qm@web180110.mail.gq1.yahoo.com> References: <380283.15997.qm@web180110.mail.gq1.yahoo.com> Message-ID: Try 'import Image' (with a capital I). On Sat, May 22, 2010 at 11:54 AM, Ali Mohseni wrote: > I downloaded and installed pil. > In the interpreter window, when I type "import image" I get the following > error message: > "No Module name image" > > If I type import math it works fine. > Can anyone help me please? > Thanks > > > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > -- -- Mark Wendell -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrewwilson at alum.mit.edu Sun May 23 17:01:01 2010 From: andrewwilson at alum.mit.edu (Andrew Wilson) Date: Sun, 23 May 2010 11:01:01 -0400 Subject: [Image-SIG] PIL In-Reply-To: References: <380283.15997.qm@web180110.mail.gq1.yahoo.com> Message-ID: try capitalizing image... "import Image" On Sun, May 23, 2010 at 10:51 AM, Edward Cannon wrote: > please provide python and pil version numbers, what OS you are using, > and how you installed it, (prebuilt binary or build from source) > > On Fri, May 21, 2010 at 7:24 PM, Ali Mohseni wrote: > > > > I downloaded and installed pil. > > In the interpreter window, when I type "import image" I get the following > error message: > > "No Module name image" > > > > If I type import math it works fine. > > Can anyone help me please? > > Thanks > > > > > > > > _______________________________________________ > > Image-SIG maillist - Image-SIG at python.org > > http://mail.python.org/mailman/listinfo/image-sig > > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Chris.Barker at noaa.gov Tue May 25 21:57:28 2010 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Tue, 25 May 2010 12:57:28 -0700 Subject: [Image-SIG] PIL binaries -- please test Message-ID: <4BFC2BA8.6040809@noaa.gov> Hi folks, Much to my surprise, I had a little time to build some PIL binaries: http://dl.dropbox.com/u/855965/PIL-OSX-Binaries/PIL-1.1.7-py2.5-macosx10.5.mpkg.zip http://dl.dropbox.com/u/855965/PIL-OSX-Binaries/PIL-1.1.7-py2.6-macosx10.5.mpkg.zip I'd really like folks to test them on as many different systems as possible. You can see these are for python 2.5 or 2.6, build with and for the python.org python binaries. They should have all dependencies statically linked. I built them on OS-X 10.5 (leopard), so they may not work on 10.4 I'd love if someone could test and see if they do, however, I no longer have a 10.4 system to test on. I do expect them to work on 10.5 and 10.6, PPC and Intel. Please let me know if you test, whether it worked or not, and on what system/python. If these work well, I think Fredrik will put them on the PIL site. Thanks, -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 May 26 01:21:57 2010 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Tue, 25 May 2010 16:21:57 -0700 Subject: [Image-SIG] [Pythonmac-SIG] PIL binaries -- please test In-Reply-To: <4BFC4E36.8030604@gmail.com> References: <4BFC2BA8.6040809@noaa.gov> <4BFC4E36.8030604@gmail.com> Message-ID: <4BFC5B95.5070909@noaa.gov> Matthias Baas wrote: > Christopher Barker wrote: >> Much to my surprise, I had a little time to build some PIL binaries: >> >> http://dl.dropbox.com/u/855965/PIL-OSX-Binaries/PIL-1.1.7-py2.5-macosx10.5.mpkg.zip >> http://dl.dropbox.com/u/855965/PIL-OSX-Binaries/PIL-1.1.7-py2.6-macosx10.5.mpkg.zip >> I built them on OS-X 10.5 (leopard), so they may not work on 10.4 I'd >> love if someone could test and see if they do, however, I no longer have >> a 10.4 system to test on. > > I tried the py2.6 binary on OSX 10.4. The package installs fine but it > can't really load an image. When I open a jpg, I can read its size but > as soon as I try to load the data, I get an import error: > > ImportError: The _imaging C module is not installed > > When I try to import _imaging manually I get: > > ImportError: dlopen(./_imaging.so, 2): Symbol not found: _clock$UNIX2003 > Referenced from: ./_imaging.so > Expected in: dynamic lookup Thanks for testing -- it's pretty much what I expected. I build libjpeg will macports, and it linked it against the 10.5 system libs. It's certainly possible to build libs that are 10.4 compatible, but it's a pain to do on a 10.5 machine. I don't have much time, so these will remain 10.5 and above binaries, unless someone steps up to build universal versions of the dependencies that work with 10.4. NOTE: it was trivial to build them with macports on 10.5. However, last time I tried on 10.4, I had trouble. But if you have a 10.4 system and want to give it a try: $ sudo port install jpeg +universal and see if it works -- if it does, try the other dependencies (I think it's freetype, zlib, and lcms -- see the PIL README) Fredrik -- it's up to you what you want to post on your site, but if we hear from some others that they work for them, you might want to post these, making it clear they work only for the python.org binaries and OS-X 10.5 and above. For what it's worth, I built these on an Intel 10.5 system and they work there and on my PPC 10.5 system, so that's a start. -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 May 26 01:56:37 2010 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Tue, 25 May 2010 16:56:37 -0700 Subject: [Image-SIG] PIL binaries -- please test In-Reply-To: <4BFC2BA8.6040809@noaa.gov> References: <4BFC2BA8.6040809@noaa.gov> Message-ID: <4BFC63B5.3030806@noaa.gov> Christopher Barker wrote: > I'd really like folks to test them on as many different systems as > possible. By the way, is there a test module that can be run from an installed version? It would be nice if it was easy for folks to test these binaries. -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 erwin94 at gmx.net Wed May 26 04:23:27 2010 From: erwin94 at gmx.net (David) Date: Wed, 26 May 2010 04:23:27 +0200 Subject: [Image-SIG] PIL bug: Antialias.c bicubic filter error In-Reply-To: References: <03B44E09-0554-4A98-A86A-3ED63DC85E96@gmx.net> Message-ID: On May 9, 2010, at 4:03 AM, Xavier Ho wrote: > On Sun, May 9, 2010 at 11:47 AM, David wrote: > return (((a * x) - 5*a) * x + 8*a) * x - 4*a; > > Hello David, > I just factored out from your patch, as a comment to your post. > > ((x - 5) * x + 8) * a * x - 4*a; > Yes, of course, thanks! Actually there seems to be another bug in that file, which becomes apparent when a is not 0: The support of the filter is set to 0.5 for every magnification, which degrades ANTIALIAS and BICUBIC resizing to something that looks close to BILINEAR. The attached patch attempts to fix both. till then, David. -------------- next part -------------- A non-text attachment was scrubbed... Name: bicubic.patch Type: application/octet-stream Size: 923 bytes Desc: not available URL: From yury at shurup.com Wed May 26 09:17:07 2010 From: yury at shurup.com (Yury V. Zaytsev) Date: Wed, 26 May 2010 09:17:07 +0200 Subject: [Image-SIG] PIL binaries -- please test In-Reply-To: <4BFC2BA8.6040809@noaa.gov> References: <4BFC2BA8.6040809@noaa.gov> Message-ID: <1274858227.6918.10.camel@mypride> Hi Chris, On Tue, 2010-05-25 at 12:57 -0700, Christopher Barker wrote: > If these work well, I think Fredrik will put them on the PIL site. If you need a permanent mirror in the States, here you go: http://packages.zaytsev.net/python/ What I would want to comment is that it would be nice for you to post the history script / walk-through / whatever on how you created them, so that other people would be able to reproduce this if you are busy / unavailable etc. For instance, I have a whole bunch of Macs out there... -- Sincerely yours, Yury V. Zaytsev From aditya at wefoundland.com Tue May 25 22:08:51 2010 From: aditya at wefoundland.com (aditya bhargava) Date: Tue, 25 May 2010 15:08:51 -0500 Subject: [Image-SIG] [Pythonmac-SIG] PIL binaries -- please test In-Reply-To: <4BFC2BA8.6040809@noaa.gov> References: <4BFC2BA8.6040809@noaa.gov> Message-ID: How do you determine which version of Python to build for? I'm on 10.4 and I've got two versions of Python ? python2.3 in /usr/bin/python and python2.5 in /opt/local/bin/python. python2.5 is my default (i.e. the one that shows when I run 'which python'), but the package installer doesn't seem to recognize it. It gives me an error saying "You cannot install PIL 1.1.7 on this volume. PIL requires System Python 2.5 to install". Aditya On Tue, May 25, 2010 at 2:57 PM, Christopher Barker wrote: > Hi folks, > > Much to my surprise, I had a little time to build some PIL binaries: > > > http://dl.dropbox.com/u/855965/PIL-OSX-Binaries/PIL-1.1.7-py2.5-macosx10.5.mpkg.zip > > > http://dl.dropbox.com/u/855965/PIL-OSX-Binaries/PIL-1.1.7-py2.6-macosx10.5.mpkg.zip > > I'd really like folks to test them on as many different systems as > possible. > > You can see these are for python 2.5 or 2.6, build with and for the > python.org python binaries. They should have all dependencies statically > linked. > > I built them on OS-X 10.5 (leopard), so they may not work on 10.4 I'd love > if someone could test and see if they do, however, I no longer have a 10.4 > system to test on. > > I do expect them to work on 10.5 and 10.6, PPC and Intel. > > Please let me know if you test, whether it worked or not, and on what > system/python. > > If these work well, I think Fredrik will put them on the PIL site. > > Thanks, > -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 > _______________________________________________ > Pythonmac-SIG maillist - Pythonmac-SIG at python.org > http://mail.python.org/mailman/listinfo/pythonmac-sig > unsubscribe: http://mail.python.org/mailman/options/Pythonmac-SIG > -- wefoundland.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthias.baas at gmail.com Wed May 26 00:24:54 2010 From: matthias.baas at gmail.com (Matthias Baas) Date: Tue, 25 May 2010 23:24:54 +0100 Subject: [Image-SIG] [Pythonmac-SIG] PIL binaries -- please test In-Reply-To: <4BFC2BA8.6040809@noaa.gov> References: <4BFC2BA8.6040809@noaa.gov> Message-ID: <4BFC4E36.8030604@gmail.com> Christopher Barker wrote: > Much to my surprise, I had a little time to build some PIL binaries: > > http://dl.dropbox.com/u/855965/PIL-OSX-Binaries/PIL-1.1.7-py2.5-macosx10.5.mpkg.zip > http://dl.dropbox.com/u/855965/PIL-OSX-Binaries/PIL-1.1.7-py2.6-macosx10.5.mpkg.zip > > I'd really like folks to test them on as many different systems as > possible. > > You can see these are for python 2.5 or 2.6, build with and for the > python.org python binaries. They should have all dependencies statically > linked. > > I built them on OS-X 10.5 (leopard), so they may not work on 10.4 I'd > love if someone could test and see if they do, however, I no longer have > a 10.4 system to test on. I tried the py2.6 binary on OSX 10.4. The package installs fine but it can't really load an image. When I open a jpg, I can read its size but as soon as I try to load the data, I get an import error: ImportError: The _imaging C module is not installed When I try to import _imaging manually I get: ImportError: dlopen(./_imaging.so, 2): Symbol not found: _clock$UNIX2003 Referenced from: ./_imaging.so Expected in: dynamic lookup I don't know what that UNIX2003 means? Is that a special version of clock() that's not compatible with the one provided here on 10.4? Cheers, - Matthias - From matthias.baas at gmail.com Wed May 26 00:30:20 2010 From: matthias.baas at gmail.com (Matthias Baas) Date: Tue, 25 May 2010 23:30:20 +0100 Subject: [Image-SIG] [Pythonmac-SIG] PIL binaries -- please test In-Reply-To: References: <4BFC2BA8.6040809@noaa.gov> Message-ID: <4BFC4F7C.3060805@gmail.com> aditya bhargava wrote: > How do you determine which version of Python to build for? I'm on 10.4 > and I've got two versions of Python ? python2.3 in /usr/bin/python and > python2.5 in /opt/local/bin/python. python2.5 is my default (i.e. the > one that shows when I run 'which python'), but the package installer > doesn't seem to recognize it. It gives me an error saying "You cannot > install PIL 1.1.7 on this volume. PIL requires System Python 2.5 to > install". Apparently, you got your Python 2.5 from MacPorts (as it's in /opt/local). As far as I know, such installers as provided by Christopher only work with the Python version you can download on python.org (or the system Python probably) whereas if you want extension modules for your MacPorts Python you also have to use MacPorts to install them. Cheers, - Matthias - From zvezdan at zope.com Wed May 26 06:10:30 2010 From: zvezdan at zope.com (Zvezdan Petkovic) Date: Wed, 26 May 2010 00:10:30 -0400 Subject: [Image-SIG] [Pythonmac-SIG] PIL binaries -- please test In-Reply-To: <4BFC4E36.8030604@gmail.com> References: <4BFC2BA8.6040809@noaa.gov> <4BFC4E36.8030604@gmail.com> Message-ID: On May 25, 2010, at 6:24 PM, Matthias Baas wrote: > I tried the py2.6 binary on OSX 10.4. The package installs fine but it > can't really load an image. When I open a jpg, I can read its size but > as soon as I try to load the data, I get an import error: > > ImportError: The _imaging C module is not installed > > When I try to import _imaging manually I get: > > ImportError: dlopen(./_imaging.so, 2): Symbol not found: _clock$UNIX2003 > Referenced from: ./_imaging.so > Expected in: dynamic lookup > > I don't know what that UNIX2003 means? Is that a special version of > clock() that's not compatible with the one provided here on 10.4? In short: Mac OS X 10.5 (Leopard) is an officially certified UNIX conforming to UNIX 2003 specification. Since Mac OS X 10.4 and earlier still had to be supported, Apple decided to use names like _clock() for legacy calls and _clock$UNIX2003() for the new UNIX specification compatible calls. See the details here: http://developer.apple.com/mac/library/releasenotes/Darwin/SymbolVariantsRelNotes/index.html Unfortunately, this also means that you cannot use this build of PIL on Mac OS X 10.4 and older. Best regards, Zvezdan From Chris.Barker at noaa.gov Wed May 26 19:58:32 2010 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Wed, 26 May 2010 10:58:32 -0700 Subject: [Image-SIG] PIL binaries -- please test In-Reply-To: <1274858227.6918.10.camel@mypride> References: <4BFC2BA8.6040809@noaa.gov> <1274858227.6918.10.camel@mypride> Message-ID: <4BFD6148.8000407@noaa.gov> Yury V. Zaytsev wrote: > On Tue, 2010-05-25 at 12:57 -0700, Christopher Barker wrote: > >> If these work well, I think Fredrik will put them on the PIL site. > > If you need a permanent mirror in the States, here you go: > > http://packages.zaytsev.net/python/ Thanks, though ideally these would be available in a place everyone would know to look -- i.e. the PIL site. > What I would want to comment is that it would be nice for you to post > the history script / walk-through / whatever on how you created them, so > that other people would be able to reproduce this if you are busy / > unavailable etc. > > For instance, I have a whole bunch of Macs out there... great -- are any of them running 10.4? I have little time, but here is the short version: The goal is to get a PIL binary that is statically linked to all of its dependencies, and those dependencies are all universal (32 bit PPC and Intel) and linked against the 10.4 sdk (or even the 10.3 one...) I achieved all of this except for the 10.4 part... = Building the dependencies: = This ended up being trivial with macports: sudo port install jpeg +universal sudo port install lcms +universal sudo port install freetype +universal = Statically linking them when building PIL: = This is trickier -- it turns out that the PIL setup.py already looks in the macports tree for libs. However, gcc prefers dynamic linking, so out of the box, it will dynamically link the dependencies -- fine on your machine, but not re-distributable. I THINK there may be a way to tell gcc, through distutils, to statically link, but it's hard to find. However, if gcc only finds static libs, then it will link those. In this case, I wasn't using macports for anything else on that machine, so what I did is re-name /opt/local/lib, and then create a new one that had only static libs in it. then I just ran setup,py build and presto: all was well. The better way to do this would be to edit the setup.py to point to a place where the static libs are instead of mangling your macports install. One other note about 10.4 -- the last time I tried to build teh deps n a 10.4 machine, I had trouble -- I don't think there are a lot of macports devs on 10.4 any more, so it tends to be buggier. To create the package, run bdist_mpkg, you can get that with easy-install -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 fredrik at pythonware.com Wed May 26 20:35:13 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 26 May 2010 20:35:13 +0200 Subject: [Image-SIG] Loading Imaging 1.1.7 In-Reply-To: References: Message-ID: Looks like the Hair Designer is actually using PIL, but Edward's advice still stands, I think. If the vendor cannot help you (they should), there's another thread in this forum right now about PIL binaries for Mac, complete with links to downloads (look for "PIL binaries -- please test"). Make sure Python and PIL works on their own before trying to run things from inside Poser. On Sun, May 23, 2010 at 4:53 PM, Edward Cannon wrote: > you have posted to the wrong list. this list is about image processing > in the Python programing language. Try contacting the software vendor > for help. > > On Sat, May 22, 2010 at 4:26 PM, Troy Nixon wrote: >> Hello, >> I?ve purchased the Hair Designer Texture Creator for Mac and I?m having >> problems understanding how to add this file to my Poser Program. ?Please >> help. >> Thanks, >> Troy Nixon >> _______________________________________________ >> Image-SIG maillist ?- ?Image-SIG at python.org >> http://mail.python.org/mailman/listinfo/image-sig >> >> > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From fredrik at pythonware.com Wed May 26 21:00:22 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 26 May 2010 21:00:22 +0200 Subject: [Image-SIG] Installing libjpeg In-Reply-To: References: Message-ID: PIL's setup.py script (which uses Python's standard "distutils" build mechanisms) work the same was as the venerable "make" utility (1); that is, if a target exists and is newer than the source files, it's assumed to be correct. This is great when you change only a few source files, but less great when you change the configuration but not the source... Distutils provides a "clean" command that removes old stuff, and there's also a --force option to install that's supposed to force a full rebuild. Looks like neither of these are explained in the generic Python "installing python modules" documentation (2), so I guess I should add something to the README about this. 1) http://en.wikipedia.org/wiki/Make_(software) 2) http://docs.python.org/install/index.html On Sat, May 22, 2010 at 12:29 AM, Mark Twenhafel wrote: > Hi-- > > I just wanted to close out this thread, for the benefit of anyone reading > the archives in the future. > > The problem was solved by following Chris Barker's advice/observation that > the files "site-packages/PIL/_imaging*.so" needed to be deleted and then the > PIL package rebuilt.? That is exactly what I did, and PIL is now working. > The wildcard "_imaging*.so" matched the four shared-object files seen in the > listing, shown in my earlier post.? I deleted those four files and then > rebuilt them by executing "python setup.py install" in the Imaging-1.1.7 > directory. > > Apparently, the install script doesn't delete these files if they already > exist; unfortunately, they had been linked to a version of libjpeg that > didn't work on my box.? Deleting and rebuilding the four "_imaging*.so" > files allowed the new shared-object files to link to the new version of > libjpeg that I had installed, which *does* work on my box. > > Thanks to Chris, and to Fredrik for his earlier assistance.? Hope I haven't > clogged up too much bandwidth with my novice-level approach. > > Mark T. > > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > From seb.haase at gmail.com Thu May 27 09:32:33 2010 From: seb.haase at gmail.com (Sebastian Haase) Date: Thu, 27 May 2010 09:32:33 +0200 Subject: [Image-SIG] Installing libjpeg In-Reply-To: References: Message-ID: On Wed, May 26, 2010 at 9:00 PM, Fredrik Lundh wrote: > PIL's setup.py script (which uses Python's standard "distutils" build > mechanisms) work the same was as the venerable "make" utility (1); > that is, if a target exists and is newer than the source files, it's > assumed to be correct. ?This is great when you change only a few > source files, but less great when you change the configuration but not > the source... > > Distutils provides a "clean" command that removes old stuff, and > there's also a --force option to install that's supposed to force a > full rebuild. ?Looks like neither of these are explained in the > generic Python "installing python modules" documentation (2), so I > guess I should add something to the README about this. Thanks for the info -- maybe someone here is also on the python list and can suggest a note being added to the proper place in (2). - Sebastian Haase > > > > 1) http://en.wikipedia.org/wiki/Make_(software) > 2) http://docs.python.org/install/index.html > From trujillo.dp at gmail.com Thu May 27 07:25:52 2010 From: trujillo.dp at gmail.com (Diego Trujillo) Date: Thu, 27 May 2010 00:25:52 -0500 Subject: [Image-SIG] Python-PIL bug report Message-ID: Hello, I am using PIL to render a view in pyGame and I need to rewrite a buffer image that is loaded to the pygame window after it is rewritten. It works fine but after a while I get this error: Traceback (most recent call last): File "./environmentPYG.py", line 42, in File "ouroborus/birdcageLibrary/pyGameVisual.py", line 40, in generate File "/usr/lib/python2.6/dist-packages/PIL/Image.py", line 1400, in save IOError: [Errno 24] Too many open files: 'buffer.tiff' I am running python 2.6 under Ubuntu 9.10 (Karmic) GNU/Linux. I've checked the reference on line 1400 in save but it does not make any sense to me. I hope this bug report is somewhat useful to you. Thanks. -- Diego Trujillo Pisanty -------------- next part -------------- An HTML attachment was scrubbed... URL: From trujillo.dp at gmail.com Thu May 27 07:29:25 2010 From: trujillo.dp at gmail.com (Diego Trujillo) Date: Thu, 27 May 2010 00:29:25 -0500 Subject: [Image-SIG] Python-PIL bug report (source) Message-ID: I forgot to add my source code on my previous e-mail, the bug is created by the generate function inside the PyGVisual() class found here http://ouroborus.svn.sourceforge.net/viewvc/ouroborus/birdcageLibrary/pyGameVisual.py?view=markup&pathrev=238 and called here: http://ouroborus.svn.sourceforge.net/viewvc/ouroborus/birdcageLibrary/environmentPYG.py?view=markup&pathrev=236 I apologize for the distraction. -- Diego Trujillo Pisanty -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Fri May 28 10:35:10 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 28 May 2010 10:35:10 +0200 Subject: [Image-SIG] Python-PIL bug report In-Reply-To: References: Message-ID: Your operating system has a limit to the amount of files that you can have open in a single program, and the error message simply tells you that you've exceeded this limit. To work around this, you can: -- avoid holding on to the objects returned by Image.open(); either process the data as you go, or make explicit copies of the images (im.copy()). -- have Image.open() read from an opened file object instead of a filename, and explicitly close the file when you've read the data you need: fp = open(filename, "rb") im = PIL.Image.open(fp) im.load() # force loading of the first frame fp.close() # force-close the file On Thu, May 27, 2010 at 7:25 AM, Diego Trujillo wrote: > Hello, > > I am using PIL to render a view in pyGame and I need to rewrite a buffer > image that is loaded to the pygame window after it is rewritten. It works > fine but after a while I get this error: > > Traceback (most recent call last): > ? File "./environmentPYG.py", line 42, in > ? File "ouroborus/birdcageLibrary/pyGameVisual.py", line 40, in generate > ? File "/usr/lib/python2.6/dist-packages/PIL/Image.py", line 1400, in save > IOError: [Errno 24] Too many open files: 'buffer.tiff' > > I am running python 2.6 under Ubuntu 9.10 (Karmic) GNU/Linux. > > I've checked the reference on line 1400 in save but it does not make any > sense to me. I hope this bug report is somewhat useful to you. > > Thanks. > > -- > Diego Trujillo Pisanty > > > > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > From steve.glassman at gmail.com Fri May 28 22:49:51 2010 From: steve.glassman at gmail.com (Steve Glassman) Date: Fri, 28 May 2010 13:49:51 -0700 Subject: [Image-SIG] littleCMS for PIL Message-ID: The new release of littleCMS (2.0 - released May 15, 2010) does not (yet) work with PIL. For now, stick with the latest release in the 1.x series - currently 1.19. Not surprisingly, use of this new release of lcms is not deprecated in the PIL README file. Steve Glassman -------------- next part -------------- An HTML attachment was scrubbed... URL: From simonsez at gmail.com Sat May 29 04:03:16 2010 From: simonsez at gmail.com (Simon Mosk-Aoyama) Date: Fri, 28 May 2010 19:03:16 -0700 Subject: [Image-SIG] broken data stream when reading image file Message-ID: Hello, I'm trying to get PIL to work on my OS X 10.6 box, and unfortunately have ran into some trouble with the JPEG CODEC. I installed the library from port, but when I try to run my application and read a JPEG I get the following error: broken data stream when reading image file Tracing this back to PIL I went to install PIL manually, which seems to succeed: -------------------------------------------------------------------- PIL 1.1.7 SETUP SUMMARY -------------------------------------------------------------------- version 1.1.7 platform darwin 2.6.5 (r265:79063, Apr 17 2010, 18:49:39) [GCC 4.2.1 (Apple Inc. build 5659)] -------------------------------------------------------------------- --- TKINTER support available --- JPEG support available --- ZLIB (PNG/ZIP) support available --- FREETYPE2 support available --- LITTLECMS support available -------------------------------------------------------------------- And yet when I run python selftest.py I get: -------------------------------------------------------------------- PIL 1.1.7 TEST SUMMARY -------------------------------------------------------------------- Python modules loaded from ./PIL Binary modules loaded from /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL -------------------------------------------------------------------- *** PIL CORE support not installed *** TKINTER support not installed --- JPEG support ok --- ZLIB (PNG/ZIP) support ok *** FREETYPE2 support not installed *** LITTLECMS support not installed -------------------------------------------------------------------- Running selftest: ***************************************************************** Failure in example: try: _info(Image.open(os.path.join(ROOT, "Images/lena.jpg"))) except IOError, v: print v from line #24 of selftest.testimage Expected: ('JPEG', 'RGB', (128, 128)) Got: broken data stream when reading image file 1 items had failures: 1 of 57 in selftest.testimage ***Test Failed*** 1 failures. *** 1 tests of 57 failed. So far searches on the error message haven't turned up anything. I'm a little concerned about the PIL_CORE not installed message, should I be? Any ideas? Thanks -Simon From fredrik at pythonware.com Sat May 29 14:51:25 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 29 May 2010 14:51:25 +0200 Subject: [Image-SIG] broken data stream when reading image file In-Reply-To: References: Message-ID: The confusion here is that setup.py reports what it identified, and what parts it told the distutils system to build (expecting distutils to yell if something went wrong), while the selftest.py reports what it actually found for the PIL build it managed to import. Usually, having the first one build things successfully means that the second one will be able to test them successfully, but sometimes, things go wrong on the way (and that seems to be especially likely if you have debris around from earlier build attempts). In your case, when you run the test, the following happens: 1. imports the PIL.Image.py module (which succeeds) this imports some other components, including _imaging (succeeds) 2. imports _imaging again, explicitly (FAILS, which results in the PIL CORE complaint) 3. checks that the _imaging module imported by Image.py has a JPEG codec (succeeds) 4. checks that the _imaging module imported by Image.py has a ZLIB codec (succeeds) 5. checks for a few more support modules, by importing them explicitly (FAILS) 6. tries to use the JPEG module to read a sample file (FAILS) My guess is that the _imaging.so module built by setup.py doesn't work, for some reason, and that Python then goes ahead and imports the one under /opt/local/Library/Frameworks/Python.framework/... instead, which can be imported, but has a broken JPEG module (either that, or the sample file is damaged). You can check this by doing: $ python >>> import sys >>> sys.path.insert(0, ".") >>> from PIL import Image >>> Image.core ... this will tell you from where PIL pulled the _imaging module ... >>> from PIL import _imaging >>> _imaging Let us know if this results in any errors. Also make sure that the Image.core output is the module you built yourself. To check if the sample file is ok, open it in some other program. On Sat, May 29, 2010 at 4:03 AM, Simon Mosk-Aoyama wrote: > Hello, > > I'm trying to get PIL to work on my OS X 10.6 box, and unfortunately > have ran into some trouble with the JPEG CODEC. > > I installed the library from port, but when I try to run my > application and read a JPEG I get the following error: > broken data stream when reading image file > > Tracing this back to PIL I went to install PIL manually, which seems to succeed: > > -------------------------------------------------------------------- > PIL 1.1.7 SETUP SUMMARY > -------------------------------------------------------------------- > version ? ? ? 1.1.7 > platform ? ? ?darwin 2.6.5 (r265:79063, Apr 17 2010, 18:49:39) > ? ? ? ? ? ? ?[GCC 4.2.1 (Apple Inc. build 5659)] > -------------------------------------------------------------------- > --- TKINTER support available > --- JPEG support available > --- ZLIB (PNG/ZIP) support available > --- FREETYPE2 support available > --- LITTLECMS support available > -------------------------------------------------------------------- > > And yet when I run python selftest.py I get: > -------------------------------------------------------------------- > PIL 1.1.7 TEST SUMMARY > -------------------------------------------------------------------- > Python modules loaded from ./PIL > Binary modules loaded from > /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL > -------------------------------------------------------------------- > *** PIL CORE support not installed > *** TKINTER support not installed > --- JPEG support ok > --- ZLIB (PNG/ZIP) support ok > *** FREETYPE2 support not installed > *** LITTLECMS support not installed > -------------------------------------------------------------------- > Running selftest: > ***************************************************************** > Failure in example: > try: > ?_info(Image.open(os.path.join(ROOT, "Images/lena.jpg"))) > except IOError, v: > ?print v > from line #24 of selftest.testimage > Expected: ('JPEG', 'RGB', (128, 128)) > Got: broken data stream when reading image file > 1 items had failures: > ? 1 of ?57 in selftest.testimage > ***Test Failed*** 1 failures. > *** 1 tests of 57 failed. > > So far searches on the error message haven't turned up anything. I'm a > little concerned about the PIL_CORE not installed message, should I > be? > > Any ideas? > > Thanks > > -Simon > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From sedrik at gmail.com Sun May 30 02:55:18 2010 From: sedrik at gmail.com (Andy McCurdy) Date: Sat, 29 May 2010 17:55:18 -0700 Subject: [Image-SIG] PIL Consuming All System Resources Message-ID: Hi, We've been using PIL for the last 2 years to resize our users' uploaded images and have been extremely pleased. Thanks for all your effort. I noticed earlier today that we were experiencing issues of servers running out of memory. It looks like the problem might be within PIL. I've put together a few lines of code below that produce the same behavior. This is the first time we've seen anything like this, and it seems to be a problem with a specific image file (URL included in the code below) being converted to RGB or resized. This is the only image file I've encountered that produces this behavior. And no, I'm not quite sure why a user felt the need to upload a 17M JPG... :) I've tried both PIL 1.1.6 and 1.1.7, and the same behavior occurs on both Ubuntu 8.04 and OS X 10.5. A bug fix would be great, but given the infrequency of seeing this problem, I'd settle for a way to detect whether the image I'm working with will cause PIL issues so that I can avoid it. Thanks! -andy ##### Example Code ##### import StringIO import urllib2 from PIL import Image image_data = urllib2.urlopen(' http://media.giantbomb.com/uploads/8/84310/1291762-img016.jpg').read() io = StringIO.StringIO(image_data) img = Image.open(io) # either of the following two lines causes Python to consume > 2G of memory and not return. converted_img = img.convert('RGB') # or resized_img = img.resize((200, 150), Image.ANTIALIAS) -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Sun May 30 14:59:27 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 30 May 2010 14:59:27 +0200 Subject: [Image-SIG] PIL Consuming All System Resources In-Reply-To: References: Message-ID: The file has mode=RGB size=20400x28079, so you'd need about 2291246400 bytes to load it all into memory at once, and twice that to do e.g. color conversion (which creates a second image memory), so it's a bit on the big side, at least for a 32-bit environment. Note that PIL doesn't actually read the pixels until you do something that needs them, so you can do a sanity check before you proceed; e.g. im = Image.open(...) bytes = im.size[0] * im.size[1] if im.mode not in ("1", "L", "P"): bytes = bytes * 4 # 32-bit storage if bytes > some threshold: raise IOError("sorry, to big for us") # do operation that actually needs the pixels On Sun, May 30, 2010 at 2:55 AM, Andy McCurdy wrote: > Hi, > We've been using PIL for the last 2 years to resize our users' uploaded > images and have been extremely pleased. Thanks for all your effort. > I noticed earlier today that we were experiencing issues of servers running > out of memory. It looks like the problem might be within PIL. I've put > together a few lines of code below that produce the same behavior. This is > the first time we've seen anything like this, and it seems to be a problem > with a specific image file (URL included in the code below) being converted > to RGB or resized. This is the only image file I've encountered that > produces this behavior. And no, I'm not quite sure why a user felt the need > to upload a 17M JPG... :) > I've tried both PIL 1.1.6 and 1.1.7, and the same behavior occurs on both > Ubuntu 8.04 and OS X 10.5. > A bug fix would be great, but given the infrequency of seeing this problem, > I'd settle for a way to detect whether the image I'm working with will cause > PIL issues so that I can avoid it. > Thanks! > -andy > ##### Example Code ##### > import StringIO > import urllib2 > from PIL import Image > image_data = > urllib2.urlopen('http://media.giantbomb.com/uploads/8/84310/1291762-img016.jpg').read() > io = StringIO.StringIO(image_data) > img = Image.open(io) > # either of the following two lines causes Python to consume > 2G of memory > and not return. > converted_img = img.convert('RGB') > # or > resized_img = img.resize((200, 150), Image.ANTIALIAS) > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > From yury at shurup.com Sun May 30 15:36:48 2010 From: yury at shurup.com (Yury V. Zaytsev) Date: Sun, 30 May 2010 15:36:48 +0200 Subject: [Image-SIG] PIL Consuming All System Resources In-Reply-To: References: Message-ID: <1275226609.7617.8.camel@mypride> Hi! On Sun, 2010-05-30 at 14:59 +0200, Fredrik Lundh wrote: > The file has mode=RGB size=20400x28079, so you'd need about 2291246400 > bytes to load it all into memory at once, and twice that to do e.g. > color conversion (which creates a second image memory), so it's a bit > on the big side, at least for a 32-bit environment. I was just about to complain how suboptimal PIL is at loading images, but first tried to load this in eog (which actually did render the image after consuming an insane amount of 1.8 Gb memory) and then in Gimp that was no better :-) I am wondering whether there's a way of performing image transformations without temporarily decoding the whole image in memory... -- Sincerely yours, Yury V. Zaytsev From fredrik at pythonware.com Sun May 30 16:26:48 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 30 May 2010 16:26:48 +0200 Subject: [Image-SIG] PIL Consuming All System Resources In-Reply-To: <1275226609.7617.8.camel@mypride> References: <1275226609.7617.8.camel@mypride> Message-ID: I spent about a decade working on libraries with paging, tiling, and streaming processing architectures. PIL's simple storage model is pretty much a reaction against that. It has worked reasonably well this far :-) However, note that for resizing and some color conversions, the draft & thumbnail operations can do a bunch of tricks to avoid decoding everything; e.g. im.thumbnail((200, 150), Image.ANTIALIAS) only uses 40 MB peak on my machine for that image, and you can use draft to specify a maximum size you're interested in dealing with: >>> im = Image.open("1291762-img016.jpg") >>> im.draft("RGB", (1000, 1000)) >>> im (note that this modifies the image in place, and can only be used directly after open. also note that it doesn't necessarily give you exactly the mode or size you're asking for, and it also doesn't work for all formats) 2010/5/30 Yury V. Zaytsev : > Hi! > > On Sun, 2010-05-30 at 14:59 +0200, Fredrik Lundh wrote: >> The file has mode=RGB size=20400x28079, so you'd need about 2291246400 >> bytes to load it all into memory at once, and twice that to do e.g. >> color conversion (which creates a second image memory), so it's a bit >> on the big side, at least for a 32-bit environment. > > I was just about to complain how suboptimal PIL is at loading images, > but first tried to load this in eog (which actually did render the image > after consuming an insane amount of 1.8 Gb memory) and then in Gimp that > was no better :-) > > I am wondering whether there's a way of performing image > transformations without temporarily decoding the whole image in > memory... > > -- > Sincerely yours, > Yury V. Zaytsev > > From cannon.el at gmail.com Sun May 30 23:59:42 2010 From: cannon.el at gmail.com (Edward Cannon) Date: Sun, 30 May 2010 14:59:42 -0700 Subject: [Image-SIG] PIL Consuming All System Resources In-Reply-To: References: <1275226609.7617.8.camel@mypride> Message-ID: Another method used by many websites is to put a limit on uploaded file size. This has the double benifit of saving on bandwidth as well. Facebook uses 5MB if I recall correctly, and that seems to work really well in practice, large enough to handle most camera files, but small enough to exclude giant images that cause server problems. In some instances you can even preform the file size check pre upload and save your user frustration and headache. Edward Unicorn School On May 30, 2010, at 7:26 AM, Fredrik Lundh wrote: > I spent about a decade working on libraries with paging, tiling, and > streaming processing architectures. PIL's simple storage model is > pretty much a reaction against that. It has worked reasonably well > this far :-) > > However, note that for resizing and some color conversions, the draft > & thumbnail operations can do a bunch of tricks to avoid decoding > everything; e.g. im.thumbnail((200, 150), Image.ANTIALIAS) only uses > 40 MB peak on my machine for that image, and you can use draft to > specify a maximum size you're interested in dealing with: > >>>> im = Image.open("1291762-img016.jpg") >>>> im.draft("RGB", (1000, 1000)) > 0xE18580> >>>> im > 0xE18580> > > (note that this modifies the image in place, and can only be used > directly after open. also note that it doesn't necessarily give you > exactly the mode or size you're asking for, and it also doesn't work > for all formats) > > > > 2010/5/30 Yury V. Zaytsev : >> Hi! >> >> On Sun, 2010-05-30 at 14:59 +0200, Fredrik Lundh wrote: >>> The file has mode=RGB size=20400x28079, so you'd need about 2291246400 >>> bytes to load it all into memory at once, and twice that to do e.g. >>> color conversion (which creates a second image memory), so it's a >>> bit >>> on the big side, at least for a 32-bit environment. >> >> I was just about to complain how suboptimal PIL is at loading images, >> but first tried to load this in eog (which actually did render the >> image >> after consuming an insane amount of 1.8 Gb memory) and then in Gimp >> that >> was no better :-) >> >> I am wondering whether there's a way of performing image >> transformations without temporarily decoding the whole image in >> memory... >> >> -- >> Sincerely yours, >> Yury V. Zaytsev >> >> > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig From yury at shurup.com Mon May 31 08:31:49 2010 From: yury at shurup.com (Yury V. Zaytsev) Date: Mon, 31 May 2010 08:31:49 +0200 Subject: [Image-SIG] PIL Consuming All System Resources In-Reply-To: References: <1275226609.7617.8.camel@mypride> Message-ID: <1275287509.6926.16.camel@mypride> On Sun, 2010-05-30 at 14:59 -0700, Edward Cannon wrote: > Another method used by many websites is to put a limit on uploaded > file size. This has the double benifit of saving on bandwidth as well. > Facebook uses 5MB This is no magic bullet, though. As with ZIP bombs, you can craft a malicious image in such a way, that taking few hundred kilobytes it will still have a giant resolution and when unpacked take many gigabytes of memory to make your server go into swap and die. Hey, by the way... If you don't ulimit your Python processes, that's pretty lame. A single minor mistake / lack of a sanity check in the code and a successful DOS against your server is warranted. -- Sincerely yours, Yury V. Zaytsev From sedrik at gmail.com Mon May 31 07:39:30 2010 From: sedrik at gmail.com (Andy McCurdy) Date: Sun, 30 May 2010 22:39:30 -0700 Subject: [Image-SIG] PIL Consuming All System Resources In-Reply-To: References: Message-ID: Thanks for the explanation. As your and others have suggested, I think limiting the size of the source file seems like a reasonable idea. -andy On Sun, May 30, 2010 at 5:59 AM, Fredrik Lundh wrote: > The file has mode=RGB size=20400x28079, so you'd need about 2291246400 > bytes to load it all into memory at once, and twice that to do e.g. > color conversion (which creates a second image memory), so it's a bit > on the big side, at least for a 32-bit environment. > > Note that PIL doesn't actually read the pixels until you do something > that needs them, so you can do a sanity check before you proceed; e.g. > > im = Image.open(...) > bytes = im.size[0] * im.size[1] > if im.mode not in ("1", "L", "P"): > bytes = bytes * 4 # 32-bit storage > if bytes > some threshold: > raise IOError("sorry, to big for us") > # do operation that actually needs the pixels > > > > On Sun, May 30, 2010 at 2:55 AM, Andy McCurdy wrote: > > Hi, > > We've been using PIL for the last 2 years to resize our users' uploaded > > images and have been extremely pleased. Thanks for all your effort. > > I noticed earlier today that we were experiencing issues of servers > running > > out of memory. It looks like the problem might be within PIL. I've put > > together a few lines of code below that produce the same behavior. This > is > > the first time we've seen anything like this, and it seems to be a > problem > > with a specific image file (URL included in the code below) being > converted > > to RGB or resized. This is the only image file I've encountered that > > produces this behavior. And no, I'm not quite sure why a user felt the > need > > to upload a 17M JPG... :) > > I've tried both PIL 1.1.6 and 1.1.7, and the same behavior occurs on both > > Ubuntu 8.04 and OS X 10.5. > > A bug fix would be great, but given the infrequency of seeing this > problem, > > I'd settle for a way to detect whether the image I'm working with will > cause > > PIL issues so that I can avoid it. > > Thanks! > > -andy > > ##### Example Code ##### > > import StringIO > > import urllib2 > > from PIL import Image > > image_data = > > urllib2.urlopen(' > http://media.giantbomb.com/uploads/8/84310/1291762-img016.jpg').read() > > io = StringIO.StringIO(image_data) > > img = Image.open(io) > > # either of the following two lines causes Python to consume > 2G of > memory > > and not return. > > converted_img = img.convert('RGB') > > # or > > resized_img = img.resize((200, 150), Image.ANTIALIAS) > > _______________________________________________ > > Image-SIG maillist - Image-SIG at python.org > > http://mail.python.org/mailman/listinfo/image-sig > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: