From alex at chiefmall.com Wed Feb 3 13:41:36 2010 From: alex at chiefmall.com (Alex Ksikes) Date: Wed, 03 Feb 2010 04:41:36 -0800 Subject: [Image-SIG] faceted search interface Message-ID: Hi all, I have just put together a system to automatically build a faceted search interface and search engine from any data. Would you mind having a look at it and letting me know what you think of it? Here is a particular instance on IMDb (the internet movie database). You can refine by particular categories such as genres, actors or directors with the results ordered by user ratings and number of votes. http://imdb.cloudmining.net/search?query=(@actor%20Brad%20Pitt) This IMDb instance was built automatically. All that was needed was to setup the data in a specific format and to optionally customize the look and feel of a search result. In fact the system was also applied to DBLP: http://dblp.cloudmining.net/search?query=(@venue%20CHI) The system is called Cloud Mining (http://www.cloudmining.net). Your feedback would be very much appreciated. Thank you so much, Alex Ksikes From playfight at mac.com Mon Feb 8 05:53:01 2010 From: playfight at mac.com (Doug Easterly) Date: Mon, 08 Feb 2010 17:53:01 +1300 Subject: [Image-SIG] _imaging C module Message-ID: Hello I have a MacPowerbook Pro, Intel Core Duo running 10.6.2 and Python 2.6.1 installed I have also tried these different instructions for getting PIL to work: http://jetfar.com/libjpeg-and-python-imaging-pil-on-snow-leopard/ http://gknauth.blogspot.com/2009/10/building-pil-116-on-mac-os-x-106.html http://proteus-tech.com/blog/cwt/install-pil-in-snow-leopard/ And I have done all manner of variation on the above (installing on top, deleting everything and working from scratch, using macports, etc). But, each time I try this simple example: >>> from PIL import Image >>> mg = Image.open('test.jpg') >>> print(mg.size) >>> mg.show() Everything works until I get to mg.show(). Then I get the following traceback: File "", line 1, in File "/Library/Python/2.6/site-packages/PIL/Image.py", line 1449, in show _showxv(self, title, command) File "/Library/Python/2.6/site-packages/PIL/Image.py", line 2082, in _showxv file = image._dump(format=format) File "/Library/Python/2.6/site-packages/PIL/Image.py", line 476, in _dump self.load() File "/Library/Python/2.6/site-packages/PIL/ImageFile.py", line 155, in load self.load_prepare() File "/Library/Python/2.6/site-packages/PIL/ImageFile.py", line 223, in load_prepare self.im = Image.core.new(self.mode, self.size) File "/Library/Python/2.6/site-packages/PIL/Image.py", line 36, in __getattr__ raise ImportError("The _imaging C module is not installed") Can anyone please help with this? I've been trying for several days now and just seem to be spinning my wheels. More info: my build seemed to work ok, but my self test had a failure: PIL 1.1.6 BUILD SUMMARY -------------------------------------------------------------------- version 1.1.6 platform darwin 2.6.1 (r261:67515, Jul 7 2009, 23:51:51) [GCC 4.2.1 (Apple Inc. build 5646)] -------------------------------------------------------------------- --- TKINTER support ok --- JPEG support ok --- ZLIB (PNG/ZIP) support ok --- FREETYPE2 support ok ***************************************************************** Failure in example: _info(Image.open("Images/lena.jpg")) from line #24 of selftest.testimage Exception raised: Traceback (most recent call last): File "./doctest.py", line 499, in _run_examples_inner exec compile(source, "", "single") in globs File "", line 1, in File "./selftest.py", line 22, in _info im.load() File "PIL/ImageFile.py", line 207, in load raise IOError(error + " when reading image file") IOError: decoding error when reading image file 1 items had failures: 1 of 57 in selftest.testimage ***Test Failed*** 1 failures. *** 1 tests of 57 failed. cheers Doug From ariel.goldstien at gmail.com Wed Feb 3 10:06:17 2010 From: ariel.goldstien at gmail.com (ariel goldstien) Date: Wed, 3 Feb 2010 11:06:17 +0200 Subject: [Image-SIG] proble loading font Message-ID: <258791b31002030106y1ba605b2t8b6e891df46ad99f@mail.gmail.com> Hi. My name is Ariel Goldstien I work at The Hebrew university laboratory. I am trying to write a Hebrew string to a BMP. and I keep getting "The _imaging C module is not installed" despite the fact that I have managed to import _imaging. this is the code: import Image import ImageDraw import ImageFont import _imaging a=u'1?????' #u'..' converts to Unicode font = ImageFont.truetype('c:/mriam.ttf',24) #standard Hebrew font, this line throws the error im=Image.new('RGB',(200,200),(100,100,100)) d=ImageDraw.Draw(im) d.text((0,0),a) im.show() I have spent more than 3 dayes trying to figure it out. any help would be very appriciated -------------- next part -------------- An HTML attachment was scrubbed... URL: From espen at medialog.no Wed Feb 10 12:01:24 2010 From: espen at medialog.no (Espen Moe-Nilssen) Date: Wed, 10 Feb 2010 12:01:24 +0100 Subject: [Image-SIG] Colorize Image Message-ID: Hi We are making an open source project, http://plone.org/products/subskins I have been trying over and over again to find a way to let PIL colorize an image. It should work like this: 1) I have a greyscale image 2) A color is selected, for example "#123456" 3) The image is colorized in this way: Whatever was white is still white Whatever was black (100%) is now "#123456" Whaterver was grey (50%) is now 50% of "#123456" I have tried a lot of different approaches, but the colors always come out too dark. Is there a way to do this ? The code is here: http://svn.plone.org/svn/collective/Products.PloneSubSkins/trunk/ Products.PloneSubSkins/Products/PloneSubSkins/browser/views.py where the lines about this are: ______________________________________ class ColorizedImage(BrowserView): def __call__(self): portal_skins = getToolByName(self.context, 'portal_skins') img = portal_skins.restrictedTraverse(self.request.img) input = StringIO() input.write(img._data) input.seek(0) image = Image.open(input) newimage = colorize(image, self.request.color) output = StringIO() newimage.save(output, format='PNG') self.request.response.setHeader('Content-Type','image/png') return output.getvalue() def colorize(image, color): color = color[1:] assert len(color) == 6 or len(color)==3 if len(color)==6: r,g,b = int(color[:2],16),int(color[2:4],16),int(color[4:7],16) elif len(color)==3: r,g,b = int(color[0],16)*16,int(color[1],16)*16,int(color[2], 16)*16 palette = make_linear_ramp((r,g,b)) if image.mode != "L": image = image.convert('L') image.putpalette(palette) return image #Thanks to http://effbot.org/zone/pil-sepia.htm for the snippet def make_linear_ramp(white): # putpalette expects [r,g,b,r,g,b,...] ramp = [] r, g, b = white for i in range(255): ramp.extend((r*i/255, g*i/255, b*i/255)) return ramp __________________________________________ Espen -------------- next part -------------- An HTML attachment was scrubbed... URL: From jcupitt at gmail.com Thu Feb 11 12:50:11 2010 From: jcupitt at gmail.com (jcupitt at gmail.com) Date: Thu, 11 Feb 2010 11:50:11 +0000 Subject: [Image-SIG] Colorize Image In-Reply-To: References: Message-ID: <522c6461002110350p6208e7a7ic41820b88dc75de@mail.gmail.com> On 10 February 2010 11:01, Espen Moe-Nilssen wrote: > We are making an open source project,?http://plone.org/products/subskins > I have been trying over and over again to find a way to let PIL colorize an > image. > It should work like this: > 1) I have a greyscale image > 2) A color is selected, for example "#123456" > 3) The image is colorized in this way: > ?? ?Whatever was white is still white > ?? ?Whatever was black (100%) is now "#123456" > ?? ?Whaterver was grey (50%) is now 50% of "#123456" > I have tried a lot of different approaches, but the colors always come out > too dark.?Is there a way to do this ? You need to split the image into luminance (your greyscale image) and colour (the constant colour you want to apply). If you imagine the RGB space as a cube, the neutral axis (all the grey colours) is a straight line from (0, 0, 0) to (255, 255, 255). What you want to do is translate that line (ie. keep the angle of the thing the same, just translate the whole line up/down/left/right/fwd/back) so that it passes through #123456 instead. Any bits that go over 255 or under 0 need to be clipped. This is easy in CIELAB space, but still OK in RGB. John From spe.stani.be at gmail.com Thu Feb 11 20:26:15 2010 From: spe.stani.be at gmail.com (Stani) Date: Thu, 11 Feb 2010 20:26:15 +0100 Subject: [Image-SIG] PIL not saving metadata from progressive Jpeg's In-Reply-To: References: Message-ID: <2078a7ad1002111126g65623ccbjed87a75be869cffc@mail.gmail.com> http://tilloy.net/dev/pyexiv2/index.htm On Wed, Jan 27, 2010 at 2:50 PM, Frank Borell wrote: > Hello, > > I've tested on PIL 1.16 and 1.17. Metadata(IPTC and EXIF) are saved > fine when the jpg image is NOT progressive. But when the jpg is > progressive, the metadata gets wiped out. Does anyone have any ideas > on how to preserve? > > im = Image.open('progressive jpeg path') > > im.save('jpeg path') or > im.save('jpeg path',option={'progression':False,'quality': > 60,'optimize':True}) > > Thanks, > Frank > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > -- Phatch Photo Batch Processor - http://photobatch.stani.be SPE Python IDE - http://pythonide.stani.be From spe.stani.be at gmail.com Thu Feb 11 20:29:39 2010 From: spe.stani.be at gmail.com (Stani) Date: Thu, 11 Feb 2010 20:29:39 +0100 Subject: [Image-SIG] Colorize Image In-Reply-To: <522c6461002110350p6208e7a7ic41820b88dc75de@mail.gmail.com> References: <522c6461002110350p6208e7a7ic41820b88dc75de@mail.gmail.com> Message-ID: <2078a7ad1002111129i1a3b4caq1e581c6088ccdf1e@mail.gmail.com> How about using ImageOps.colorize ;-) ? On Thu, Feb 11, 2010 at 12:50 PM, wrote: > On 10 February 2010 11:01, Espen Moe-Nilssen wrote: >> We are making an open source project,?http://plone.org/products/subskins >> I have been trying over and over again to find a way to let PIL colorize an >> image. >> It should work like this: >> 1) I have a greyscale image >> 2) A color is selected, for example "#123456" >> 3) The image is colorized in this way: >> ?? ?Whatever was white is still white >> ?? ?Whatever was black (100%) is now "#123456" >> ?? ?Whaterver was grey (50%) is now 50% of "#123456" >> I have tried a lot of different approaches, but the colors always come out >> too dark.?Is there a way to do this ? > > You need to split the image into luminance (your greyscale image) and > colour (the constant colour you want to apply). > > If you imagine the RGB space as a cube, the neutral axis (all the grey > colours) is a straight line from (0, 0, 0) to (255, 255, 255). What > you want to do is translate that line (ie. keep the angle of the thing > the same, just translate the whole line up/down/left/right/fwd/back) > so that it passes through #123456 instead. Any bits that go over 255 > or under 0 need to be clipped. > > This is easy in CIELAB space, but still OK in RGB. > > John > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > -- Phatch Photo Batch Processor - http://photobatch.stani.be SPE Python IDE - http://pythonide.stani.be From cannon.el at gmail.com Thu Feb 11 17:12:25 2010 From: cannon.el at gmail.com (Laura & Edward Cannon) Date: Thu, 11 Feb 2010 08:12:25 -0800 Subject: [Image-SIG] Colorize Image In-Reply-To: <522c6461002110350p6208e7a7ic41820b88dc75de@mail.gmail.com> References: <522c6461002110350p6208e7a7ic41820b88dc75de@mail.gmail.com> Message-ID: There is a function for this. from the handbook: ImageOps.colorize(image, black, white) => image Colorize grayscale image. The black and white arguments should be RGB tuples or color names; this function calculates a colour wedge mapping all black pixels in the source image to the first colour, and all white pixels to the second colour. call it with your color for black and white for white, it accepts all "standard" color specifications, such as "#ff2253" or (255, 0, 0). On Thu, Feb 11, 2010 at 3:50 AM, wrote: > On 10 February 2010 11:01, Espen Moe-Nilssen wrote: >> We are making an open source project,?http://plone.org/products/subskins >> I have been trying over and over again to find a way to let PIL colorize an >> image. >> It should work like this: >> 1) I have a greyscale image >> 2) A color is selected, for example "#123456" >> 3) The image is colorized in this way: >> ?? ?Whatever was white is still white >> ?? ?Whatever was black (100%) is now "#123456" >> ?? ?Whaterver was grey (50%) is now 50% of "#123456" >> I have tried a lot of different approaches, but the colors always come out >> too dark.?Is there a way to do this ? > > You need to split the image into luminance (your greyscale image) and > colour (the constant colour you want to apply). > > If you imagine the RGB space as a cube, the neutral axis (all the grey > colours) is a straight line from (0, 0, 0) to (255, 255, 255). What > you want to do is translate that line (ie. keep the angle of the thing > the same, just translate the whole line up/down/left/right/fwd/back) > so that it passes through #123456 instead. Any bits that go over 255 > or under 0 need to be clipped. > > This is easy in CIELAB space, but still OK in RGB. > > John > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From mathewsl at indiana.edu Thu Feb 11 22:51:46 2010 From: mathewsl at indiana.edu (Mathews, Leah Nicole) Date: Thu, 11 Feb 2010 16:51:46 -0500 Subject: [Image-SIG] compatibility Message-ID: <3B184B0C-3225-4A14-8EB5-E18CAE953007@indiana.edu> Hello, > We are currently using Python Imaging Library 1.1.6 and evaluating > for use with snow leopard. Is it compatible and > what is the version that is compatible? > > Thanks, > Leah From espen at medialog.no Fri Feb 12 00:29:09 2010 From: espen at medialog.no (Espen Moe-Nilssen) Date: Fri, 12 Feb 2010 00:29:09 +0100 Subject: [Image-SIG] Colorize Image In-Reply-To: References: <522c6461002110350p6208e7a7ic41820b88dc75de@mail.gmail.com> Message-ID: Thanks a lot. I thought there had to be one, but I never found it. This will come in very handy Espen, >There is a function for this. from the handbook: >ImageOps.colorize(image, black, white) => image > >Colorize grayscale image. The black and white arguments should be RGB >tuples or color names; this function calculates a colour wedge mapping >all black pixels in the source image to the first colour, and all >white pixels to the second colour. > >call it with your color for black and white for white, it accepts all >"standard" color specifications, such as "#ff2253" or (255, 0, 0). > >On Thu, Feb 11, 2010 at 3:50 AM, wrote: >> On 10 February 2010 11:01, Espen Moe-Nilssen wrote: >>> We are making an open source project,?http://plone.org/products/subskins >>> I have been trying over and over again to find a way to let PIL colorize an >>> image. >>> It should work like this: >>> 1) I have a greyscale image >>> 2) A color is selected, for example "#123456" >>> 3) The image is colorized in this way: >>> ?? ?Whatever was white is still white >>> ?? ?Whatever was black (100%) is now "#123456" >>> ?? ?Whaterver was grey (50%) is now 50% of "#123456" >>> I have tried a lot of different approaches, but the colors always come out >>> too dark.?Is there a way to do this ? >> >> You need to split the image into luminance (your greyscale image) and >> colour (the constant colour you want to apply). >> >> If you imagine the RGB space as a cube, the neutral axis (all the grey >> colours) is a straight line from (0, 0, 0) to (255, 255, 255). What >> you want to do is translate that line (ie. keep the angle of the thing >> the same, just translate the whole line up/down/left/right/fwd/back) >> so that it passes through #123456 instead. Any bits that go over 255 >> or under 0 need to be clipped. >> >> This is easy in CIELAB space, but still OK in RGB. >> >> John >> _______________________________________________ >> Image-SIG maillist ?- ?Image-SIG at python.org >> http://mail.python.org/mailman/listinfo/image-sig >> -- Espen Moe-Nilssen Grieg Medialog AS From fredrik at pythonware.com Thu Feb 11 21:06:18 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 11 Feb 2010 21:06:18 +0100 Subject: [Image-SIG] delayed mail Message-ID: <368a5cd51002111206w543da989r9031737b3d0631da@mail.gmail.com> sorry for the delays in mail handling; I've been on the road more or less constantly since late november, and more mails than usual have ended up in the moderation queues lately (most of it is indeed spam, but not everything...). From fredrik at pythonware.com Fri Feb 12 03:01:16 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 12 Feb 2010 03:01:16 +0100 Subject: [Image-SIG] delayed mail In-Reply-To: <368a5cd51002111206w543da989r9031737b3d0631da@mail.gmail.com> References: <368a5cd51002111206w543da989r9031737b3d0631da@mail.gmail.com> Message-ID: <368a5cd51002111801w34ec9a8x8ff9f92010dc82b5@mail.gmail.com> (and of course that mail got caught by the filter as well. argh!) On Thu, Feb 11, 2010 at 9:06 PM, Fredrik Lundh wrote: > sorry for the delays in mail handling; I've been on the road more or > less constantly since late november, and more mails than usual have > ended up in the moderation queues lately (most of it is indeed spam, > but not everything...). > > > From fredrik at pythonware.com Fri Feb 12 03:55:03 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 12 Feb 2010 03:55:03 +0100 Subject: [Image-SIG] compatibility In-Reply-To: <3B184B0C-3225-4A14-8EB5-E18CAE953007@indiana.edu> References: <3B184B0C-3225-4A14-8EB5-E18CAE953007@indiana.edu> Message-ID: <368a5cd51002111855h5a8397dfp72b65a93dd60e889@mail.gmail.com> On Thu, Feb 11, 2010 at 10:51 PM, Mathews, Leah Nicole wrote: > Hello, > >> We are currently using Python Imaging Library 1.1.6 and evaluating >> for use with snow leopard. Is it compatible and >> what is the version that is compatible? I'm not aware of any known incompatibilities with any version of Mac OS X, for any version of PIL. You need a version of PIL that matches your Python installation, but that's about it. From fredrik at pythonware.com Fri Feb 12 03:59:26 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 12 Feb 2010 03:59:26 +0100 Subject: [Image-SIG] How to pass the address of the buffer to Image.frombuffer() In-Reply-To: References: Message-ID: <368a5cd51002111859v148eaab2of4d034935cd5e986@mail.gmail.com> 2010/1/26 ??????? : > I want to display captured frames from a webcam. I am using > video4linux2, v4l2 bindings for python and ctypes. > > I am also using Tk. In the main loop of my v4l2 app, after Q_BUF, > STREAM_ON, DQ_BUF I call method that looks something like that: > > > window = Tkinter.Tk() > image = ImageTk.PhotoImage(pixelfmt, (320, 240)) > label = Tkinter.Label(window, image=image) > label.pack() > > im = Image.frombuffer(pixelfmt, (320, 240), > ctypes.string_at(buf.userptr, buf.length), 'raw', pixelfmt, 0, 1) > > image.paste(im) > window.update() > > Now, how is buf.userptr supposed to look like? A ctypes.c_void_p? > In my case buf.userptr is long. Something like 170692608. > > I don't know how addresses in python should look like. Did you figure this out? I think this is more of a ctypes question than a PIL question, so you might want to repost this to a more general Python forum, such as python-list at python.org (but feel free to follow up here with the solution if you have it). Cheers /F From fredrik at pythonware.com Fri Feb 12 08:42:02 2010 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 12 Feb 2010 08:42:02 +0100 Subject: [Image-SIG] proble loading font In-Reply-To: <258791b31002030106y1ba605b2t8b6e891df46ad99f@mail.gmail.com> References: <258791b31002030106y1ba605b2t8b6e891df46ad99f@mail.gmail.com> Message-ID: <368a5cd51002112342p72c7f3c3p46999cc946ab5114@mail.gmail.com> What platform is this? If you start a Python interpreter and write: >>> import Image >>> Image.core what does it output? On Wed, Feb 3, 2010 at 10:06 AM, ariel goldstien wrote: > Hi. > My name is Ariel Goldstien I work at The Hebrew university laboratory. > I am trying to write a Hebrew string to a BMP. and I keep getting "The > _imaging C module is not installed" despite the fact that I have managed to > import _imaging. > this is the code: > import Image > import ImageDraw > import ImageFont > import _imaging > > a=u'1?????' #u'..' converts to Unicode > font = ImageFont.truetype('c:/mriam.ttf',24) #standard Hebrew font, this > line throws the error > im=Image.new('RGB',(200,200),(100,100,100)) > d=ImageDraw.Draw(im) > d.text((0,0),a) > im.show() > I have spent more than 3 dayes trying to figure it out. any help would be > very appriciated > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > From Chris.Barker at noaa.gov Fri Feb 12 18:28:35 2010 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Fri, 12 Feb 2010 09:28:35 -0800 Subject: [Image-SIG] Is PIL 1.1.7 final "official" In-Reply-To: <368a5cd50912111646x9ff190cib0da871c50807d2f@mail.gmail.com> References: <800886C2A4A73E44BA0FE45152C023705D78630E8C@ADSK-NAMSG-02.MGDADSK.autodesk.com> <368a5cd50912111646x9ff190cib0da871c50807d2f@mail.gmail.com> Message-ID: <4B758FC3.10401@noaa.gov> Fredrik Lundh wrote: > Yeah, 1.1.7 is official; it's just me having accidentally skipped a > couple of steps in the release procedure. Do you have any Mac binaries? If not, do you have anyone to build them? If not, should I try to get it done? -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 nicolas.roux at st.com Fri Feb 12 10:35:16 2010 From: nicolas.roux at st.com (Nicolas ROUX) Date: Fri, 12 Feb 2010 10:35:16 +0100 Subject: [Image-SIG] Support of RGB 16 bits images Message-ID: <000001caabc6$af860270$d4e8810a@gnb.st.com> Hello, We need to load/save RGB images in more than 8 bits and up to 16bits. We use to work with TIFF, PNG, BMP, ... Is there a plan to support such RGB bitwidth (and so associated file format) ? Thanks, Cheers, Nicolas. From cannon.el at gmail.com Sat Feb 13 00:05:01 2010 From: cannon.el at gmail.com (Laura & Edward Cannon) Date: Fri, 12 Feb 2010 15:05:01 -0800 Subject: [Image-SIG] BUG? PIL does not recognise alpha channel in attached png file In-Reply-To: <4B5E748F.2090902@smithpolglase.com> References: <4B5E748F.2090902@smithpolglase.com> Message-ID: I confirm the results PIL 1.16 Python 2.5.2 Seems pretty odd. What program did you use to create the image? On Mon, Jan 25, 2010 at 8:50 PM, Root wrote: > Hi, > > The attached image shows an alpha channel when viewed with gimp or eog, but > not when loading with PIL (version 1.1.6-3ubuntu1 as supplied with Ubuntu > Karmic AMD64 Desktop): > > >>>> import Image >>>> im = Image.open("seabreeze.png") >>>> print im.format > PNG >>>> print im.size > (599, 264) >>>> print im.mode > RGB > > > When I save the file using im.save(), and then open with gimp or eog, the > alpha channel is removed (to be expected given that the mode is read as > RGB). > > Is this is a bug? > > > Cheers, > Justin. > > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > From justin at smithpolglase.com Sat Feb 13 05:49:40 2010 From: justin at smithpolglase.com (Justin Smith) Date: Sat, 13 Feb 2010 12:49:40 +0800 Subject: [Image-SIG] BUG? PIL does not recognise alpha channel in attached png file In-Reply-To: References: <4B5E748F.2090902@smithpolglase.com> Message-ID: <4B762F64.7080008@smithpolglase.com> Laura & Edward Cannon wrote: > I confirm the results PIL 1.16 Python 2.5.2 > Seems pretty odd. What program did you use to create the image? I didn't create the image - it is generated by a weather web-site. I have a python script that downloads it for use on my MythTV box. BTW I'm using Python 2.6.4. Cheers, Justin. From cannon.el at gmail.com Mon Feb 15 01:26:52 2010 From: cannon.el at gmail.com (Laura & Edward Cannon) Date: Sun, 14 Feb 2010 16:26:52 -0800 Subject: [Image-SIG] Support of RGB 16 bits images In-Reply-To: <000001caabc6$af860270$d4e8810a@gnb.st.com> References: <000001caabc6$af860270$d4e8810a@gnb.st.com> Message-ID: I have a similar question. PIL supports 16 bit integer for single band images, but not multi-band images. Messing around a bit with the 1.16 version, I find that many of the operations in the library are for 8 bit bands only. ImageMagick has python bindings and supports a wide variety of formats, check it out. On Fri, Feb 12, 2010 at 1:35 AM, Nicolas ROUX wrote: > Hello, > We need to load/save RGB images in more than 8 bits and up to 16bits. > We use to work with TIFF, PNG, BMP, ... > > Is there a plan to support such RGB bitwidth (and so associated file format) ? > > Thanks, > > Cheers, > Nicolas. > > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From cannon.el at gmail.com Wed Feb 17 06:57:18 2010 From: cannon.el at gmail.com (Laura & Edward Cannon) Date: Tue, 16 Feb 2010 21:57:18 -0800 Subject: [Image-SIG] ImageStat silent convert Message-ID: while using PIL 1.16 recently, I noticed that ImageStat seems to do a silent convert to mode L when given a mode F image. Looping though the image manually using the im.load() access object gives me a different maximum than ImageStat.Stat(im).extrema. Is this intentional? it doesn't seem to be documented. Is it perhaps been fixed? Edward Unicorn School From wrybread at gmail.com Wed Feb 17 12:30:23 2010 From: wrybread at gmail.com (Alec Bennett) Date: Wed, 17 Feb 2010 03:30:23 -0800 Subject: [Image-SIG] How to improve rotation quality? Message-ID: I'm wondering if anyone has any idea how to get better results from PIL's rotate() function? No matter what filter I use I'm getting very jagged edges after rotating an image. Here's how I'm invoking the filters: pic = pic.rotate(random_rotation, resample=Image.NEAREST, expand=1) pic = pic.rotate(random_rotation, resample=Image.BILINEAR, expand=1) pic = pic.rotate(random_rotation, resample=Image.BICUBIC, expand=1) # the best I think I posted a sample app that opens an image and rotates it using each of the filters. You can see the jagged edges pretty plainly. I have a slideshow app that I'm working on where these edges are very obvious, so I'm wondering if anyone might have any tips on getting better results from rotate(), or from some other method or module that might do a better job? My very simple sample app that tests each of the filters is here: http://sinkingsensation.com/stuff/rotation_test.zip -------------- next part -------------- An HTML attachment was scrubbed... URL: From cannon.el at gmail.com Wed Feb 17 23:12:41 2010 From: cannon.el at gmail.com (Laura & Edward Cannon) Date: Wed, 17 Feb 2010 14:12:41 -0800 Subject: [Image-SIG] How to improve rotation quality? In-Reply-To: References: Message-ID: Try using Image.ANTIALIAS, I find it has the best quality. On Wed, Feb 17, 2010 at 3:30 AM, Alec Bennett wrote: > I'm wondering if anyone has any idea how to get better results from PIL's > rotate() function? No matter what filter I use I'm getting very jagged edges > after rotating an image. > > Here's how I'm invoking the filters: > > pic = pic.rotate(random_rotation, resample=Image.NEAREST, expand=1) > pic = pic.rotate(random_rotation, resample=Image.BILINEAR, expand=1) > pic = pic.rotate(random_rotation, resample=Image.BICUBIC, expand=1)??? # the > best I think > > I posted a sample app that opens an image and rotates it using each of the > filters. You can see the jagged edges pretty plainly. > > I have a slideshow app that I'm working on where these edges are very > obvious, so I'm wondering if anyone might have any tips on getting better > results from rotate(), or from some other method or module that might do a > better job? > > My very simple sample app that tests each of the filters is here: > > http://sinkingsensation.com/stuff/rotation_test.zip > > > > _______________________________________________ > Image-SIG maillist ?- ?Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > From Chris.Barker at noaa.gov Wed Feb 17 23:38:03 2010 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Wed, 17 Feb 2010 14:38:03 -0800 Subject: [Image-SIG] How to improve rotation quality? In-Reply-To: References: Message-ID: <4B7C6FCB.2000909@noaa.gov> Alec Bennett wrote: > I'm wondering if anyone has any idea how to get better results from > PIL's rotate() function? No matter what filter I use I'm getting very > jagged edges after rotating an image. > > Here's how I'm invoking the filters: > > pic = pic.rotate(random_rotation, resample=Image.NEAREST, expand=1) > pic = pic.rotate(random_rotation, resample=Image.BILINEAR, expand=1) > pic = pic.rotate(random_rotation, resample=Image.BICUBIC, expand=1) # > the best I think Too bad ANTIALIAS doesn't seem to be available for rotate -- darn. It might look better. But to some extent, you can only get so good rotating an image. However, I took at look at your test images -- it looked like better smoothing was going on inside the white border than outside, which made me think -- when rotating, if you are going to use interpolation, how does it interpolate to outside the image? It doesn't. So I tried adding a black background to the image first, then rotating it -- much better. See the enclosed version of your test code, and a rotated image. -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 -------------- A non-text attachment was scrubbed... Name: test.py Type: application/x-python Size: 961 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: test-3.jpg Type: image/jpeg Size: 42962 bytes Desc: not available URL: From johan at slentrian.org Thu Feb 18 10:23:48 2010 From: johan at slentrian.org (Johan Forsberg) Date: Thu, 18 Feb 2010 10:23:48 +0100 Subject: [Image-SIG] Floodfill Message-ID: <27d300711002180123p53644bb5pe35899c6743529cf@mail.gmail.com> Hello, I have been using PIL to write a simple drawing program and it's been great fun. The only thing I've really been missing from the library is a fast flood-fill routine. The included python based floodfill, while functional, is very slow (in 1.1.7), I guess due to the per-pixel access required. Since I want interactive speed, I decided to try and hack in a floodfill function in C. Instead of reinventing the wheel, I googled up a nice implementation in the "graphics gems" collection ( http://tog.acm.org/resources/GraphicsGems/) which needed only small modifications in order to work with the PIL code. I havent benchmarked it but it's (not surprisingly) orders of magnitudes faster than the python routine. I've only implemented it for 8-bit palette image formats since that's what I use, but it should be easy to generalize. Would it be a good idea to clean this up and submit it as a patch to PIL? The graphics gems license is very liberal and seems to me to be compatible (this is what I found on the webpage above): ---8<--- The Graphics Gems code is copyright-protected. In other words, you cannot claim the text of the code as your own and resell it. Using the code is permitted in any program, product, or library, non-commercial or commercial. Giving credit is not required, though is a nice gesture. ---8<--- Cheers, Johan -------------- next part -------------- An HTML attachment was scrubbed... URL: From wrybread at gmail.com Thu Feb 18 12:50:01 2010 From: wrybread at gmail.com (Alec Bennett) Date: Thu, 18 Feb 2010 03:50:01 -0800 Subject: [Image-SIG] How to improve rotation quality? In-Reply-To: <4B7C6FCB.2000909@noaa.gov> References: <4B7C6FCB.2000909@noaa.gov> Message-ID: > So I tried adding a black background to the image first, then rotating it -- much better. > See the enclosed version of your test code, and a rotated image. Wow, what a difference! Even if the border is a single pixel, much better results. I set the border color to grey, which seems to work as well as black, and am now a happy slideshow maker. Huge thanks. And to anyone else coming down this road, if the resampling filters aren't having any effect, update to the latest PIL. -------------- next part -------------- An HTML attachment was scrubbed... URL: From karsten.hiddemann at mathematik.uni-dortmund.de Fri Feb 19 21:53:25 2010 From: karsten.hiddemann at mathematik.uni-dortmund.de (Karsten Hiddemann) Date: Fri, 19 Feb 2010 21:53:25 +0100 Subject: [Image-SIG] Floodfill In-Reply-To: <27d300711002180123p53644bb5pe35899c6743529cf@mail.gmail.com> References: <27d300711002180123p53644bb5pe35899c6743529cf@mail.gmail.com> Message-ID: <4B7EFA45.5020805@mathematik.uni-dortmund.de> Johan Forsberg wrote: > Hello, > > I have been using PIL to write a simple drawing program and it's been > great fun. The only thing I've really been missing from the library is a > fast flood-fill routine. The included python based floodfill, while > functional, is very slow (in 1.1.7), I guess due to the per-pixel access > required. Since I want interactive speed, I decided to try and hack in a > floodfill function in C. Just wanted to add that I remember that somebody else did that as well. This is a post from the list by Douglas Bagnall on 01.06.2009 02:23, original title "[Image-SIG] remove an image background using PIL" > Peter Yen wrote: > >> Thanks for your quick response. The background is unknown at the time of >> processing. Actually I don't need a very accurate methodology to remove all >> background, removing partially is good enough. > > I once wrote a (GPL'd) C module that fairly reliably extracts the > background of a photograph of a drawing on paper. It is essentially the > same as PIL's floodfill but it follows shallow gradients. > > The public git browser[1] seems to be broken right now, but if this > sounds like what you need download a tarball[2], and look for the > expand_region function in the img-c directory. > > [1] https://savannah.nongnu.org/git/?group=tetuhi > [2] http://sourceforge.net/project/showfiles.php?group_id=217385 > > > Douglas Cheers, Karsten From Chris.Barker at noaa.gov Fri Feb 19 23:42:57 2010 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Fri, 19 Feb 2010 14:42:57 -0800 Subject: [Image-SIG] How to improve rotation quality? In-Reply-To: References: <4B7C6FCB.2000909@noaa.gov> Message-ID: <4B7F13F1.9020200@noaa.gov> Alec Bennett wrote: > > So I tried adding a black background to the image first, then > rotating it -- much better. > > See the enclosed version of your test code, and a rotated image. > > Wow, what a difference! Even if the border is a single pixel, much > better results. I set the border color to grey, which seems to work as > well as black, and am now a happy slideshow maker. Ideally, you should use whatever color is going to be in the background when you show the image. Even better would be if you could blend it with a transparent background, and show it that way, but that would require an alpha channel, and I don't think jpeg supports that. Glad it worked for you, -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 uricchio at gmail.com Mon Feb 22 16:38:08 2010 From: uricchio at gmail.com (Tiberio Uricchio) Date: Mon, 22 Feb 2010 16:38:08 +0100 Subject: [Image-SIG] Radius bug with GaussianBlur Message-ID: Hi, i just wanted to report a simple bug in ImageFilter.GaussianBlur: class GaussianBlur(Filter): name = "GaussianBlur" def __init__(self, radius=2): self.radius = 2 def filter(self, image): return image.gaussian_blur(self.radius) As you can see, radius is always fixed at value 2 instead of using the argument value. Tiberio From wrybread at gmail.com Sat Feb 20 04:39:42 2010 From: wrybread at gmail.com (Alec Bennett) Date: Fri, 19 Feb 2010 19:39:42 -0800 Subject: [Image-SIG] How to improve rotation quality? In-Reply-To: <4B7F13F1.9020200@noaa.gov> References: <4B7C6FCB.2000909@noaa.gov> <4B7F13F1.9020200@noaa.gov> Message-ID: > Ideally, you should use whatever color is going to be in the background when you show the image. Agreed, but the problem is I'm making a collage of pictures where the new pictures are placed above previous pictures, so there's no one consistent background color. > Even better would be if you could blend it with a transparent background, and show it that way, > but that would require an alpha channel, and I don't think jpeg supports that. I'm converting to BMP and assigning an alpha channel so this is indeed a possibility. Another thought I had was making a drop shadow effect, which the thin gray edge outside of my white border already approximates. Interestingly, when I've tried making a transparent canvas in PIL (which I'd have to do to add an alpha border) in the past, I consistently got weird artifacts in the transparent areas. The workaround I used was to make a small blank PNG that was pure alpha and resize it as necessary. If I test out the alpha border I'll post back to this thread. -------------- next part -------------- An HTML attachment was scrubbed... URL: From lutz at rmi.net Sun Feb 21 14:53:22 2010 From: lutz at rmi.net (lutz at rmi.net) Date: Sun, 21 Feb 2010 08:53:22 -0500 (GMT-05:00) Subject: [Image-SIG] PIL for Python 3.X? Message-ID: <6392297.1266760402700.JavaMail.root@mswamui-bichon.atl.sa.earthlink.net> (Having trouble getting in touch with Fredrik on short notice, so I'm giving this list a shot). Does anyone have a definitive answer on if/when PIL will become available for Python 3.1? It seems to have stalled last year. Barring that, are there any reasonable and portable alternatives for using jpegs in tkinter? Either way, this needs to be an official-type release, that can be used by the masses. I'm updating the book Programming Python for 3.X (only), and it uses PIL extensively for image display, thumbnails, and the like. Using 2.X-compatible code for the PIL examples isn't a great option; tkinter's naming/structure has changed much. And I can't really use PIL at all if its 3.X future is unclear. Unfortunately, I need a decision on PIL for 3.X in the next week or two due to book schedules (and can't work on a port myself for the same reason). My last resort is to use one of tk's native image formats and relegate PIL to a footnote. Thanks, --Mark Lutz From sflist at ihonk.com Mon Feb 22 08:05:13 2010 From: sflist at ihonk.com (Steve Freitas) Date: Sun, 21 Feb 2010 23:05:13 -0800 Subject: [Image-SIG] n00b Question Message-ID: <1266822313.16307.414.camel@phat> Hi all, I've downloaded image data[1] which has no header and is comprised of 16-bit signed big-endian pixels (it's a heightmap). I figured I'd cull a portion of the data and turn it into a TIFF so I could check it out visually to make sure it looks kinda like a heightmap should. However, I seem to be doing something wrong. I've read the data into a string (not unicode, and the file was opened with 'rb'), and I'm using essentially this code to generate a TIFF: f = open('data.bin', 'rb') data = f.read() p = Image.fromstring('F', (tile_width, tile_height), data, 'raw', 'F;16BS', 0, 1) p.save('foo.tiff') I've verified that I'm pulling data that isn't just a bunch of zeros, and I've verified that the generated TIFF isn't just a bunch of zeros, but when I view it I get the checkerboard pattern which seems to indicate a translucent image. Or something. Part of my confusion comes from the interrelation between the two "mode" arguments to Image.fromstring(). I guess the first one indicates the kind of output mode you want, and the second one indicates the raw decoder to use? But why am I specifying 'F' if the input data is all integers? I tried changing them respectively to 'I' and 'I;16BS', but that didn't change the resulting blank image. Any tips appreciated! Thanks, Steve [1] http://visibleearth.nasa.gov/view_rec.php?id=8391 -------------- next part -------------- An HTML attachment was scrubbed... URL: From sflist at ihonk.com Tue Feb 23 05:48:15 2010 From: sflist at ihonk.com (Steve Freitas) Date: Mon, 22 Feb 2010 20:48:15 -0800 Subject: [Image-SIG] n00b Question In-Reply-To: <1266822313.16307.414.camel@phat> References: <1266822313.16307.414.camel@phat> Message-ID: <1266900495.16307.1733.camel@phat> On Sun, 2010-02-21 at 23:05 -0800, Steve Freitas wrote: > I've verified that I'm pulling data that isn't just a bunch of zeros, > and I've verified that the generated TIFF isn't just a bunch of zeros, > but when I view it I get the checkerboard pattern which seems to > indicate a translucent image. Or something. Solved. Turns out that I needed to a) Change the mode to 'I', the raw decoder mode to 'I;16BS' and save it as a PNG. I wonder if I just needed to set alpha somehow on the TIFF, but no biggie, a PNG gave me what I needed and I can use gimp to convert it to a TIFF if that's the format my 3D scene manager needs. Steve -------------- next part -------------- An HTML attachment was scrubbed... URL: From joeoettinger at gmail.com Tue Feb 23 11:57:55 2010 From: joeoettinger at gmail.com (joe oettinger) Date: Tue, 23 Feb 2010 05:57:55 -0500 Subject: [Image-SIG] PIL and Python 3.1 Message-ID: First, I'd like to say thanks to Fredrik Lundh and those working with him for the huge and effective effort they've expended to establish and maintain PIL. Second, that PIL for python 3.1 would be a wonderful advance. Personally, I just dabble in Python, but I've got an interesting story to tell: My son, who writes software for TI, recently wanted to help his 10-year-old learn to program. I suggested Python. He downloaded the latest version of Python and bought "Python Programming for the Absolute Beginner" (which uses PIL and Pygames). He's a very busy engineer. The kid is bright, but has many other interests. As you will have guessed, they've postponed their project for a while. I'm sure that lack of support libraries like PIL and numpy has slowed the adoption of Python 3.x. I'd guess that the uncertainty about which version to use has even slowed the overall adoption of Python by new users. Conversely, Python3.x with PIL and other support libraries would be unbeatable - a beautiful intellectual achievement. Thanks again to Lundh et al for all their selfless work! Joe Oettinger -------------- next part -------------- An HTML attachment was scrubbed... URL: From jared0x90 at gmail.com Tue Feb 23 18:11:37 2010 From: jared0x90 at gmail.com (Jared De Blander) Date: Tue, 23 Feb 2010 12:11:37 -0500 Subject: [Image-SIG] PIL and Python 3.1 In-Reply-To: References: Message-ID: <2960ed0a1002230911s326d2444xc40ac82aeb867d3f@mail.gmail.com> This sort of describes the situation I have just recently ran into. I wanted to fiddle with a wireless IP cam I picked up to monitor my driveway as the included software was garbage and decided to try Python as I had been wanting to learn it for sometime. Well 100 lines into my first real attempt at a python3 program I realized that I needed PIL and had to revert back to python2. I know asking for something like this to be converted is a tall tall order but as it seems to be in the works I just wanted to give it my +1 again On Tue, Feb 23, 2010 at 5:57 AM, joe oettinger wrote: > First, I'd like to say thanks to Fredrik Lundh and those working with him > for the huge and effective effort they've expended to establish and maintain > PIL. > > Second, that PIL for python 3.1 would be a wonderful advance. > > Personally, I just dabble in Python, but I've got an interesting story to > tell: > > My son, who writes software for TI, recently wanted to help his 10-year-old > learn to program. I suggested Python. He downloaded the latest version of > Python and bought "Python Programming for the Absolute Beginner" (which uses > PIL and Pygames). He's a very busy engineer. The kid is bright, but has many > other interests. As you will have guessed, they've postponed their project > for a while. > > I'm sure that lack of support libraries like PIL and numpy has slowed the > adoption of Python 3.x. I'd guess that the uncertainty about which version > to use has even slowed the overall adoption of Python by new users. > > Conversely, Python3.x with PIL and other support libraries would be > unbeatable - a beautiful intellectual achievement. > > Thanks again to Lundh et al for all their selfless work! > > Joe Oettinger > > _______________________________________________ > 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 william.t.bridgman at nasa.gov Fri Feb 26 14:42:11 2010 From: william.t.bridgman at nasa.gov (Bridgman, William T.) Date: Fri, 26 Feb 2010 08:42:11 -0500 Subject: [Image-SIG] Bug Report: PIL font management clipping tops of characters (addendum) Message-ID: <4057D068-DBA4-4379-85A1-EA35BEE198A9@nasa.gov> This happens with at least Python 2.4 (LInux) PIL 1.1.6 Python 2.6 (Mac OS X 10.5.+), PIL 1.1.6 Release notes for 1.1.7 suggest something like this might have been fixed in 1.1.6b1 but no clear indication in 1.1.7. Tom -- Dr. William T."Tom" Bridgman Scientific Visualization Studio Global Science & Technology, Inc. NASA/Goddard Space Flight Center Email: William.T.Bridgman at nasa.gov Code 610.3 Phone: 301-286-1346 Greenbelt, MD 20771 FAX: 301-286-1634 http://svs.gsfc.nasa.gov/ From william.t.bridgman at nasa.gov Fri Feb 26 14:29:43 2010 From: william.t.bridgman at nasa.gov (Bridgman, William T.) Date: Fri, 26 Feb 2010 08:29:43 -0500 Subject: [Image-SIG] Bug report: PIL font management clipping tops of characters Message-ID: Such as the circle atop the characters: ? ?, used in Angstrom. Sample code & graphic output below. #!/usr/bin/env python # -*- coding: utf-8 -*- from PIL import Image, ImageFont, ImageDraw titleFont=ImageFont.truetype('HelveticaBold.ttf',32,encoding='unic') size=(128,128) image=Image.new('RGB',size,(0,0,0)) draw=ImageDraw.Draw(image) teststr=unichr(0x00e5)+unichr(0x00c5) textsize=draw.textsize(teststr,font=titleFont) xposition=0 yposition=textsize[1] draw .text((xposition,yposition),teststr,font=titleFont,fill=(255,255,255)) image.save('fonttest.tif','TIFF') -------------- next part -------------- A non-text attachment was scrubbed... Name: fonttest.tif Type: image/tiff Size: 49280 bytes Desc: not available URL: -------------- next part -------------- Thanks, Tom -- Dr. William T."Tom" Bridgman Scientific Visualization Studio Global Science & Technology, Inc. NASA/Goddard Space Flight Center Email: William.T.Bridgman at nasa.gov Code 610.3 Phone: 301-286-1346 Greenbelt, MD 20771 FAX: 301-286-1634 http://svs.gsfc.nasa.gov/ From William.T.Bridgman at nasa.gov Fri Feb 26 15:06:52 2010 From: William.T.Bridgman at nasa.gov (Bridgman, William T.) Date: Fri, 26 Feb 2010 09:06:52 -0500 Subject: [Image-SIG] Bug Report: PIL font management clipping tops of characters (addendum) Message-ID: <7F24AB15-5A47-47A8-B777-B5D1E20EE93B@nasa.gov> Also happens with Python 2.5.1 (Mac OS X 10.5.+), PIL 1.1.7 This happens with at least Python 2.4 (LInux) PIL 1.1.6 Python 2.6 (Mac OS X 10.5.+), PIL 1.1.6 Release notes for 1.1.7 suggest something like this might have been fixed in 1.1.6b1 but no clear indication in 1.1.7. Tom -- Dr. William T."Tom" Bridgman Scientific Visualization Studio Global Science & Technology, Inc. NASA/Goddard Space Flight Center Email: William.T.Bridgman at nasa.gov Code 610.3 Phone: 301-286-1346 Greenbelt, MD 20771 FAX: 301-286-1634 http://svs.gsfc.nasa.gov/