From dakotajszabo at gmail.com Sat Jun 2 02:32:02 2012 From: dakotajszabo at gmail.com (Dakota Szabo) Date: Fri, 1 Jun 2012 20:32:02 -0400 Subject: [Image-SIG] Image show Message-ID: Good evening, I'm running Python 2.7 using PIL on Ubuntu 12.04; I'm trying to use Image.show() to display an image. The temp image file is saved to /tmp and XV (which calls the Gnome default image viewer) is launched to view the image, but the Gnome default image viewer can't identify the type of image correctly. Appending ".ppm" to the end of the temp file name seems to correct the issue; I've created a patch to correct what seems like a PIL issue, but I'm not sure if PIL is really at fault here or if there might be something wrong with my environment. Source code that exhibits the issue: http://pastebin.com/8278wS9t Patch file that seems to correct the issue: http://pastebin.com/UfmHjemU Thanks for any assistance! Dakota Szabo -------------- next part -------------- An HTML attachment was scrubbed... URL: From cannon.el at gmail.com Wed Jun 6 17:31:22 2012 From: cannon.el at gmail.com (Edward Cannon) Date: Wed, 6 Jun 2012 08:31:22 -0700 Subject: [Image-SIG] PIL and multiprocessing module In-Reply-To: References: Message-ID: <618884D1-97D4-4957-8DFD-F5F60A355D9B@gmail.com> You can convert the image to an array and then do whatever you want. Look in the Image documentation. On May 13, 2012, at 2:11 PM, John Anderson wrote: > I was wondering if anyone has used PIL with the multiprocessing module. > > I would like to do some pixel by pixel translations using the .load() function and shared memory with the multiprocessing module. > > > This is the code I have so far: > def convert_to_gs_load(surf): > width, height = surf.size > pix = surf.load() > > for x in range(width): > for y in range(height): > alpha = 1 > red, green, blue = pix[x, y] > average = (red + green + blue) // 3 > gs_color = (average, average, average, alpha) > pix[x, y] = gs_color > > def convert_to_gs_load_mp(surf): > width, height = surf.size > pix = surf.load() > > t1 = multiprocessing.Process(target=gs_load, args=(pix, width, 0, height / 4)) > t2 = multiprocessing.Process(target=gs_load, args=(pix, width, height / 4, height / 2)) > t3 = multiprocessing.Process(target=gs_load, args=(pix, width, height / 2, 3 * height / 4)) > t4 = multiprocessing.Process(target=gs_load, args=(pix, width, 3 * height / 4, height)) > threads = [t1, t2, t3, t4] > > for thread in threads: > thread.start() > > for thread in threads: > thread.join() > > The problem is the 'pix' object is not in shared memory, so this doesn't work. Is there a way I could use Value or Array to store the object? > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig From chris.barker at noaa.gov Tue Jun 19 21:24:49 2012 From: chris.barker at noaa.gov (Chris Barker) Date: Tue, 19 Jun 2012 12:24:49 -0700 Subject: [Image-SIG] Initializing a 'P' image Message-ID: HI folks, I'm creating, then drawing to, a "P" paletted image. I like how ImageDraw will let you set the colors as you drawm and it will automaticaly get added to teh palette. However, I can't see how to initialize the image with a given background (fill) color: In [35]: Image.new('P', (10,10), color=(255,255,255)) TypeError: an integer is required I can set color to 0 (Or, presumabley any other 8-bit integer), but then there is no color added to the palette, so it will get whatever I happend to draw first. So I've ended up doing this: self.image = Image.new('P', size, color=0) drawer = ImageDraw.Draw(self.image) # couldn't find a better way to initilize the colors right. drawer.rectangle(((0,0), size), fill=self.background_color) but that sure feels kludgy -- have I missed something? Of course, I could manage the palette myself, but that's uglier... -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 german.mb at gmail.com Thu Jun 21 00:55:38 2012 From: german.mb at gmail.com (=?UTF-8?Q?Germ=C3=A1n_M=2E_Bravo?=) Date: Wed, 20 Jun 2012 17:55:38 -0500 Subject: [Image-SIG] Bug in PIL's quantize() Message-ID: I found a nasty bug in PIL's quantize(), in Quant.c, map_image_pixels_from_median_box(), the `int pixelVal;` definition must be `unsigned long pixelVal;` instead... This was making PIL crash under certain circumstances in my system (64 bit Mac OS X Lion 10.7.4 using llvm-gcc4.2). Patch follows: -------- CUT HERE -------- --- libImaging/Quant.c.orig 2012-06-20 17:53:49.000000000 -0500 +++ libImaging/Quant.c 2012-06-20 17:53:51.000000000 -0500 @@ -914,7 +914,7 @@ unsigned long bestdist,bestmatch,dist; unsigned long initialdist; HashTable h2; - int pixelVal; + unsigned long pixelVal; h2=hashtable_new(unshifted_pixel_hash,unshifted_pixel_cmp); for (i=0;i