From 289MwF51x@1ranitin.com Wed Nov 24 10:31:41 2010 From: 289MwF51x@1ranitin.com (289MwF51x@1ranitin.com) Date: 24 Nov 10 10:31:41 AM Subject: [IMAGE-SIG] We will mail 4 U Message-ID: LET US DO YOUR BULK MAILINGS!!! ..$250 PER MILLION THE WAY OF THE FUTURE FOR SUCCESS IN YOUR BUSINESS! Our company will do bulk emailing for your product/service. Addresses are extracted daily by four of our computers, which run 24 hours a day 7 days a week, scanning the net for new addresses. They are fresh! Over 36 million addresses on file. No more than 2 pages (50 lines), no porn and no foul language. We do not do targeted mailings at this price. Targeted mailings $150 per 50,000 addresses extracted. There are no lower prices on the net. Your mailing can be done in a matter of hours. We have 4 computers extracting addresses 24/7. For the fastest service, cheapest prices and cleanest mailings call our processing and new accounts office at 904-282-0945, Monday - Friday 9 - 5 EST. If the line is busy, please keep trying, as bulk mailing is growing fast. We do want to work with you to advertise your product. $250 per million expires December 1, 1997. Price increases to $350 per million, $250 per 500,000. All orders received before December 1 will not reflect the increase. Even with the increase, we will still be the best prices on the net. To have your name removed, call our processing office. Any negative responses will be dealt with accordingly. _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From 289MwF51x@1ranitin.com Wed Nov 24 10:31:41 2010 From: 289MwF51x@1ranitin.com (289MwF51x@1ranitin.com) Date: 24 Nov 10 10:31:41 AM Subject: [IMAGE-SIG] We will mail 4 U Message-ID: LET US DO YOUR BULK MAILINGS!!! ..$250 PER MILLION THE WAY OF THE FUTURE FOR SUCCESS IN YOUR BUSINESS! Our company will do bulk emailing for your product/service. Addresses are extracted daily by four of our computers, which run 24 hours a day 7 days a week, scanning the net for new addresses. They are fresh! Over 36 million addresses on file. No more than 2 pages (50 lines), no porn and no foul language. We do not do targeted mailings at this price. Targeted mailings $150 per 50,000 addresses extracted. There are no lower prices on the net. Your mailing can be done in a matter of hours. We have 4 computers extracting addresses 24/7. For the fastest service, cheapest prices and cleanest mailings call our processing and new accounts office at 904-282-0945, Monday - Friday 9 - 5 EST. If the line is busy, please keep trying, as bulk mailing is growing fast. We do want to work with you to advertise your product. $250 per million expires December 1, 1997. Price increases to $350 per million, $250 per 500,000. All orders received before December 1 will not reflect the increase. Even with the increase, we will still be the best prices on the net. To have your name removed, call our processing office. Any negative responses will be dealt with accordingly. _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From 289MwF51x@1ranitin.com Wed Nov 24 10:31:41 2010 From: 289MwF51x@1ranitin.com (289MwF51x@1ranitin.com) Date: 24 Nov 10 10:31:41 AM Subject: [IMAGE-SIG] We will mail 4 U Message-ID: LET US DO YOUR BULK MAILINGS!!! ..$250 PER MILLION THE WAY OF THE FUTURE FOR SUCCESS IN YOUR BUSINESS! Our company will do bulk emailing for your product/service. Addresses are extracted daily by four of our computers, which run 24 hours a day 7 days a week, scanning the net for new addresses. They are fresh! Over 36 million addresses on file. No more than 2 pages (50 lines), no porn and no foul language. We do not do targeted mailings at this price. Targeted mailings $150 per 50,000 addresses extracted. There are no lower prices on the net. Your mailing can be done in a matter of hours. We have 4 computers extracting addresses 24/7. For the fastest service, cheapest prices and cleanest mailings call our processing and new accounts office at 904-282-0945, Monday - Friday 9 - 5 EST. If the line is busy, please keep trying, as bulk mailing is growing fast. We do want to work with you to advertise your product. $250 per million expires December 1, 1997. Price increases to $350 per million, $250 per 500,000. All orders received before December 1 will not reflect the increase. Even with the increase, we will still be the best prices on the net. To have your name removed, call our processing office. Any negative responses will be dealt with accordingly. _______________ IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org _______________ From loz.accs at gmail.com Fri Nov 5 07:16:26 2010 From: loz.accs at gmail.com (loz.accs) Date: Fri, 5 Nov 2010 16:16:26 +1000 Subject: [Image-SIG] PIL and swapping colors Message-ID: Hi, everyone! PIL doesn't provide screenshots making on linux, so I wrote C-extension that uses Imlib2 to grab screenshots in raw RGBA format and returns it to python interpreter. Image object (Image.fromstring) was created successfully, but red and blue colors was swapped. So my question: is there any way to swap colors in image using PIL? And why don't you make linux version of ImageGrab, based on Imlib2 for example? From anders.sandvig at gmail.com Fri Nov 5 11:05:10 2010 From: anders.sandvig at gmail.com (Anders Sandvig) Date: Fri, 5 Nov 2010 11:05:10 +0100 Subject: [Image-SIG] PIL and swapping colors In-Reply-To: References: Message-ID: On Fri, Nov 5, 2010 at 7:16 AM, loz.accs wrote: > [...] > > Image object (Image.fromstring) was created successfully, but red and > blue colors was swapped. > So my question: is there any way to swap colors in image using PIL? My naive (and slow) implementation would be something like this (code not tested): def swap(image): width, height = image.size() res = Image.new("RGBA", (width, height)) data1 = image.load() data2 = res.load() for y in range(height): for x in range(width): r, g, b, a = data1[x, y] data2[x, y] = (b, g, r, a) del image return res However, be aware that even if the format is BGRx on your machine doesn't mean it's the same on a different machine (or even on your machine with a different resolution), as the screen format will depend on the graphics card and driver. Usually the drivers will have a way to tell which format the screen is in (i.e. RGBx or BGRx), so I advice you to check the format and pass this information on to the Python code, or convert it to RGBx before handing the image buffer over to Python. Anders From loz.accs at gmail.com Fri Nov 5 17:55:55 2010 From: loz.accs at gmail.com (loz.accs) Date: Sat, 6 Nov 2010 02:55:55 +1000 Subject: [Image-SIG] PIL and swapping colors In-Reply-To: References: Message-ID: Thanks for reply, Anders! I found Xlib Visual structure that contains color masks. Actually masks was normal RGB: R=0xFF0000, G=0xFF00 and B=0xFF. Swapping R and B masks gave me necessary result. By some strange resons X RGB image converts to PIL BRG image, in Image.fromstring I think, and BRG accordingly to RGB =) Anyway now all screenshot will have the right color masks. 2010/11/5, Anders Sandvig : > On Fri, Nov 5, 2010 at 7:16 AM, loz.accs wrote: >> [...] >> >> Image object (Image.fromstring) was created successfully, but red and >> blue colors was swapped. >> So my question: is there any way to swap colors in image using PIL? > > My naive (and slow) implementation would be something like this (code not > tested): > > def swap(image): > width, height = image.size() > res = Image.new("RGBA", (width, height)) > data1 = image.load() > data2 = res.load() > for y in range(height): > for x in range(width): > r, g, b, a = data1[x, y] > data2[x, y] = (b, g, r, a) > del image > return res > > However, be aware that even if the format is BGRx on your machine doesn't > mean it's the same on a different machine (or even on your machine with a > different resolution), as the screen format will depend on the graphics card > and > driver. > > Usually the drivers will have a way to tell which format the screen is in > (i.e. > RGBx or BGRx), so I advice you to check the format and pass this information > on > to the Python code, or convert it to RGBx before handing the image buffer > over > to Python. > > > Anders > From esbenbugge at gmail.com Sat Nov 6 22:30:55 2010 From: esbenbugge at gmail.com (Esben Bugge) Date: Sat, 6 Nov 2010 22:30:55 +0100 Subject: [Image-SIG] Unable to import _imaging Message-ID: Hi I am trying to install PIL on Mac OS.X 10.6 for the purpose of using Satchmo. After installation I tried $ python >>> import PIL >>> import Image >>> import _imaging Traceback (most recent call last): File "", line 1, in ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so, 2): Symbol not found: _jpeg_resync_to_restart Referenced from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so Expected in: dynamic lookup I believe that jpeglib (version 7) is properly installed: I am able to run the tests that are provided with the source of jpeglib. I am quite new to installing stuff via the command-line. I did a lot of searches on Google and found some guys with the same problem - but I have not been able to find a solution that fixes the problem for me. Any ideas on what I can check? Any help appreciated! -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Sun Nov 7 00:46:31 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 7 Nov 2010 00:46:31 +0100 Subject: [Image-SIG] Unable to import _imaging In-Reply-To: References: Message-ID: On Sat, Nov 6, 2010 at 10:30 PM, Esben Bugge wrote: > Hi > > I am trying to install PIL on Mac OS.X 10.6 for the purpose of using > Satchmo. After installation I tried > > $ python >>>> import PIL >>>> import Image >>>> import _imaging > Traceback (most recent call last): > ? File "", line 1, in > ImportError: > dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so, > 2): Symbol not found: _jpeg_resync_to_restart > ? Referenced from: > /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so > ? Expected in: dynamic lookup > > I believe that jpeglib (version 7) is properly installed: I am able to run > the tests that are provided with the source of jpeglib. > > I am quite new to installing stuff via the command-line. I did a lot of > searches on Google and found some guys with the same problem - but I have > not been able to find a solution that fixes the problem for me. Any ideas on > what I can check? I *think* this is caused by a mismatch between jpeg-6a and jpeg-7 (or 8 or whatever the latest is) -- i.e. your compiler picks up the header files for one of them, but when you run the program, the runtime linker pulls in the other one and gets confused. I know absolutely nothing about the Mac OS X build & execution environment, though, so I don't know where to look for that conflict. The comments to this blog post contain several workarounds that may or may not solve your problem: http://jetfar.com/libjpeg-and-python-imaging-pil-on-snow-leopard/ but for this non-Mac user, compiling stuff on Mac OS X seems to be about as fragile as getting audio stuff to work on Linux :) (This mail list is full of competent Mac hackers, though, so hopefully one of them has more useful advice) From fredrik at pythonware.com Sun Nov 7 00:53:27 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 7 Nov 2010 00:53:27 +0100 Subject: [Image-SIG] Building Imaging 1.1.7 on CentOS 4 x86_64 In-Reply-To: <201010270741.o9R7fugn024394@ruuvi.it.helsinki.fi> References: <201010270741.o9R7fugn024394@ruuvi.it.helsinki.fi> Message-ID: On Wed, Oct 27, 2010 at 9:41 AM, Atro Tossavainen wrote: > Hello, > > I've got libjpeg-devel installed, but doing a > > python setup.py build > > with a Python 2.6.6 install that I made myself, against Imaging 1.1.7, > results in no JPEG support. ?The same process works just fine on i386 > CentOS 4 (also with a custom Python 2.6.6), but not on this x86_64. > > The JpegEncode.o and JpegDecode.o files in build/temp.SOMETHING/libImaging > get created in the process, but contain no symbols. ?The compilation command > > $ gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DHAVE_LIBZ -IlibImaging -I/[PYTHON INSTALL]/include -I/usr/local/include -I/usr/include -I/[PYTHON INSTALL]/include/python2.6 -c libImaging/JpegDecode.c -o build/temp.linux-x86_64-2.6/libImaging/JpegDecode.o > > goes through without errors. ?I'm completely puzzled. > > I would appreciate any help, and explicit personal cc's of any replies > as I am at present not a member of this mailing list. Those two files are always compiled by the current build scripts, but the code is wrapped inside a big #ifdef HAVE_LIBJPEG ... #endif clause to disable them if JPEG support isn't available, so the problem is probably that setup doesn't pick up that you have the jpeg library installed. You can set the ROOT variables in setup.py to point directly to the right libraries. If you want to debug the auto-detection mechanisms, see the code around line 240 or so (search for "jpeglib.h"). Patches for 64-bit CentOS are welcome. From fredrik at pythonware.com Sun Nov 7 00:58:57 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 7 Nov 2010 00:58:57 +0100 Subject: [Image-SIG] Bug: ImageFilter.py GaussianBlur radius not set In-Reply-To: References: Message-ID: On Thu, Oct 7, 2010 at 8:08 PM, Even wrote: > The constructor for GaussianBlur class accepts the argument radius, with > default value 2, > but it does nothing with this argument, and instead hardcodes the radius to > 2. > Below is the code found in PIL 1.1.7: > class GaussianBlur(Filter): > ? ? name = "GaussianBlur" > ? ? def __init__(self, radius=2): > ? ? ? ? self.radius = 2 > ? ? def filter(self, image): > ? ? ? ? return image.gaussian_blur(self.radius) > > > I believe it should be "self.radius = radius" instead. Indeed. Trivial patch here: http://hg.effbot.org/pil-2009-raclette/changeset/ee5c367a6a75 From fredrik at pythonware.com Sun Nov 7 02:02:50 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 7 Nov 2010 02:02:50 +0100 Subject: [Image-SIG] PIL and swapping colors In-Reply-To: References: Message-ID: On Fri, Nov 5, 2010 at 7:16 AM, loz.accs wrote: > Hi, everyone! > PIL doesn't provide screenshots making on linux, so I wrote > C-extension that uses Imlib2 to grab screenshots in raw RGBA format > and returns it to python interpreter. > > Image object (Image.fromstring) was created successfully, but red and > blue colors was swapped. > So my question: is there any way to swap colors in image using PIL? You can pass in a "raw mode" argument to fromstring/frombuffer that tells PIL what "unpacker" to use: >>> Image.frombuffer("RGBA", (1, 1), "\1\2\3\4", "raw", "RGBA", 0, 1).getpixel((0,0)) (1, 2, 3, 4) >>> Image.frombuffer("RGBA", (1, 1), "\1\2\3\4", "raw", "ABGR", 0, 1).getpixel((0,0)) (4, 3, 2, 1) The default mode is the same as the image mode. > And why don't you make linux version of ImageGrab, based on Imlib2 for example? Lack of round tuits, mostly. Contributions are welcome. From fredrik at pythonware.com Sun Nov 7 02:20:54 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 7 Nov 2010 02:20:54 +0100 Subject: [Image-SIG] A question In-Reply-To: References: Message-ID: 2010/10/7 ??? : > I wrote the python script below usind word editor. > > 1. How can I run it as a python script? It seems to be opened as a word > document! As Don said, use a text editor that can produce plain text files. In addition to the ones he mentioned, you can use IDLE which is included in most Python distributions. > 2. Where do I find the xbmc and xbmcgui libraries. Somewhere on http://xbmc.org, most likely. They're not part of Python or PIL, so I assume they're application-specific libraries. Check the XBMC docs for details. From eli_cohen at bezeqint.net Sun Nov 7 07:12:42 2010 From: eli_cohen at bezeqint.net (=?windows-1255?B?4Ozp?=) Date: Sun, 7 Nov 2010 08:12:42 +0200 Subject: [Image-SIG] A question In-Reply-To: Message-ID: <21EE6F912F064D50BE2F24A7639FD9A8@COHEN> IDLE works great, thanks a lot! Regards, Eli Cohen ?????, ??? ??? -----Original Message----- From: fredrik.lundh at gmail.com [mailto:fredrik.lundh at gmail.com] On Behalf Of Fredrik Lundh Sent: Sunday, November 07, 2010 3:21 AM To: ??? Cc: image-sig at python.org Subject: Re: [Image-SIG] A question 2010/10/7 ??? : > I wrote the python script below usind word editor. > > 1. How can I run it as a python script? It seems to be opened as a word > document! As Don said, use a text editor that can produce plain text files. In addition to the ones he mentioned, you can use IDLE which is included in most Python distributions. > 2. Where do I find the xbmc and xbmcgui libraries. Somewhere on http://xbmc.org, most likely. They're not part of Python or PIL, so I assume they're application-specific libraries. Check the XBMC docs for details. From fredrik at pythonware.com Mon Nov 8 10:01:06 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 8 Nov 2010 10:01:06 +0100 Subject: [Image-SIG] Digital Number In-Reply-To: References: Message-ID: On Sun, Sep 19, 2010 at 12:19 PM, wrote: > How to read pixel wise Digital Number (DN) of a JPG image using PIL? You mean "Digital Number" in the ancient GIS sense? I.e. simply the value of a pixel? The simplest way is to use getpixel(pos) where pos is a (x, y) tuple: http://effbot.org/tag/PIL.Image.Image.getpixel If you need to read more than a few pixels, calling load() to get an access object is more efficient: http://effbot.org/tag/PIL.Image.Image.load From fredrik at pythonware.com Mon Nov 8 15:00:13 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 8 Nov 2010 15:00:13 +0100 Subject: [Image-SIG] 64 bit _imaging.so In-Reply-To: <201009271943.16147.don@donvest.org> References: <201009271943.16147.don@donvest.org> Message-ID: On Tue, Sep 28, 2010 at 1:43 AM, Donald Price wrote: > I am now running opensuse 11.3 on an HP computer with i7-860 processor. Have > loaded python 2.6.5 and it works fine except for ?PIL. I can import ?PIL, > Image, and ImageDraw. But when I import ImageFont or try to use Image I get > the error "The _imaging C module is not installed". ?It seems that the PIL I > downloaded is a 32 bit version and I need a 64 bit version. Can you help me? >From where did you download PIL? Have you checked the openSUSE package repositories to see if they have a proper package for your platform? In worst case, you can build your own binaries from source. That's usually pretty straightforward on Linux & Unix platforms; see the README files for details and for the dependencies you need. From Chris.Barker at noaa.gov Mon Nov 8 18:21:37 2010 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Mon, 08 Nov 2010 09:21:37 -0800 Subject: [Image-SIG] Unable to import _imaging In-Reply-To: References: Message-ID: <4CD831A1.7030101@noaa.gov> On 11/6/10 2:30 PM, Esben Bugge wrote: > I am trying to install PIL on Mac OS.X 10.6 for the purpose of using > Satchmo. After installation I tried getting PIL built on OS-X is a bit of a pain. If you want to run it just on your system, the easiest way is to get the dependencies from macports, and then build PIL with those. A note: OS-X generally (always?) hard-codes the path to dependent libs when linking. so you can do: otool -L _imaging.so and you should see what it's linked against. But far easier is to install a binary. Russell Owen has built some, that you can find here: Fredrik: please put these up the PIL site! -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 esbenbugge at gmail.com Mon Nov 8 19:35:08 2010 From: esbenbugge at gmail.com (Esben Bugge) Date: Mon, 8 Nov 2010 19:35:08 +0100 Subject: [Image-SIG] Unable to import _imaging In-Reply-To: <4CD831A1.7030101@noaa.gov> References: <4CD831A1.7030101@noaa.gov> Message-ID: otool -L _imaging.so gave me /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so (architecture ppc): /usr/lib/libmx.A.dylib (compatibility version 1.0.0, current version 315.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0) /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so (architecture i386): /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.0) That doesn't mention anything about jpeg...? Anyway, I used the binaries and now it seems to work just fine :) On 8 November 2010 18:21, Christopher Barker wrote: > On 11/6/10 2:30 PM, Esben Bugge wrote: > >> I am trying to install PIL on Mac OS.X 10.6 for the purpose of using >> Satchmo. After installation I tried >> > > getting PIL built on OS-X is a bit of a pain. If you want to run it just on > your system, the easiest way is to get the dependencies from macports, and > then build PIL with those. > > A note: OS-X generally (always?) hard-codes the path to dependent libs when > linking. so you can do: > > otool -L _imaging.so > > and you should see what it's linked against. > > But far easier is to install a binary. Russell Owen has built some, that > you can find here: > > > > Fredrik: please put these up the PIL site! > > -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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Tue Nov 9 02:01:46 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 9 Nov 2010 02:01:46 +0100 Subject: [Image-SIG] PIL Image array interface has the wrong size for YCbCr In-Reply-To: <1286513509.2785.71.camel@krikkit> References: <1286513509.2785.71.camel@krikkit> Message-ID: Just committed a fix to trunk (including some simple tests for this operation & mode...). Thanks! /F On Fri, Oct 8, 2010 at 6:51 AM, David Coles wrote: > PIL's Image class has incorrect dimension specified for YCbCr images. > This causes issues when converting to or from NumPy arrays. > > According to http://www.pythonware.com/library/pil/handbook/concepts.htm > YCbCr should be "3x8-bit pixels, colour video format". Instead it > appears to be converted to a 4x8-bit format. > > The incorrect definition is at line 206 of > http://svn.effbot.python-hosting.com/pil/PIL/Image.py. > > Example: Load up any image and convert to YCbCr. > >>>> import numpy >>>> import Image as im >>>> image = im.open('bush640x360.png') >>>> ycbcr = image.convert('YCbCr') > > Using the Array interface produces a HxWx4 array, which is the wrong > dimensions for YCbCr. Thus when selecting a single channel it displays > incorrectly: > >>>> A = numpy.asarray(ycbcr) >>>> print A.shape > (360, 640, 4) >>>> im.fromarray(A[:,:,0], "L").show() > > Here's an example decoding the image byte string ourselves gives the > correct result: > >>>> B = numpy.ndarray((image.size[1], image.size[0], 3), 'u1', > ycbcr.tostring()) >>>> print B.shape > (360, 640, 3) >>>> im.fromarray(B[:,:,0], "L").show() > > Attached is a patch against the 1.1.7-2 (python-imaging) package in > Ubuntu as I can't find the development repository for 1.1.7. See > https://bugs.edge.launchpad.net/ubuntu/+source/python-imaging/+bug/656666 for details. > > Cheers, > David > > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > From fredrik at pythonware.com Tue Nov 9 09:34:47 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 9 Nov 2010 09:34:47 +0100 Subject: [Image-SIG] Reading a 8bit Tif image from ArcMAP doesnt read well In-Reply-To: References: Message-ID: On Thu, Oct 28, 2010 at 6:56 PM, German Ocampo wrote: > The issue is that using PIL I get pixel values in the greyscale of 127 > or rgb(0,0,0), where really I could see in Gimp that these pixels have > a different value. Looks like PIL can decode part of the picture and > another part of the picture not. Chris already asked you about this, but I'm asking again -- what are you doing that returns both greyscale and rgb values from the same image? What's the mode of this image, btw? Maybe the confusion here is that it's a palette image (i.e. each 8-bit pixel value is an index into a colour table), and you're working on the index values instead of the colour values. Try replacing your code with im = Image.open(file_tif) im = im.convert("L") # or "RGB" if you want full color values = numpy.asarray(im) and see if the resulting array makes more sense. > Also I tried today to read the pixel values of the picture using > temp=np.array(im) but still I got ?some cells with a value of 127 > where really the image has different values. > > The only way to decode the picture was using freeImagepy, opening the > image with freeImagepy, saving and then open again with PIL to get the > values. It works but not in the way that supose to be. I want to do > all with PIL :-) > ?(Attached is the code) > > Many thanks > > German > > ? ?from PIL import Image > ? ?from PIL import TiffImagePlugin > ? ?import numpy as np > ? ?import sys > ? ?import FreeImagePy > ? ?FIPY = FreeImagePy.freeimage() > ? ?image = FIPY.genericLoader(file_tif) > ? ?FIPY.Save(FreeImagePy.FIF_TIFF, image, "temp.tif") > > ? im = Image.open("temp.tif") > ? values=np.zeros((size_y,size_x)) > ? mode=im.mode > ? temp=list(im.getdata()) > ? cont=-1 > ? list_colors=[] > ? for i in range(0,size_y): > ? ? ? for j in range(0,size_x): > ? ? ? ? ? cont+=1 > ? ? ? ? ? if mode=="RGB": > ? ? ? ? ? ? ? color=temp[cont] > ? ? ? ? ? ? ? print cont,temp[cont] > ? ? ? ? ? ? ? if color in list_colors: > ? ? ? ? ? ? ? ? ? index=list_colors.index(color) > ? ? ? ? ? ? ? ? ? values[i][j]=index+1 > ? ? ? ? ? ? ? else: > ? ? ? ? ? ? ? ? ? list_colors.append(color) > ? ? ? ? ? ? ? ? ? values[i][j]=len(list_colors) > ? ? ? ? ? else: > ? ? ? ? ? ? ? values[i][j]=temp[cont] > > On Thu, Oct 28, 2010 at 4:26 PM, Chris Mitchell wrote: >> Why would the image go between greyscale and rgb? ?In anycase, perhaps >> the easiest solution is use np.resize on temp instead of the for >> loops. ?Then if you have tuples of rgb versus ints you can use >> np.where() >> >> On Thu, Oct 28, 2010 at 4:36 AM, German Ocampo wrote: >>> Good morning >>> >>> Im reading an 8bit image generated by ArcMap using PIL in windows, the >>> image load well without error messages but, when I try to extract the >>> values to a numpy array I got some lines of the image with value of >>> pixel 127 (greyscale) or rgb(0,0,0). When I open the image using GIMP >>> or arcmap ?I could see that the image is complete. >>> >>> Any idea of what is happening?? >>> >>> the code that I'm using for read the image is: >>> >>> ? ? from PIL import Image >>> ? ? from PIL import TiffImagePlugin >>> ? ?import numpy as np >>> ? ?import sys >>> ? ?im = Image.open(file_tif) >>> ? ?values=np.zeros((size_y,size_x)) >>> ? ?mode=im.mode >>> ? ?temp=list(im.getdata()) >>> ? ?cont=-1 >>> ? ?list_colors=[] >>> ? ?for i in range(0,size_y): >>> ? ? ? ?for j in range(0,size_x): >>> ? ? ? ? ? ?cont+=1 >>> ? ? ? ? ? ?if mode=="RGB": >>> ? ? ? ? ? ? ? ?color=temp[cont] >>> ? ? ? ? ? ? ? ?print cont,temp[cont] >>> ? ? ? ? ? ? ? ?if color in list_colors: >>> ? ? ? ? ? ? ? ? ? ?index=list_colors.index(color) >>> ? ? ? ? ? ? ? ? ? ?values[i][j]=index+1 >>> ? ? ? ? ? ? ? ?else: >>> ? ? ? ? ? ? ? ? ? ?list_colors.append(color) >>> ? ? ? ? ? ? ? ? ? ?values[i][j]=len(list_colors) >>> ? ? ? ? ? ?else: >>> ? ? ? ? ? ? ? ?values[i][j]=temp[cont] >>> >>> Best regards >>> >>> German >>> _______________________________________________ >>> 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 Tue Nov 9 09:39:55 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 9 Nov 2010 09:39:55 +0100 Subject: [Image-SIG] Read SVG files - extracting the path In-Reply-To: <32268588.1286557192780.JavaMail.root@viefep18> References: <32268588.1286557192780.JavaMail.root@viefep18> Message-ID: On Fri, Oct 8, 2010 at 6:59 PM, Sebastian Koblinger wrote: > Hi everybody! > > I'm new to Python as well as to this mailing list and this is my question: > > Is it possible to read a path provided by an SVG file, and based on that path, make a selection of an image? > (Further I'd like to invert the selection and fill it with black.) > > Is that doable with PIL? > > AFAIK ImagePath can create a path object, but is there a function, a module, or anything else that reads the path of the SVG directly? > I rawly could imagine to read the SVG as a text file, scan it for the "path" argument, read the subsequent tuples and make them a path object. You want an XML library (you could use e.g. xml.etree or lxml) to read the SVG file itself. Converting an SVG path to an image mask is a bit trickier, depending on how many SVG features you want to support -- SVG paths support both straight line segments and various curves. The aggdraw add-on to PIL (http://effbot.org/zone/aggdraw-index.htm) might be a better choice than ImagePath; I'm not aware of any ready made SVG to raster converter built on these tools, though. Yet another alternative would be to look for some SVG rendering tool, beyond GIMP. No good pointers there, though, but maybe some other image-sig:ers have some ideas. From fredrik at pythonware.com Tue Nov 9 09:47:57 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 9 Nov 2010 09:47:57 +0100 Subject: [Image-SIG] How to change size of PIL fonts? In-Reply-To: References: Message-ID: On Tue, Oct 12, 2010 at 1:31 PM, D?vji Chh?ng? wrote: > Hello Image-SIG, > I am a newbie to PIL, I have following code > > ??? def __setFont (self, filename): > ??? ??? pilfont = ImageFont.load(filename) > ??? ??? return pilfont > > ??? def drawImage (self): > ??? ??? cg = CaptchaString(4) > ??? ??? myString = cg.getString() #Some other object to get string from > ??? ??? myFont = self.__setFont('E:\\pilfonts\\timB12.pil') > > ??? ??? img = Image.new('RGB', (220,90), '#FFFFFF') > > ??? ??? drawText = ImageDraw.Draw(img) > ??? ??? drawText.text((6, 0), myCaptchaString, font=myFont, fill=(255, 100, > 25)) > > ??? ??? img.save('myFile.png', 'PNG') > > I don't know how to set font size so that it appear larger The "pil" fonts are simple raster fonts that have a fixed size. To get more flexible font scaling, you want to use TrueType fonts instead. From fredrik at pythonware.com Tue Nov 9 09:52:16 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 9 Nov 2010 09:52:16 +0100 Subject: [Image-SIG] Hi I have problems with tif files In-Reply-To: <1285133066.4135.5.camel@rajan-laptop> References: <1285133066.4135.5.camel@rajan-laptop> Message-ID: On Wed, Sep 22, 2010 at 7:24 AM, Rajan Gurjar wrote: > Image.open('filename') and im.info gives the following > > (640, 480) > {'resolution': (1, 1), 'compression': 'raw'} > F;32BF Where did the "F;32BF" come from? > TIFF > > > But when I run the im.show() it gives the following error. >>>> im.show() > Traceback (most recent call last): > ?File "", line 1, in > ? ?im.show() > ?File "/usr/lib/python2.6/dist-packages/PIL/Image.py", line 1483, in > show > ? ?_show(self, title=title, command=command) > ?File "/usr/lib/python2.6/dist-packages/PIL/Image.py", line 2123, in > _show > ? ?apply(_showxv, (image,), options) > ?File "/usr/lib/python2.6/dist-packages/PIL/Image.py", line 2127, in > _showxv > ? ?apply(ImageShow.show, (image, title), options) > ?File "/usr/lib/python2.6/dist-packages/PIL/ImageShow.py", line 41, in > show > ? ?if viewer.show(image, title=title, **options): > ?File "/usr/lib/python2.6/dist-packages/PIL/ImageShow.py", line 62, in > show > ? ?base = Image.getmodebase(image.mode) > ?File "/usr/lib/python2.6/dist-packages/PIL/Image.py", line 245, in > getmodebase > ? ?return ImageMode.getmode(mode).basemode > ?File "/usr/lib/python2.6/dist-packages/PIL/ImageMode.py", line 50, in > getmode > ? ?return _modes[mode] > KeyError: 'F;32BF' > > I have no idea why this happens. > I will appreciate your response. The file opens with ImageJ and > ImageMagick. It is a 8-bit RGB file. Are you sure it's 8-bit? (F;32BF indicates otherwise) What's the mode attribute set to for this image? What happens if you convert to grayscale (mode L) before displaying it? From donn.ingle at gmail.com Tue Nov 9 11:51:27 2010 From: donn.ingle at gmail.com (donn) Date: Tue, 09 Nov 2010 12:51:27 +0200 Subject: [Image-SIG] Read SVG files - extracting the path In-Reply-To: References: <32268588.1286557192780.JavaMail.root@viefep18> Message-ID: <4CD927AF.9010006@gmail.com> On 09/11/2010 10:39, Fredrik Lundh wrote: > Yet another alternative would be to look for some SVG rendering tool Have a look at python-cairo and python-rsvg. Rsvg on its own will render an svg (or any svg xml string passed, you can also specify by id) to an image. Cairo comes in when you want to do more custom stuff. To get an actual image file out of rsvg ... I'm rusty, but you'd need a Cairo context that gets rendered-into (by rsvg) and then you'd save that context to a file. OTOH, you can use Inkscape's command-line to fetch and render and chop and dice and flip and spin .... \d From fredrik at pythonware.com Tue Nov 9 14:55:57 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 9 Nov 2010 14:55:57 +0100 Subject: [Image-SIG] Problem with psd and Alpha In-Reply-To: <29B87C47-3DB1-4C11-A880-85814C3455B3@gmail.com> References: <29B87C47-3DB1-4C11-A880-85814C3455B3@gmail.com> Message-ID: On Thu, Aug 5, 2010 at 10:42 AM, Martino Massalini wrote: > Hi, i'm tryng to composite several psd coming from my render software. > Each one is a psd with ?the same size of the others and an alpha channel. > The problem is when i do > > im = Image.open("filepath") > > I alway get a "RGB" image instead of "RGBA" so i can't use the alpha channel > as mask when i compose the image. > > Here some snippet: > >>>> im = Image.open("prova0000.psd") >>>> im.mode > 'RGB' >>>> im.split() > Traceback (most recent call last): > ?File "", line 1, in > ?File "/Library/Python/2.5/site-packages/PIL/Image.py", line 1497, in split > ? ?if self.im.bands == 1: > AttributeError: 'NoneType' object has no attribute 'bands' This is a bug in PIL 1.1.7 that affects all file formats; fix here: http://hg.effbot.org/pil-2009-raclette/changeset/fb7ce579f5f9 >>>> repr(im.im) > 'None' >>>> im.load() > >>>> repr(im.im) > '' >>>> im.split() > (, mode=L size=146x90 at 0x42C828>, 0x42C940>) I think the problem here is that the PSD format stores the alpha in a separate layer, that's not recognized by the PSD loader. If you mail me a sample image, I can check if there's an easy fix for this issue. From yury at shurup.com Tue Nov 9 18:09:01 2010 From: yury at shurup.com (Yury V. Zaytsev) Date: Tue, 09 Nov 2010 18:09:01 +0100 Subject: [Image-SIG] Read SVG files - extracting the path In-Reply-To: <4CD927AF.9010006@gmail.com> References: <32268588.1286557192780.JavaMail.root@viefep18> <4CD927AF.9010006@gmail.com> Message-ID: <1289322541.8025.5.camel@mypride> On Tue, 2010-11-09 at 12:51 +0200, donn wrote: > OTOH, you can use Inkscape's command-line to fetch and render and chop > and dice and flip and spin .... Or even Apache Batik which managed to rasterize my SVG files in finite time and with finite memory consumption that made Inkscape dump core... -- Sincerely yours, Yury V. Zaytsev From coles.david at gmail.com Wed Nov 10 00:08:28 2010 From: coles.david at gmail.com (David Coles) Date: Wed, 10 Nov 2010 10:08:28 +1100 Subject: [Image-SIG] PIL Image array interface has the wrong size for YCbCr In-Reply-To: References: <1286513509.2785.71.camel@krikkit> Message-ID: <1289344108.2539.15.camel@krikkit> Nice! Is http://hg.effbot.org/pil-2009-raclette the current trunk? There seems to be a bit of confusion of which is the current repository. Quite handy when trying to write patches. The ones I've seen are: http://effbot.org/zone/pil-index.htm links to http://svn.effbot.python-hosting.com/pil/ http://effbot.org/downloads/#imaging links to http://svn.effbot.org/public/tags/pil-1.1.7 http://hg.effbot.org/pil-2009-raclette (and the pil-117 fork) seems to be the most up to date. Cheers, David On Tue, 2010-11-09 at 02:01 +0100, Fredrik Lundh wrote: > Just committed a fix to trunk (including some simple tests for this > operation & mode...). > > Thanks! /F -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part URL: From fredrik at pythonware.com Wed Nov 10 04:09:49 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 10 Nov 2010 04:09:49 +0100 Subject: [Image-SIG] PIL Image array interface has the wrong size for YCbCr In-Reply-To: <1289344108.2539.15.camel@krikkit> References: <1286513509.2785.71.camel@krikkit> <1289344108.2539.15.camel@krikkit> Message-ID: On Wed, Nov 10, 2010 at 12:08 AM, David Coles wrote: > Nice! > > Is http://hg.effbot.org/pil-2009-raclette the current trunk? There seems > to be a bit of confusion of which is the current repository. Quite handy > when trying to write patches. > > The ones I've seen are: > > http://effbot.org/zone/pil-index.htm links to > http://svn.effbot.python-hosting.com/pil/ Ouch, that's ancient. I thought that repository was deleted ages ago. I'll fix the link asap, and figure out if I can get the python-hosting folks to nuke the repo. > http://effbot.org/downloads/#imaging links to > http://svn.effbot.org/public/tags/pil-1.1.7 That's a SVN snapshot of the latest release, for SVN users. > http://hg.effbot.org/pil-2009-raclette (and the pil-117 fork) seems to > be the most up to date. Yeah, the raclette HG repo is where the action is. I agree that the name is a bit confusing... :) From gora at mimirtech.com Thu Nov 11 05:48:54 2010 From: gora at mimirtech.com (Gora Mohanty) Date: Thu, 11 Nov 2010 10:18:54 +0530 Subject: [Image-SIG] [OT] Commercial support for PIL Message-ID: Hi, We would like to request commercial support for PIL. We have been using PIL in a Django project, and have been happy with it, except that we have been encountering issues with support for newer .TIF files. Currently, we have encountered such an issue with: * 16 bit-per-channel .TIFF files * .TIF files that have unsupported compression schemes (AdobeDeflate), plus some other unsupported features that we do not fully understand. Our client would most likely be willing to pay for adding such support to PIL, provided that we could be assured that such support would be added in a timely manner. My apologies for posting this to the list, but I am not getting a response to multiple queries sent to the address noted on the page for PIL commercial support: http://www.pythonware.com/products/pil/support.htm . I would very much appreciate it if someone frm PIL commercial support would contact me off-list. Regards, Gora From pascalclausen at hotmail.com Thu Nov 11 06:03:19 2010 From: pascalclausen at hotmail.com (Pascal Clausen) Date: Thu, 11 Nov 2010 06:03:19 +0100 Subject: [Image-SIG] stuckin installing PIL Message-ID: Hi, I tried to install PIL but did not succeeded. I have windows 7, 64 bits. If I upload Python Imaging library 1.1.7 for Python 2.6, I have a message error saying "Python version 2.6 required, which was not found in the registy", whereas I have it in C:/Python26/. If I download the source kit on my C:/Imaging-1.1.7/, and type "python ../Imaging-1.17/setup.py install" I have an error message saying "Unable to find vcvarsall.bat" (I have Microsoft VIdeo Studio 2010 installed). I do not know what to do. Could you help me with that? Thanks a lot for your reply, Pascal -------------- next part -------------- An HTML attachment was scrubbed... URL: From cannon.el at gmail.com Thu Nov 11 23:05:03 2010 From: cannon.el at gmail.com (Edward Cannon) Date: Thu, 11 Nov 2010 14:05:03 -0800 Subject: [Image-SIG] stuckin installing PIL In-Reply-To: References: Message-ID: <6863B26F-4533-45F2-AEAB-45F35B311FFF@gmail.com> Try using 1.1.6 instead. I did that and had no problems at all. Are you using the right bit type 64bit PIL with 64bit python or are you using 32 bit PIL with 64 bit python, which doesn't work. Edward Unicorn School On Nov 10, 2010, at 9:03 PM, Pascal Clausen wrote: > Hi, > > I tried to install PIL but did not succeeded. I have windows 7, 64 bits. If I upload Python Imaging library 1.1.7 for Python 2.6, I have a message error saying "Python version 2.6 required, which was not found in the registy", whereas I have it in C:/Python26/. If I download the source kit on my C:/Imaging-1.1.7/, and type "python ../Imaging-1.17/setup.py install" I have an error message saying "Unable to find vcvarsall.bat" (I have Microsoft VIdeo Studio 2010 installed). I do not know what to do. Could you help me with that? > > Thanks a lot for your reply, > Pascal > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig From bing.jian at gmail.com Thu Nov 11 22:49:57 2010 From: bing.jian at gmail.com (Bing Jian) Date: Thu, 11 Nov 2010 16:49:57 -0500 Subject: [Image-SIG] Dashed Lines in PIL Message-ID: Hi all, Anyone knows how to draw dashed lines in PIL. Just did not find anything related from the online PIL handbook. Thanks, Bing -------------- next part -------------- An HTML attachment was scrubbed... URL: From bharathwaaj.s at gmail.com Fri Nov 12 19:30:20 2010 From: bharathwaaj.s at gmail.com (Bharathwaaj Srinivasan) Date: Sat, 13 Nov 2010 00:00:20 +0530 Subject: [Image-SIG] import ICCProfile Error Message-ID: Hi, I keep getting error in import ICCProfile in PNGImagePlugin.py _save. What am I missing? Which package contains ICCProfile? I've been searching but couldn't get a clue on why it is failing. The support was added as mentioned here: http://mail.python.org/pipermail/image-sig/2009-March/005460.html Kind regards, Bharath -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Fri Nov 12 21:34:48 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 12 Nov 2010 21:34:48 +0100 Subject: [Image-SIG] import ICCProfile Error In-Reply-To: References: Message-ID: On Fri, Nov 12, 2010 at 7:30 PM, Bharathwaaj Srinivasan wrote: > I keep getting error in import ICCProfile in PNGImagePlugin.py _save. > > What am I missing? Which package contains ICCProfile? Not sure why that code was left in there, but iirc it's an extension hook. > I've been searching but couldn't get a clue on why it is failing. Me neither, given that the import is protected by a try/except. try: import ICCProfile except ImportError: ... What exactly are you doing when you get this import error, and what does the full traceback look like? From bharathwaaj.s at gmail.com Fri Nov 12 22:33:34 2010 From: bharathwaaj.s at gmail.com (Bharathwaaj Srinivasan) Date: Sat, 13 Nov 2010 03:03:34 +0530 Subject: [Image-SIG] import ICCProfile Error In-Reply-To: References: Message-ID: I'm trying to get the images-demo working for google appengine. http://code.google.com/p/google-app-engine-samples/source/browse/trunk/images-demo The full traceback can be found here: http://pastebin.com/cBn6cA0V Kind regards, Bharath On 13 November 2010 02:04, Fredrik Lundh wrote: > On Fri, Nov 12, 2010 at 7:30 PM, Bharathwaaj Srinivasan > wrote: > > I keep getting error in import ICCProfile in PNGImagePlugin.py _save. > > > > What am I missing? Which package contains ICCProfile? > > Not sure why that code was left in there, but iirc it's an extension hook. > > > I've been searching but couldn't get a clue on why it is failing. > > Me neither, given that the import is protected by a try/except. > > try: > import ICCProfile > except ImportError: > ... > > What exactly are you doing when you get this import error, and what > does the full traceback look like? > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Sat Nov 13 14:40:42 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 13 Nov 2010 14:40:42 +0100 Subject: [Image-SIG] import ICCProfile Error In-Reply-To: References: Message-ID: On Fri, Nov 12, 2010 at 10:33 PM, Bharathwaaj Srinivasan wrote: > I'm trying to get the images-demo working for google appengine. > > http://code.google.com/p/google-app-engine-samples/source/browse/trunk/images-demo > > The full traceback can be found here: > > http://pastebin.com/cBn6cA0V Hmm. First time I've ever seen that error in any context. Looks like GAE's import mechanisms cause some trouble for relative imports that won't happen if you run things stand-alone. And it looks like PIL's far from the only library suffering from this: http://www.google.com/search?q=%22SystemError:+Parent+module+*+not+loaded%22 even if most PIL reports I found seem to be for GAE. My guess is that it's some misfeature in the changes to relative import that was introduced in 2.6 (iirc), but since it doesn't happen when you run PIL in a normal configuration, I'm not sure how to debug it. If someone can come up with a simple test case that triggers this, let me know. I guess this also means that adding an ICCProfile module to the path won't help you; if you cannot figure out something better, you might have to comment out the problematic code (or you could try replacing the relative import with a "from PIL import" and see if that helps). > On 13 November 2010 02:04, Fredrik Lundh wrote: >> >> On Fri, Nov 12, 2010 at 7:30 PM, Bharathwaaj Srinivasan >> wrote: >> > I keep getting error in import ICCProfile in PNGImagePlugin.py _save. >> > >> > What am I missing? Which package contains ICCProfile? >> >> Not sure why that code was left in there, but iirc it's an extension hook. >> >> > I've been searching but couldn't get a clue on why it is failing. >> >> Me neither, given that the import is protected by a try/except. >> >> ? try: >> ? ? ? import ICCProfile >> ? except ImportError: >> ? ? ? ... >> >> What exactly are you doing when you get this import error, and what >> does the full traceback look like? >> >> > > From fredrik at pythonware.com Sat Nov 13 15:17:54 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 13 Nov 2010 15:17:54 +0100 Subject: [Image-SIG] import ICCProfile Error In-Reply-To: References: Message-ID: By the way, I'm pretty sure that this only happens for some PNG images, and once you upload your application, PNG reading is done by GAE:s image library, not PIL, so the application you're building should be fine. On Sat, Nov 13, 2010 at 2:40 PM, Fredrik Lundh wrote: > On Fri, Nov 12, 2010 at 10:33 PM, Bharathwaaj Srinivasan > wrote: >> I'm trying to get the images-demo working for google appengine. >> >> http://code.google.com/p/google-app-engine-samples/source/browse/trunk/images-demo >> >> The full traceback can be found here: >> >> http://pastebin.com/cBn6cA0V > > Hmm. First time I've ever seen that error in any context. ?Looks like > GAE's import mechanisms cause some trouble for relative imports that > won't happen if you run things stand-alone. ?And it looks like PIL's > far from the only library suffering from this: > > http://www.google.com/search?q=%22SystemError:+Parent+module+*+not+loaded%22 > > even if most PIL reports I found seem to be for GAE. ?My guess is that > it's some misfeature in the changes to relative import that was > introduced in 2.6 (iirc), but since it doesn't happen when you run PIL > in a normal configuration, I'm not sure how to debug it. ?If someone > can come up with a simple test case that triggers this, let me know. > > I guess this also means that adding an ICCProfile module to the path > won't help you; if you cannot figure out something better, you might > have to comment out the problematic code (or you could try replacing > the relative import with a "from PIL import" and see if that helps). > > > >> On 13 November 2010 02:04, Fredrik Lundh wrote: >>> >>> On Fri, Nov 12, 2010 at 7:30 PM, Bharathwaaj Srinivasan >>> wrote: >>> > I keep getting error in import ICCProfile in PNGImagePlugin.py _save. >>> > >>> > What am I missing? Which package contains ICCProfile? >>> >>> Not sure why that code was left in there, but iirc it's an extension hook. >>> >>> > I've been searching but couldn't get a clue on why it is failing. >>> >>> Me neither, given that the import is protected by a try/except. >>> >>> ? try: >>> ? ? ? import ICCProfile >>> ? except ImportError: >>> ? ? ? ... >>> >>> What exactly are you doing when you get this import error, and what >>> does the full traceback look like? >>> >>> >> >> > From fredrik at pythonware.com Sun Nov 14 04:44:18 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 14 Nov 2010 04:44:18 +0100 Subject: [Image-SIG] import ICCProfile Error In-Reply-To: References: Message-ID: So after digging a bit further, the suspect is the auto-reload mechanisms in GAE's development appserver -- the appserver attempts to clear out all imported modules in sys.modules when it detects changes to your application code, and that process apparently leaves the PIL modules in a half-baked state (i.e. "PIL" has been removed, but code for "PIL.PngImagePlugin" is still around). You're not importing PIL code directly, are you? On Sat, Nov 13, 2010 at 3:17 PM, Fredrik Lundh wrote: > By the way, I'm pretty sure that this only happens for some PNG > images, and once you upload your application, PNG reading is done by > GAE:s image library, not PIL, so the application you're building > should be fine. > > > > On Sat, Nov 13, 2010 at 2:40 PM, Fredrik Lundh wrote: >> On Fri, Nov 12, 2010 at 10:33 PM, Bharathwaaj Srinivasan >> wrote: >>> I'm trying to get the images-demo working for google appengine. >>> >>> http://code.google.com/p/google-app-engine-samples/source/browse/trunk/images-demo >>> >>> The full traceback can be found here: >>> >>> http://pastebin.com/cBn6cA0V >> >> Hmm. First time I've ever seen that error in any context. ?Looks like >> GAE's import mechanisms cause some trouble for relative imports that >> won't happen if you run things stand-alone. ?And it looks like PIL's >> far from the only library suffering from this: >> >> http://www.google.com/search?q=%22SystemError:+Parent+module+*+not+loaded%22 >> >> even if most PIL reports I found seem to be for GAE. ?My guess is that >> it's some misfeature in the changes to relative import that was >> introduced in 2.6 (iirc), but since it doesn't happen when you run PIL >> in a normal configuration, I'm not sure how to debug it. ?If someone >> can come up with a simple test case that triggers this, let me know. >> >> I guess this also means that adding an ICCProfile module to the path >> won't help you; if you cannot figure out something better, you might >> have to comment out the problematic code (or you could try replacing >> the relative import with a "from PIL import" and see if that helps). >> >> >> >>> On 13 November 2010 02:04, Fredrik Lundh wrote: >>>> >>>> On Fri, Nov 12, 2010 at 7:30 PM, Bharathwaaj Srinivasan >>>> wrote: >>>> > I keep getting error in import ICCProfile in PNGImagePlugin.py _save. >>>> > >>>> > What am I missing? Which package contains ICCProfile? >>>> >>>> Not sure why that code was left in there, but iirc it's an extension hook. >>>> >>>> > I've been searching but couldn't get a clue on why it is failing. >>>> >>>> Me neither, given that the import is protected by a try/except. >>>> >>>> ? try: >>>> ? ? ? import ICCProfile >>>> ? except ImportError: >>>> ? ? ? ... >>>> >>>> What exactly are you doing when you get this import error, and what >>>> does the full traceback look like? >>>> >>>> >>> >>> >> > From fredrik at pythonware.com Sun Nov 14 17:56:24 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 14 Nov 2010 17:56:24 +0100 Subject: [Image-SIG] import ICCProfile Error In-Reply-To: References: Message-ID: On Sun, Nov 14, 2010 at 3:46 PM, Bharathwaaj Srinivasan wrote: > Hi, > > I tried from the command line. Still getting error. Please see the log. > > bharath at bharath-laptop:~/workspace/webKit$ python2.5 > Python 2.5.5 (r255:77872, Nov? 3 2010, 13:18:19) > [GCC 4.4.5] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> import PIL >>>> import ICCProfile > Traceback (most recent call last): > ? File "", line 1, in > ImportError: No module named ICCProfile >>>> from PIL import ICCProfile > Traceback (most recent call last): > ? File "", line 1, in > ImportError: cannot import name ICCProfile >>>> That's irrelevant -- in the PNG module, the import is wrapped inside a try/except statement. The problem is that the try/except expects an ImportError (which you'e seeing), not a SystemError (which is what happens inside GAE). From bharathwaaj.s at gmail.com Sun Nov 14 15:46:13 2010 From: bharathwaaj.s at gmail.com (Bharathwaaj Srinivasan) Date: Sun, 14 Nov 2010 20:16:13 +0530 Subject: [Image-SIG] import ICCProfile Error In-Reply-To: References: Message-ID: Hi, I tried from the command line. Still getting error. Please see the log. bharath at bharath-laptop:~/workspace/webKit$ python2.5 Python 2.5.5 (r255:77872, Nov 3 2010, 13:18:19) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import PIL >>> import ICCProfile Traceback (most recent call last): File "", line 1, in ImportError: No module named ICCProfile >>> from PIL import ICCProfile Traceback (most recent call last): File "", line 1, in ImportError: cannot import name ICCProfile >>> Kind regards, Bharath On 14 November 2010 09:14, Fredrik Lundh wrote: > So after digging a bit further, the suspect is the auto-reload > mechanisms in GAE's development appserver -- the appserver attempts to > clear out all imported modules in sys.modules when it detects changes > to your application code, and that process apparently leaves the PIL > modules in a half-baked state (i.e. "PIL" has been removed, but code > for "PIL.PngImagePlugin" is still around). > > You're not importing PIL code directly, are you? > > > > On Sat, Nov 13, 2010 at 3:17 PM, Fredrik Lundh > wrote: > > By the way, I'm pretty sure that this only happens for some PNG > > images, and once you upload your application, PNG reading is done by > > GAE:s image library, not PIL, so the application you're building > > should be fine. > > > > > > > > On Sat, Nov 13, 2010 at 2:40 PM, Fredrik Lundh > wrote: > >> On Fri, Nov 12, 2010 at 10:33 PM, Bharathwaaj Srinivasan > >> wrote: > >>> I'm trying to get the images-demo working for google appengine. > >>> > >>> > http://code.google.com/p/google-app-engine-samples/source/browse/trunk/images-demo > >>> > >>> The full traceback can be found here: > >>> > >>> http://pastebin.com/cBn6cA0V > >> > >> Hmm. First time I've ever seen that error in any context. Looks like > >> GAE's import mechanisms cause some trouble for relative imports that > >> won't happen if you run things stand-alone. And it looks like PIL's > >> far from the only library suffering from this: > >> > >> > http://www.google.com/search?q=%22SystemError:+Parent+module+*+not+loaded%22 > >> > >> even if most PIL reports I found seem to be for GAE. My guess is that > >> it's some misfeature in the changes to relative import that was > >> introduced in 2.6 (iirc), but since it doesn't happen when you run PIL > >> in a normal configuration, I'm not sure how to debug it. If someone > >> can come up with a simple test case that triggers this, let me know. > >> > >> I guess this also means that adding an ICCProfile module to the path > >> won't help you; if you cannot figure out something better, you might > >> have to comment out the problematic code (or you could try replacing > >> the relative import with a "from PIL import" and see if that helps). > >> > >> > >> > >>> On 13 November 2010 02:04, Fredrik Lundh > wrote: > >>>> > >>>> On Fri, Nov 12, 2010 at 7:30 PM, Bharathwaaj Srinivasan > >>>> wrote: > >>>> > I keep getting error in import ICCProfile in PNGImagePlugin.py > _save. > >>>> > > >>>> > What am I missing? Which package contains ICCProfile? > >>>> > >>>> Not sure why that code was left in there, but iirc it's an extension > hook. > >>>> > >>>> > I've been searching but couldn't get a clue on why it is failing. > >>>> > >>>> Me neither, given that the import is protected by a try/except. > >>>> > >>>> try: > >>>> import ICCProfile > >>>> except ImportError: > >>>> ... > >>>> > >>>> What exactly are you doing when you get this import error, and what > >>>> does the full traceback look like? > >>>> > >>>> > >>> > >>> > >> > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bharathwaaj.s at gmail.com Sun Nov 14 18:44:44 2010 From: bharathwaaj.s at gmail.com (Bharathwaaj Srinivasan) Date: Sun, 14 Nov 2010 23:14:44 +0530 Subject: [Image-SIG] import ICCProfile Error In-Reply-To: References: Message-ID: As you suggested, I've commented out the try except code #try: # import ICCProfile # p = ICCProfile.ICCProfile(im.info["icc_profile"]) # name = p.tags.desc.get("ASCII", p.tags.desc.get("Unicode", p.tags.desc.get("Macintosh", p.tags.desc.get("en", {}).get("US", "ICC Profile")))).encode("latin1", "replace")[:79] #except ImportError: name = "ICC Profile" and it works fine. Still couldn't understand why it was failing? Kind regards, Bharath On 14 November 2010 22:26, Fredrik Lundh wrote: > On Sun, Nov 14, 2010 at 3:46 PM, Bharathwaaj Srinivasan > wrote: > > Hi, > > > > I tried from the command line. Still getting error. Please see the log. > > > > bharath at bharath-laptop:~/workspace/webKit$ python2.5 > > Python 2.5.5 (r255:77872, Nov 3 2010, 13:18:19) > > [GCC 4.4.5] on linux2 > > Type "help", "copyright", "credits" or "license" for more information. > >>>> import PIL > >>>> import ICCProfile > > Traceback (most recent call last): > > File "", line 1, in > > ImportError: No module named ICCProfile > >>>> from PIL import ICCProfile > > Traceback (most recent call last): > > File "", line 1, in > > ImportError: cannot import name ICCProfile > >>>> > > That's irrelevant -- in the PNG module, the import is wrapped inside a > try/except statement. The problem is that the try/except expects an > ImportError (which you'e seeing), not a SystemError (which is what > happens inside GAE). > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Sun Nov 14 20:06:26 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 14 Nov 2010 20:06:26 +0100 Subject: [Image-SIG] import ICCProfile Error In-Reply-To: References: Message-ID: I suspect a buglet in the GAE development server: when reloading the code, it explicitly messes with sys.modules in a way that triggers this error when PIL is invoked the next time (by calling code in a module that no longer exists in sys.modules). It only happens for some PNG files, and only for PIL 1.1.7, so it hasn't shown up in their tests yet. And it doesn't happen in programs that doesn't manipulate sys.modules directly (i.e. most programs), so we haven't seen it on image-sig before. On Sun, Nov 14, 2010 at 6:44 PM, Bharathwaaj Srinivasan wrote: > As you suggested, I've commented out the try except code > > ??????? #try: > ??????? #??? import ICCProfile > ??????? #??? p = ICCProfile.ICCProfile(im.info["icc_profile"]) > ??????? #??? name = p.tags.desc.get("ASCII", p.tags.desc.get("Unicode", > p.tags.desc.get("Macintosh", p.tags.desc.get("en", {}).get("US", "ICC > Profile")))).encode("latin1", "replace")[:79] > ??????? #except ImportError: > ??????? name = "ICC Profile" > > and it works fine. Still couldn't understand why it was failing? > > Kind regards, > Bharath > > On 14 November 2010 22:26, Fredrik Lundh wrote: >> >> On Sun, Nov 14, 2010 at 3:46 PM, Bharathwaaj Srinivasan >> wrote: >> > Hi, >> > >> > I tried from the command line. Still getting error. Please see the log. >> > >> > bharath at bharath-laptop:~/workspace/webKit$ python2.5 >> > Python 2.5.5 (r255:77872, Nov? 3 2010, 13:18:19) >> > [GCC 4.4.5] on linux2 >> > Type "help", "copyright", "credits" or "license" for more information. >> >>>> import PIL >> >>>> import ICCProfile >> > Traceback (most recent call last): >> > ? File "", line 1, in >> > ImportError: No module named ICCProfile >> >>>> from PIL import ICCProfile >> > Traceback (most recent call last): >> > ? File "", line 1, in >> > ImportError: cannot import name ICCProfile >> >>>> >> >> That's irrelevant -- in the PNG module, the import is wrapped inside a >> try/except statement. ?The problem is that the try/except expects an >> ImportError (which you'e seeing), not a SystemError (which is what >> happens inside GAE). >> >> > > From burton.1 at sympatico.ca Thu Nov 18 16:46:20 2010 From: burton.1 at sympatico.ca (Maxime demers) Date: Thu, 18 Nov 2010 15:46:20 +0000 Subject: [Image-SIG] how to create mask NxN automatically Message-ID: Hi everyone, I would like to hear you about the possibility to create mask of N dimension to "scan" an image. The aim of this mask is to check for each pixel if its value is between the intervals confidence of the mask's pixels or not. Im looking for a function that will create a mask of the desired dimension of the user. For instance: 3x3, 5x5, 7x7, 11x11, etc. if the scanned pixel is defined by (i,j) the function should put all the values of the mask NxN at the position (i,j) into a list. For now, I can manualy create mask of 3x3 and 5x5 by including the pixels (i-1,j-1) to (i+1,j+1) etc... in a list, but its getting complicated for 7x7 and bigger mask. Thanks for your help, its really appreciated Maxime Demers Geomatics and Remote Sensing University de Sherbrooke -------------- next part -------------- An HTML attachment was scrubbed... URL: From chris.mit7 at gmail.com Thu Nov 18 17:47:56 2010 From: chris.mit7 at gmail.com (Chris Mitchell) Date: Thu, 18 Nov 2010 11:47:56 -0500 Subject: [Image-SIG] how to create mask NxN automatically In-Reply-To: References: Message-ID: Are you using numpy or doing for loops? On Thu, Nov 18, 2010 at 10:46 AM, Maxime demers wrote: > Hi everyone, > > I would like to hear you about the possibility to create mask of N dimension > to "scan" an image. The aim of this mask is to check for each pixel if its > value is between the intervals confidence of the mask's pixels or not. Im > looking for a function that will create a mask of the desired dimension of > the user. For instance: 3x3, 5x5, 7x7, 11x11, etc. > > if the scanned pixel is defined by (i,j) > the function should put all the values of the mask NxN at the position (i,j) > into a list. > > For now, I can manualy create mask of 3x3 and 5x5 by including the pixels > (i-1,j-1) to (i+1,j+1) etc... in a list, but its getting complicated for 7x7 > and bigger mask. > > Thanks for your help, its really appreciated > > Maxime Demers > Geomatics and Remote Sensing > University de Sherbrooke > > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > From Chris.Barker at noaa.gov Thu Nov 18 19:37:14 2010 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Thu, 18 Nov 2010 10:37:14 -0800 Subject: [Image-SIG] how to create mask NxN automatically In-Reply-To: References: Message-ID: <4CE5725A.7020607@noaa.gov> On 11/18/10 8:47 AM, Chris Mitchell wrote: > Are you using numpy or doing for loops? definitely a job for numpy -- if you aren't using it, check it out. -CHB > On Thu, Nov 18, 2010 at 10:46 AM, Maxime demers wrote: >> Hi everyone, >> >> I would like to hear you about the possibility to create mask of N dimension >> to "scan" an image. The aim of this mask is to check for each pixel if its >> value is between the intervals confidence of the mask's pixels or not. Im >> looking for a function that will create a mask of the desired dimension of >> the user. For instance: 3x3, 5x5, 7x7, 11x11, etc. >> >> if the scanned pixel is defined by (i,j) >> the function should put all the values of the mask NxN at the position (i,j) >> into a list. >> >> For now, I can manualy create mask of 3x3 and 5x5 by including the pixels >> (i-1,j-1) to (i+1,j+1) etc... in a list, but its getting complicated for 7x7 >> and bigger mask. >> >> Thanks for your help, its really appreciated >> >> Maxime Demers >> Geomatics and Remote Sensing >> University de Sherbrooke >> >> _______________________________________________ >> 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 -- 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 bulwersator at gmail.com Sat Nov 20 14:33:22 2010 From: bulwersator at gmail.com (Mateusz) Date: Sat, 20 Nov 2010 14:33:22 +0100 Subject: [Image-SIG] Crash of installer on windows7 Message-ID: I installed Python 2.6.6 I tried to install Python Imaging Library 1.1.7 for Python 2.6 but installer freezed and crashed. Python Imaging Library 1.1.6 for Python 2.6 (Windows only) is also not working. Details of crash for 1.1.7 (sorry for not english description, but windows does not allow to change language of interface [except windows ultima]): Podpis problemu: Nazwa zdarzenia problemu: BEX Nazwa aplikacji: PIL-1.1.7.win32-py2.6.exe Wersja aplikacji: 0.0.0.0 Sygnatura czasowa aplikacji: 49819995 Nazwa modu?u z b??dem: PIL-1.1.7.win32-py2.6.exe Wersja modu?u z b??dem: 0.0.0.0 Sygnatura czasowa modu?u z b??dem: 49819995 Przesuni?cie wyj?tku: 000086dc Kod wyj?tku: c0000417 Dane wyj?tku: 00000000 Wersja systemu operacyjnego: 6.1.7600.2.0.0.768.3 Identyfikator ustawie? regionalnych: 1045 Dodatkowe informacje 1: 6e72 Dodatkowe informacje 2: 6e7284cc86a8674fd8bbd3bb8594d1da Dodatkowe informacje 3: 7075 Dodatkowe informacje 4: 70750b3df90d226c69fa9a27cb0caba2 Przeczytaj w trybie online nasze zasady zachowania poufno?ci informacji: http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0415 Je?li zasady zachowania poufno?ci informacji w trybie online nie s? dost?pne, przeczytaj nasze zasady zachowania poufno?ci informacji w trybie offline: C:\windows\system32\pl-PL\erofflps.txt From lists+Image_SIG at hoech.org Sat Nov 20 18:20:58 2010 From: lists+Image_SIG at hoech.org (=?ISO-8859-1?Q?Florian_H=F6ch?=) Date: Sat, 20 Nov 2010 18:20:58 +0100 Subject: [Image-SIG] import ICCProfile Error In-Reply-To: References: Message-ID: <4CE8037A.7060502@hoech.org> Hi, the whole part try: import ICCProfile ... except ImportError: is a leftover from development code. It can be removed with just leaving the name = "ICC Profile" without impeding any functionality (I contributed support for ICC profile reading/writing a while back, and forgot to remove that part back then). Sorry for the confusion caused. Am 14.11.2010 20:06, schrieb Fredrik Lundh: > I suspect a buglet in the GAE development server: when reloading the > code, it explicitly messes with sys.modules in a way that triggers > this error when PIL is invoked the next time (by calling code in a > module that no longer exists in sys.modules). It only happens for > some PNG files, and only for PIL 1.1.7, so it hasn't shown up in their > tests yet. And it doesn't happen in programs that doesn't manipulate > sys.modules directly (i.e. most programs), so we haven't seen it on > image-sig before. > > > > On Sun, Nov 14, 2010 at 6:44 PM, Bharathwaaj Srinivasan > wrote: >> As you suggested, I've commented out the try except code >> >> #try: >> # import ICCProfile >> # p = ICCProfile.ICCProfile(im.info["icc_profile"]) >> # name = p.tags.desc.get("ASCII", p.tags.desc.get("Unicode", >> p.tags.desc.get("Macintosh", p.tags.desc.get("en", {}).get("US", "ICC >> Profile")))).encode("latin1", "replace")[:79] >> #except ImportError: >> name = "ICC Profile" >> >> and it works fine. Still couldn't understand why it was failing? >> >> Kind regards, >> Bharath >> >> On 14 November 2010 22:26, Fredrik Lundh wrote: >>> >>> On Sun, Nov 14, 2010 at 3:46 PM, Bharathwaaj Srinivasan >>> wrote: >>>> Hi, >>>> >>>> I tried from the command line. Still getting error. Please see the log. >>>> >>>> bharath at bharath-laptop:~/workspace/webKit$ python2.5 >>>> Python 2.5.5 (r255:77872, Nov 3 2010, 13:18:19) >>>> [GCC 4.4.5] on linux2 >>>> Type "help", "copyright", "credits" or "license" for more information. >>>>>>> import PIL >>>>>>> import ICCProfile >>>> Traceback (most recent call last): >>>> File "", line 1, in >>>> ImportError: No module named ICCProfile >>>>>>> from PIL import ICCProfile >>>> Traceback (most recent call last): >>>> File "", line 1, in >>>> ImportError: cannot import name ICCProfile >>>>>>> >>> >>> That's irrelevant -- in the PNG module, the import is wrapped inside a >>> try/except statement. The problem is that the try/except expects an >>> ImportError (which you'e seeing), not a SystemError (which is what >>> happens inside GAE). >>> >>> >> >> > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig Regards -- Florian H?ch From gary.leydon at yale.edu Wed Nov 24 05:17:26 2010 From: gary.leydon at yale.edu (Leydon, Gary) Date: Tue, 23 Nov 2010 23:17:26 -0500 Subject: [Image-SIG] tif with jpeg compression not displaying correctly Message-ID: <0D987CAB8161A74F8DCA52B5E95A986248006CA308@XVS2-CLUSTER.yu.yale.edu> I've got PIL 1.1.7, Python 2.6.6, Libtif, libjpg, etc. Mac OS X 10.6.5. I've got some Tiff files with JPG compression , if I do import Image im = Image.open('myfile.tif') im.info['compression'] 'jpeg' im.show() I get the proper image but the colors are not remotely correct. If I first do from the command line tiffcp -c lzw myfile.tif lwfile.tif python import Image im = image.open('lwfile.tif') im.info['compression'] 'tiff_lzw' im.show() The image looks fine Is there some keyword or option or conversion, or some other set of steps to open a jpeg compressed tiff properly and work on it with PIL? thanks From josharian at gmail.com Wed Nov 24 22:11:16 2010 From: josharian at gmail.com (Josh Bleecher Snyder) Date: Wed, 24 Nov 2010 13:11:16 -0800 Subject: [Image-SIG] webp support? Message-ID: Hi, I was wondering whether webp support (encoding, decoding) was on the PIL roadmap. I was going to hack together a cPython extension for myself, but if it might be coming soon I'll hold off; alternatively, I could also try to put together a contribution to PIL. (Caveats on that: it'd probably have to be cPython only for now and I'd be new to PIL development so I'd most likely need a few pointers.) Thanks, Josh From tomislav.maric at gmx.com Fri Nov 26 11:45:09 2010 From: tomislav.maric at gmx.com (tomislav_maric@gmx.com) Date: Fri, 26 Nov 2010 11:45:09 +0100 Subject: [Image-SIG] experimental data diagram digitalization Message-ID: <20101126105325.275250@gmx.com> Hi everyone, I need to digitalize a diagram of experimental data. I have been reading the documentation of the Python Imaging Library, and I'm thinking that I can approach my problem in the following way: 1) Create a .png of the diagram I find in the literature (.pdf articles, or theses). 2) Clean up the diagram (remove the axes, the text and leave only the data that I am interested in). 3) Read the image. 4) Apply a filter that will result in only those pixels that are non-white (pick up the experimental data). 5) Scale the result data of the filter (in pixels) to the actual coordinates in the image in milimeters. 6) Scale the milimeter coordinates to the actual scale of the diagram (read from the original .pdf), to get the ? true coordinates (in my case, I have time in seconds and pressure in kPa). Can this be done with the Python Imaging Library + some additional python coding? The other option would be to use inkscape to export the path into .svg and manipulate (scale) it with some python-XML library. Can anyone give me some advice on this issue? Thanks in advance, Tomislav From tomislav.maric at gmx.com Fri Nov 26 20:20:12 2010 From: tomislav.maric at gmx.com (tomislav_maric@gmx.com) Date: Fri, 26 Nov 2010 20:20:12 +0100 Subject: [Image-SIG] experimental data diagram digitalization Message-ID: <20101126192126.275250@gmx.com> @Edward Cannon Hi Edward, Thanks for the advice. Well, I am not getting any of the experimental data, any time soon. Since I am dealing with the sonic pressure values up to 600 kPa, I basically have one peak, and the rest is low amplitude noise about 0 kPa... [0,600] leaves me a lot of tolerance to work with. This is just for the specific cases I am dealing with now. Besides, I'm using this to evaluate the numerical studies vs the experimental data, so I am very happy with a coarse estimate, for now. Anyway, thanks a lot for the advice. Best regards, Tomislav > ----- Original Message ----- > From: Edward Cannon > Sent: 11/26/10 08:10 PM > To: tomislav_maric at gmx.com > Subject: Re: [Image-SIG] experimental data diagram digitalization > > Your approach sounds pretty good, It will probably work. I might offer > this piece of advice: don't do it. Data looses precision as it is > graphed, and especially in the low resolutions used in many pdf > versions of articles. The descriptive statistics you compute are > likely to be incorrect. If you need the original data get it from a > publication or the paper author. If you intend to publish any results, > no journal will accept your recreated data. > Edward Cannon > Unicorn School > > On Fri, Nov 26, 2010 at 2:45 AM, tomislav_maric at gmx.com > wrote: > > Hi everyone, > > > > I need to digitalize a diagram of experimental data. I have been reading the documentation of the Python Imaging Library, and I'm thinking that I can approach my problem in the following way: > > > > 1) Create a .png of the diagram I find in the literature (.pdf articles, or theses). > > 2) Clean up the diagram (remove the axes, the text and leave only the data that I am interested in). > > 3) Read the image. > > 4) Apply a filter that will result in only those pixels that are non-white (pick up the experimental data). > > 5) Scale the result data of the filter (in pixels) to the actual coordinates in the image in milimeters. > > 6) Scale the milimeter coordinates to the actual scale of the diagram (read from the original .pdf), to get the > > ?? true coordinates (in my case, I have time in seconds and pressure in kPa). > > > > Can this be done with the Python Imaging Library + some additional python coding? > > > > The other option would be to use inkscape to export the path into .svg and manipulate (scale) it with some python-XML library. > > > > Can anyone give me some advice on this issue? > > > > Thanks in advance, > > Tomislav > > _______________________________________________ > > Image-SIG maillist ?- ?Image-SIG at python.org > > http://mail.python.org/mailman/listinfo/image-sig > > From guy.kloss at aut.ac.nz Fri Nov 26 20:20:39 2010 From: guy.kloss at aut.ac.nz (Guy K. Kloss) Date: Sat, 27 Nov 2010 08:20:39 +1300 Subject: [Image-SIG] experimental data diagram digitalization In-Reply-To: <20101126105325.275250@gmx.com> References: <20101126105325.275250@gmx.com> Message-ID: <201011270820.40262.guy.kloss@aut.ac.nz> Hi Tomislav, to me it seems like PIL would only to a (little) part in this, but I think it could work the way you've outlined the process. On Fri, 26 Nov 2010 23:45:09 tomislav_maric at gmx.com wrote: > 1) Create a .png of the diagram I find in the literature (.pdf articles, or > theses). > 2) Clean up the diagram (remove the axes, the text and leave > only the data that I am interested in). > 3) Read the image. I think after this step, it might be good to convert the image to a NumPy array. If you've got the image data binarised, or otherwise converted to something with a strong contrast, you can then use the "query" operation numpy.where(condition, [x, y]) to get an array of all the points that are for example non-white. This could for example look like this: numpy.array(numpy.where(graph_array > 128), dtype=float) See an example here with a floating point array here: In [3]: a = numpy.random.normal(0.5, size=(5, 5)) In [4]: a Out[4]: array([[ 1.02824407, -0.10784655, 0.50478651, 1.8077713 , 0.73332092], [ 1.21246923, -0.33658738, 0.29709342, -0.56360425, -0.2158604 ], [ 0.14956347, 0.44197572, 0.11578998, 1.39439779, 1.71079914], [ 1.06089915, 0.68276441, 1.65573349, 0.79238584, 1.15568584], [ 0.97881477, 0.14273089, -0.93478545, 0.38605599, -0.36599775]]) In [5]: numpy.where(a > 0.5) Out[5]: (array([0, 0, 0, 0, 1, 2, 2, 3, 3, 3, 3, 3, 4]), array([0, 2, 3, 4, 0, 3, 4, 0, 1, 2, 3, 4, 0])) This way you've got arrays with all x and y coordinates for all pixels belonging to the graph. The conversion to a new numpy array as stated in the line above the example converts the results to a new 2D array, but uses floats for the values, so you can conveniently go and apply scaling to millimetres/units to the coordinates rather than keeping them in integers. > 4) Apply a filter that will result in only those pixels that are non-white > (pick up the experimental data). > 5) Scale the result data of the filter (in pixels) to the actual coordinates > in the image in milimeters. If you're using all the coordinates in one big numpy array, you can apply the scaling to the whole array at once, just by multiplying it with the scaling coefficients. > 6) Scale the milimeter coordinates to the actual scale of the diagram (read > from the original .pdf), to get the true coordinates (in my case, I have > time in seconds and pressure in kPa). Hope that helps, Guy -- Guy K. Kloss School of Computing + Mathematical Sciences Auckland University of Technology Private Bag 92006, Auckland 1142 phone: +64 9 921 9999 ext. 5032 eMail: Guy.Kloss at aut.ac.nz -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part. URL: From edward at unicornschool.org Sun Nov 28 02:09:01 2010 From: edward at unicornschool.org (Edward Cannon) Date: Sat, 27 Nov 2010 17:09:01 -0800 Subject: [Image-SIG] .hdr support Message-ID: Is anyone interested in .hdr image files? some time ago I needed to read some and not finding a decent solution, I wrote my own on top of PIL. If anyone is interested I would be happy to share it with everyone. More information about the .hdr or Radiance file format: it is an older file format for high dynamic range images stored as RGBe where e is an exponent. Files come in several compressed and uncompressed flavors. My code reads the uncompressed version and returns the image as a (R,G,B) tuple of 32bit floating point images. I also wrote a few support functions to assist in my endeavors. Edward Cannon Unicorn School From HAWRYLA at novachem.com Tue Nov 30 23:51:56 2010 From: HAWRYLA at novachem.com (Andrew Hawryluk) Date: Tue, 30 Nov 2010 15:51:56 -0700 Subject: [Image-SIG] experimental data diagram digitalization In-Reply-To: <20101126105325.275250@gmx.com> References: <20101126105325.275250@gmx.com> Message-ID: <48C01AE7354EC240A26F19CEB995E94306350EAD@CHMAILMBX01.novachem.com> Unless you need to batch-process dozens of diagrams, you will probably be better off using an existing utility. While it's not as good as getting original data, it's better than guessing all of the numbers by eye. http://digitizer.sourceforge.net/ http://plotdigitizer.sourceforge.net/ Good luck! > -----Original Message----- > From: image-sig-bounces+hawryla=novachem.com at python.org [mailto:image- > sig-bounces+hawryla=novachem.com at python.org] On Behalf Of > tomislav_maric at gmx.com > Sent: Friday, November 26, 2010 3:45 AM > To: image-sig at python.org > Subject: [Image-SIG] experimental data diagram digitalization > > Hi everyone, > > I need to digitalize a diagram of experimental data. I have been > reading the documentation of the Python Imaging Library, and I'm > thinking that I can approach my problem in the following way: > > 1) Create a .png of the diagram I find in the literature (.pdf > articles, or theses). > 2) Clean up the diagram (remove the axes, the text and leave only the > data that I am interested in). > 3) Read the image. > 4) Apply a filter that will result in only those pixels that are non- > white (pick up the experimental data). > 5) Scale the result data of the filter (in pixels) to the actual > coordinates in the image in milimeters. > 6) Scale the milimeter coordinates to the actual scale of the diagram > (read from the original .pdf), to get the > ? true coordinates (in my case, I have time in seconds and pressure in > kPa). > > Can this be done with the Python Imaging Library + some additional > python coding? > > The other option would be to use inkscape to export the path into .svg > and manipulate (scale) it with some python-XML library. > > Can anyone give me some advice on this issue? > > Thanks in advance, > Tomislav > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig From burton.1 at sympatico.ca Sun Nov 21 17:22:37 2010 From: burton.1 at sympatico.ca (Maxime demers) Date: Sun, 21 Nov 2010 16:22:37 +0000 Subject: [Image-SIG] performance of pixel by pixel processing Message-ID: Good day everyone, I would like to have your suggestions about how it could be possible to improve process speed of my following script. The aim of the script is to scan each pixel of an image, and to look its validity with its neighborhood. I use a function that return the values of mask of 9x9 pixels around the scanned pixel and calculate the interval confidence of it. If the pixel is valid with the 9x9 mask its stay unchanged, if it is outside the interval confidence, the pixel receive the mean of the mask. The problem is that this pixel by pixel processing is really slow. It could take many hours for image not bigger than 4-5 Mo. Anybody knows how I could increase the performance of such a script? I use PIL and numpy. Thank youMaxime Demers-------------------------------------------------------------------------------------------------------------------------- import PILimport ImageOpsimport Imageimport numpyfrom OuvrirImg import * #function that open an imagefrom CreateSide import * from RebuildImg import *from IntervalConfiance import * def CreateMask(dimensions,image,i,j): 'create a mask of N dimensions at the position i,j of a selected image and return the values of DN of each pixel in the mask in a list' img = numpy.array(image) dim = dimensions/2 cpt = 1 mask = [] y = j x = i while cpt <= dimensions: dim2 = dimensions/2 cpt2 = 1 while cptr2 <= dimensions: mask.append(img[x-dim][y-dim2]) dim2 = dim2-1 cpt2 = cpt2 + 1 dim = dim-1 cpt = cpt + 1 return mask #This script scan each pixel of an image with a N dimension mask#If the the scanned pixel is between the interval confidence of the pixels in the mask#that pixel stay unchanged, if its outside the interval confidence, the pixel take the mean#of the pixels in the mask test=OuvrirImg('f:\\mapaq_petit.tif')img=CreateSide(9,test) #create an image with side for a 9x9 maskNewImage=[0]*(img.shape[1]-8)*(img.shape[0]-8)h=0for i in range(4,img.shape[0]-4): for j in range(4,img.shape[1]-4): mask2 = CreateMask(9,img,i,j) #return a list of DN of the 9X9 mask at the position i,j mean = IntervalConfiance(mask)[0] interval = IntervalConfiance(mask)[1] if img[i][j] >= mean+interval or img[i][j] <= mean-interval: NewImage[h] = mean else: NewImage[h]=img[i][j] h = h+1 print "process completed, the new image is created"Dilate=numpy.array(Dilate)Dilate=numpy.reshape(Dilate,(img.shape[0]-8,img.shape[1]-8))RebuildImg(Dilate,"f:\\newImage.tif") -------------- next part -------------- An HTML attachment was scrubbed... URL: From gary.leydon at yale.edu Tue Nov 23 15:41:12 2010 From: gary.leydon at yale.edu (Leydon, Gary) Date: Tue, 23 Nov 2010 09:41:12 -0500 Subject: [Image-SIG] Python Image Library problems with Tiff file using JPEG compression Message-ID: <0D987CAB8161A74F8DCA52B5E95A98624800665900@XVS2-CLUSTER.yu.yale.edu> I've got PIL 1.1.7, Python 2.6.6, Libtif, libjpg, etc. Mac OS X 10.6.5. I've got some Tiff files with JPG compression , if I do import Image im = Image.open('myfile.tif') im.info['compression'] 'jpeg' im.show() I get the proper image but the colors are not remotely correct. If I first do from the command line tiffcp -c lzw myfile.tif lwfile.tif python import Image im = image.open('lwfile.tif') im.info['compression'] 'tiff_lzw' im.show() The image looks fine Is there some keyword or option or some other set of steps to open a jpeg compressed tiff properly and work on it with PIL? thanks Gary Leydon Systems Administrator Dept of Neurobiology/Yale University School of Medicine 333 Cedar St. New Haven, Ct. 06520-8001 gary.leydon at yale.edu ph:203-785-5736 fax:203-785-5263 -------------- next part -------------- An HTML attachment was scrubbed... URL: From burton.1 at sympatico.ca Fri Nov 26 14:23:39 2010 From: burton.1 at sympatico.ca (Maxime demers) Date: Fri, 26 Nov 2010 13:23:39 +0000 Subject: [Image-SIG] experimental data diagram digitalization In-Reply-To: <20101126105325.275250@gmx.com> References: <20101126105325.275250@gmx.com> Message-ID: Hello Tomislav for the part 1-3 you can use PIL, for the part 4, you should also use numpy to convert your image into a flat list. Sorry, I cant help you for the points 5 and 6. Keep us in touch with your project Maxime > Date: Fri, 26 Nov 2010 11:45:09 +0100 > From: tomislav.maric at gmx.com > To: image-sig at python.org > Subject: [Image-SIG] experimental data diagram digitalization > > Hi everyone, > > I need to digitalize a diagram of experimental data. I have been reading the documentation of the Python Imaging Library, and I'm thinking that I can approach my problem in the following way: > > 1) Create a .png of the diagram I find in the literature (.pdf articles, or theses). > 2) Clean up the diagram (remove the axes, the text and leave only the data that I am interested in). > 3) Read the image. > 4) Apply a filter that will result in only those pixels that are non-white (pick up the experimental data). > 5) Scale the result data of the filter (in pixels) to the actual coordinates in the image in milimeters. > 6) Scale the milimeter coordinates to the actual scale of the diagram (read from the original .pdf), to get the > true coordinates (in my case, I have time in seconds and pressure in kPa). > > Can this be done with the Python Imaging Library + some additional python coding? > > The other option would be to use inkscape to export the path into .svg and manipulate (scale) it with some python-XML library. > > Can anyone give me some advice on this issue? > > Thanks in advance, > Tomislav > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig -------------- next part -------------- An HTML attachment was scrubbed... URL: