From charlie at begeistert.org Mon Jan 5 14:50:53 2009 From: charlie at begeistert.org (Charlie Clark) Date: Mon, 5 Jan 2009 14:50:53 +0100 Subject: [Image-SIG] Problem with rendering accented capitals in text Message-ID: <0D6D0090-1348-4A5A-9E4F-53C26E75AC64@begeistert.org> Hiya, this is a simple and I would have thought a common problem but I haven't been able to find it raised elsewhere. Characters such as ??? are all missing their diaresises when rendered as capitals and this is independent of the typeface used. I've played around a bit and have not been able to fix it - all the magic seems to happen in the font.render() method in _imagingft and this is probably dependent upon Freetype code. But maybe someone out there knows of a workaround? Thanks very much and a happy new year! Charlie -- Charlie Clark Helmholtzstr. 20 D?sseldorf D- 40215 Tel: +49-211-938-5360 GSM: +49-178-782-6226 From fredrik at pythonware.com Mon Jan 5 17:23:21 2009 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 5 Jan 2009 17:23:21 +0100 Subject: [Image-SIG] Problem with rendering accented capitals in text In-Reply-To: <0D6D0090-1348-4A5A-9E4F-53C26E75AC64@begeistert.org> References: <0D6D0090-1348-4A5A-9E4F-53C26E75AC64@begeistert.org> Message-ID: <368a5cd50901050823p4db8e176qf72d2cffe614c34@mail.gmail.com> This has been reported by some, but I do use the truetype bindings to render swedish text myself, and it's also tested by our internal tests. My guess is that it's either depends on the font or the freetype version. Does it happen for all fonts for you? (if you want, you can mail me a copy of the font file and a small snippet that illustrates the problem via private mail, so I can take a look at your specific case). On Mon, Jan 5, 2009 at 2:50 PM, Charlie Clark wrote: > Hiya, > > this is a simple and I would have thought a common problem but I haven't > been able to find it raised elsewhere. Characters such as ??? are all > missing their diaresises when rendered as capitals and this is independent > of the typeface used. I've played around a bit and have not been able to fix > it - all the magic seems to happen in the font.render() method in _imagingft > and this is probably dependent upon Freetype code. But maybe someone out > there knows of a workaround? > > Thanks very much and a happy new year! > > Charlie > -- > Charlie Clark > Helmholtzstr. 20 > D?sseldorf > D- 40215 > Tel: +49-211-938-5360 > GSM: +49-178-782-6226 > > > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From nick.pye at gmail.com Thu Jan 1 22:12:28 2009 From: nick.pye at gmail.com (nicholas Pye) Date: Thu, 1 Jan 2009 21:12:28 +0000 Subject: [Image-SIG] memory leak error / PIL Image Message-ID: Hello, I have a peice of code that repeatidly draws new images (draw_image) and then compares the images drawn against an origional image (image_cost). If I remove the PIL functions in these functions the rest of the code runs fine, and does not exhibit a memory leak, however when using PIL repeatidally in these functions I soon run out of memory. It's as if PIL is caching the images in memory or not cleaning up memory ... I've tried png, gif formats all eventually give a malloc of the period of the code run. error Python(2046) malloc: *** mmap(size=16777216) failed (error code=12) def draw_image(popmember,path,img_tick,poly_vector_len): img=Image.new('RGB',(300,300),(0,0,0)) d = aggdraw.Draw(img) for strand in range(len(popmember)): vector = split_strand(popmember[strand],"vec",poly_vector_len) rgb = split_strand(popmember[strand],"rgb",poly_vector_len) alpha = split_strand(popmember[strand],"alpha",poly_vector_len) b = aggdraw.Brush(tuple(rgb),alpha[0]) d.polygon(vector,b) d.flush() img.save(path + str(img_tick) + '.jpg','PNG') def image_cost(path,image2,img_tick): h1 = Image.open(path+image2).histogram() h2 = Image.open(path+str(img_tick)+'.png').histogram() rms = math.sqrt(reduce(operator.add,map(lambda a,b: (a-b)**2, h1, h2))/len(h1)) return rms -------------- next part -------------- An HTML attachment was scrubbed... URL: From bing.jian at gmail.com Fri Jan 2 05:09:21 2009 From: bing.jian at gmail.com (Bing Jian) Date: Thu, 1 Jan 2009 23:09:21 -0500 Subject: [Image-SIG] Specify line width in draw.rectangle Message-ID: Hi all, Does anyone know how to specify the line width in draw.rectangle(box,options)? Many thanks in advance and happy new year! Bing -------------- next part -------------- An HTML attachment was scrubbed... URL: From spinboy_1999 at yahoo.com Sat Jan 3 00:58:45 2009 From: spinboy_1999 at yahoo.com (Marcello Lioy) Date: Fri, 2 Jan 2009 15:58:45 -0800 (PST) Subject: [Image-SIG] selftest failing Message-ID: <916494.43024.qm@web34408.mail.mud.yahoo.com> I have downloaded the JPG library and built it. I also downloaded and built 1.1.6 and build it sucessfully - the outfput from the build process is: -------------------------------------------------------------------- PIL 1.1.6 BUILD SUMMARY -------------------------------------------------------------------- version 1.1.6 platform linux2 2.4.1 (#2, Oct 18 2006, 22:35:03) [GCC 3.3.5 (Debian 1:3.3.5-13)] -------------------------------------------------------------------- *** TKINTER support not available --- JPEG support ok *** ZLIB (PNG/ZIP) support not available *** FREETYPE2 support not available -------------------------------------------------------------------- The only one I care about is jpeg, and oddly when I run the self test I get the following error: ***************************************************************** 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 180, in load d = Image._getdecoder(self.mode, d, a, self.decoderconfig) File "PIL/Image.py", line 375, in _getdecoder raise IOError("decoder %s not available" % decoder_name) IOError: decoder jpeg not available 1 items had failures: 1 of 57 in selftest.testimage ***Test Failed*** 1 failures. *** 1 tests of 57 failed. I am not sure how to proceed from here as the build seems to indicate that JPEG support is there, while one of the tests is clearly failing... - I don't want to look away I don't want to be the one denied It ain't no fault of mine Someone, somewhere told you lies - Duncan Sheik -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Mon Jan 5 17:41:24 2009 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 5 Jan 2009 17:41:24 +0100 Subject: [Image-SIG] malloc error In-Reply-To: <40509F14-8DD7-43B8-AC6B-E6D0D48D7964@gmail.com> References: <40509F14-8DD7-43B8-AC6B-E6D0D48D7964@gmail.com> Message-ID: <368a5cd50901050841p1b25bcdam5705d8b3512e7c4e@mail.gmail.com> What version of aggdraw are you using? The Draw(im) form is buggy in some versions; it doesn't release the im object when the draw object goes away. Here's a workaround (cut and pasted from an old message to this list): as a workaround, you can use the original constructor syntax instead, together with fromstring/tostring: d = Draw(im.mode, im.size) d.fromstring(im.tostring()) # draw your stuff im.fromstring(d.tostring()) 2008/12/31 nicholas Pye : > Hello, > I have a peice of code that repeatidly draws new images (draw_image) and > then compares the images drawn against an origional image (image_cost). > If I remove the PIL functions in these functions the rest of the code runs > fine, and does not exhibit a memory leak, however when using PIL > repeatidally in these functions I soon run out of memory. It's as if PIL is > caching the images in memory or not cleaning up memory ... I've tried png, > gif formats all eventually give a malloc of the period of the code run. > error > Python(2046) malloc: *** mmap(size=16777216) failed (error code=12) > > def draw_image(popmember,path,img_tick,poly_vector_len): > img=Image.new('RGB',(300,300),(0,0,0)) > d = aggdraw.Draw(img) > for strand in range(len(popmember)): > vector = split_strand(popmember[strand],"vec",poly_vector_len) > rgb = split_strand(popmember[strand],"rgb",poly_vector_len) > alpha = split_strand(popmember[strand],"alpha",poly_vector_len) > b = aggdraw.Brush(tuple(rgb),alpha[0]) > d.polygon(vector,b) > d.flush() > img.save(path + str(img_tick) + '.jpg','PNG') > def image_cost(path,image2,img_tick): > h1 = Image.open(path+image2).histogram() > h2 = Image.open(path+str(img_tick)+'.png').histogram() > rms = math.sqrt(reduce(operator.add,map(lambda a,b: (a-b)**2, h1, > h2))/len(h1)) > return rms > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > From ggpolo at gmail.com Mon Jan 5 18:42:33 2009 From: ggpolo at gmail.com (Guilherme Polo) Date: Mon, 5 Jan 2009 15:42:33 -0200 Subject: [Image-SIG] Infinite loop in PIL/ImageFont.py Message-ID: Hi, There is an infinite loop in PIL/ImageFont.py (PIL 1.1.6) which can be entered by using ImageFont.load. Found this while testing the py3k port, but the attached patch is against the standard one. -- -- Guilherme H. Polo Goncalves -------------- next part -------------- A non-text attachment was scrubbed... Name: ImageFont.diff Type: text/x-patch Size: 543 bytes Desc: not available URL: From charlie at begeistert.org Tue Jan 6 10:14:32 2009 From: charlie at begeistert.org (Charlie Clark) Date: Tue, 6 Jan 2009 10:14:32 +0100 Subject: [Image-SIG] Problem with rendering accented capitals in text In-Reply-To: <368a5cd50901050823p4db8e176qf72d2cffe614c34@mail.gmail.com> References: <0D6D0090-1348-4A5A-9E4F-53C26E75AC64@begeistert.org> <368a5cd50901050823p4db8e176qf72d2cffe614c34@mail.gmail.com> Message-ID: <2143DCCD-8929-487E-AC11-19C15A7F3EE5@begeistert.org> Am 05.01.2009 um 17:23 schrieb Fredrik Lundh: > This has been reported by some, but I do use the truetype bindings to > render swedish text myself, and it's also tested by our internal > tests. My guess is that it's either depends on the font or the > freetype version. Does it happen for all fonts for you? While it did seem to affect all our fonts, it may only be Helvetica. If this is the case I wonder whether using small caps would be a reasonable workaround. > (if you want, you can mail me a copy of the font file and a small > snippet that illustrates the problem via private mail, so I can take a > look at your specific case). Thanks. Font sent in a separate e-mail. Charlie -- Charlie Clark Helmholtzstr. 20 D?sseldorf D- 40215 Tel: +49-211-938-5360 GSM: +49-178-782-6226 From cab938 at mail.usask.ca Thu Jan 8 02:18:19 2009 From: cab938 at mail.usask.ca (cab938 at mail.usask.ca) Date: Wed, 7 Jan 2009 19:18:19 -0600 Subject: [Image-SIG] Fast cropping In-Reply-To: References: Message-ID: <1231377499.4965545b40212@webmail.usask.ca> I have the need to break a single large image up (3 colour bands) into a series of smaller images in a grid-like fashion. The code we have written write now works, but it's really slow - we essentially walk around the image cropping and loading to return new PIL Image objects. Any suggestions on a faster way? Should I be using fromBuffer() and pixelaccess to create my sub-images? I want Image objects as I use a number of PIL methods after that, I just don't know the fastest way to create them. Regards, Chris From g.kloss at massey.ac.nz Thu Jan 8 03:10:41 2009 From: g.kloss at massey.ac.nz (Guy K. Kloss) Date: Thu, 8 Jan 2009 15:10:41 +1300 Subject: [Image-SIG] Fast cropping In-Reply-To: <1231377499.4965545b40212@webmail.usask.ca> References: <1231377499.4965545b40212@webmail.usask.ca> Message-ID: <200901081510.41464.g.kloss@massey.ac.nz> On Thu, 08 Jan 2009 14:18:19 cab938 at mail.usask.ca wrote: > I have the need to break a single large image up (3 colour bands) into a > series of smaller images in a grid-like fashion. ?The code we have written > write now works, but it's really slow - we essentially walk around the > image cropping and loading to return new PIL Image objects. ?Any > suggestions on a faster way? Should I be using fromBuffer() and pixelaccess > to create my sub-images? ?I want Image objects as I use a number of PIL > methods after that, I just don't know the fastest way to create them. Have you tried to convert the PIL image into a NumPy image, and then just use the slicing operations? After getting those sub-arrays as slices convert them back to PIL arrays. Just a thought, as NumPy is actually quite fast, but don't know whether it compares to what you're doing now. Guy -- Guy K. Kloss Institute of Information and Mathematical Sciences Te Kura P?taiao o M?hiohio me P?ngarau Room 2.63, Quad Block A Building Massey University, Auckland, Albany Private Bag 102 904, North Shore Mail Centre voice: +64 9 414-0800 ext. 9585 fax: +64 9 441-8181 eMail: G.Kloss at massey.ac.nz http://iims.massey.ac.nz From pluskid at gmail.com Mon Jan 12 08:09:28 2009 From: pluskid at gmail.com (Zhang Chiyuan) Date: Mon, 12 Jan 2009 15:09:28 +0800 Subject: [Image-SIG] Bug in the mode recognition code of Image.fromarray? Message-ID: Hi all, I have a transparent png file and load it with PIL: from PIL import Image from numpy import array im = Image.open('foo.png') a = array(im) im2 = Image.fromarray(a) It should automatically determine that the mode is 'RGBA' but it failed to do so. And the result im2 is not a correct image. I looked at the code of fromarray: def fromarray(obj, mode=None): arr = obj.__array_interface__ shape = arr['shape'] ndim = len(shape) try: strides = arr['strides'] except KeyError: strides = None if mode is None: typestr = arr['typestr'] if not (typestr[0] == '|' or typestr[0] == _ENDIAN or typestr[1:] not in ['u1', 'b1', 'i4', 'f4']): raise TypeError("cannot handle data-type") typestr = typestr[:2] if typestr == 'i4': mode = 'I' elif typestr == 'f4': mode = 'F' elif typestr == 'b1': mode = '1' elif ndim == 2: mode = 'L' elif ndim == 3: mode = 'RGB' elif ndim == 4: mode = 'RGBA' else: raise TypeError("Do not understand data.") ndmax = 4 bad_dims=0 if mode in ['1','L','I','P','F']: ndmax = 2 elif mode == 'RGB': ndmax = 3 if ndim > ndmax: raise ValueError("Too many dimensions.") size = shape[:2][::-1] if strides is not None: obj = obj.tostring() return frombuffer(mode, size, obj, "raw", mode, 0, 1) it seems that when ndim is 4, the mode is set to RGBA. I'm not familiar with the various image modes. However, I think it should be that shape[-1] == 4 instead of ndim == 4. And the same thing holds for 'RGB' and == 3. Can anyone confirm me and fix this bug? Or correct me and provide a solution? BTW: I'm not on this mailing list, please CC me when replying. Thanks! -- pluskid From Chris.Barker at noaa.gov Mon Jan 12 18:12:52 2009 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Mon, 12 Jan 2009 09:12:52 -0800 Subject: [Image-SIG] Bug in the mode recognition code of Image.fromarray? In-Reply-To: References: Message-ID: <496B7A14.9030604@noaa.gov> Zhang Chiyuan wrote: > it seems that when ndim is 4, the mode is set to RGBA. I'm not familiar with > the various image modes. However, I think it should be that shape[-1] == 4 > instead of ndim == 4. And the same thing holds for 'RGB' and == 3. at first glance, I think you are correct. however, this sounds familiar, so it may have been already fixed (or a fixed posted here -- I don't know if it was applied) You might want to post this question to the numpy list -- that code was written by the numpy folks. -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 pluskid at gmail.com Tue Jan 13 02:41:09 2009 From: pluskid at gmail.com (Zhang Chiyuan) Date: Tue, 13 Jan 2009 09:41:09 +0800 Subject: [Image-SIG] Bug in the mode recognition code of Image.fromarray? In-Reply-To: <496B7A14.9030604@noaa.gov> References: <496B7A14.9030604@noaa.gov> Message-ID: After searching in the Numpy mailing list. I found a link to the Image-SIG list: http://www.mail-archive.com/image-sig at python.org/msg01482.html And this seems to fix the problem. Is this patch applied to the PIL code? If it is applied, from what version? Or maybe still not released? Thanks again. On Tue, Jan 13, 2009 at 1:12 AM, Christopher Barker wrote: > Zhang Chiyuan wrote: >> >> it seems that when ndim is 4, the mode is set to RGBA. I'm not familiar >> with >> the various image modes. However, I think it should be that shape[-1] == 4 >> instead of ndim == 4. And the same thing holds for 'RGB' and == 3. > > at first glance, I think you are correct. however, this sounds familiar, so > it may have been already fixed (or a fixed posted here -- I don't know if it > was applied) > > You might want to post this question to the numpy list -- that code was > written by the numpy folks. > > -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 > -- pluskid From bruces1 at gmail.com Tue Jan 13 16:13:54 2009 From: bruces1 at gmail.com (Bruce Sutherland) Date: Wed, 14 Jan 2009 00:13:54 +0900 Subject: [Image-SIG] Bilinear filter: unexpected results for 50 percent resize Message-ID: <858411560901130713n1910afc5y60fb37c810ad367a@mail.gmail.com> Hi everyone. I resized an 8x16 RGB image to 4x8 using PIL (1.1.6). I used the bilinear filter. The results were not exactly as I had expected. I performed the same operation using The Gimp (2.4.2), and sure enough, the result was quite different, and fit my understanding of a bilinear filter. See attached images. There seem to be two difference, one significant (for my application), and one a minor implementation detail. 1) Each pixel in The Gimp's output image can be determined by summing the pixels in each 2x2 block starting from the top left hand corner and dividing by four. This fits my understanding of a bilinear filter. I don't understand how PIL arrives at its result. 2) PIL appears to use pure integer division to average the 2x2 blocks, resulting in truncation. By contrast, Gimp's filter seems to use fractional math and round to the nearest value. I examined the resize function in the Image class, but stopped when I realised that it calls a function from the compiled imaging core library. This is my first adventure with PIL. Please forgive the attachments, but they are very small. Bruce. -------------- next part -------------- A non-text attachment was scrubbed... Name: original.png Type: image/png Size: 193 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: pil_resize_linear.png Type: image/png Size: 159 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: gimp_resize_linear.png Type: image/png Size: 141 bytes Desc: not available URL: From bruces1 at gmail.com Tue Jan 13 16:24:22 2009 From: bruces1 at gmail.com (Bruce Sutherland) Date: Wed, 14 Jan 2009 00:24:22 +0900 Subject: [Image-SIG] Bilinear filter: unexpected results for 50 percent resize Message-ID: <858411560901130724i3853e488geabdee2cb85860@mail.gmail.com> I forgot the source: import Image size = (8, 16) halfsize = (size[0]/2, size[1]/2) image = Image.open('original.png') rgb = image.convert('RGB') linear = rgb.resize(halfsize, Image.BILINEAR) linear.save('pil_resize_linear.png') From asbach at ient.rwth-aachen.de Wed Jan 14 12:17:40 2009 From: asbach at ient.rwth-aachen.de (Mark Asbach) Date: Wed, 14 Jan 2009 12:17:40 +0100 Subject: [Image-SIG] Trying to implement the array interface Message-ID: Hi there, I'm currently extending the Python wrapper for the Open Computer Vision Library (opencv) with the goal to interface numerical libraries as seemless as possible. Unfortunately, it doesn't seem to be that easy ;-) What I've done so far: - Added an __array_interface__ property to the Python side of OpenCV data structures (matrices and images) that uses version 3 of the interface definition and supplies the keys 'version', 'shape', 'typestr', 'data' and in some cases 'strides' when we have non- continuos memory layout. I think, I'm compatible to http://numpy.scipy.org/array_interface.shtml . - Added parsing the __array_interface__ of Python objects passed to OpenCV methods. I'm a bit unsure of how to use the C/C++ side (array struct) and if I can expect it to be there (for example: I don't provide one with OpenCV). Since I intend to keep OpenCV independent of numpy, calling functions from numpy.h is not an option, as far as I can see. The stuff described above is in the head revision of OpenCV, accessible via "svn co https://opencvlibrary.svn.sourceforge.net/svnroot/opencvlibrary/trunk/opencv ". I've tried using the following packages with OpenCV this way: - numpy (1.0.4): everything works as expected. This is the most important library for OpenCV users, so this is a good sign. - pylab/matplotlib (0.91.2): seems to use numpy / scipy-core. Everything okay. - PIL (1.1.6): the array interface (Python side) doesn't adhere to the definition -> no 'version' key, 'data' is string, not a tuple holding the pointer. What to do with this? - Numeric (24.2): I can create arrays from OpenCV datatypes and print them. Converting to other types however always yields 'Cannot convert scalar to float' or 'a float is required'. Strange :-/ Numeric.array instances also don't carry an __array_interface__. I can however convert by using numpy.arrays as intermediate step. - Gnuplot (1.7): uses Numeric, so doesn't work as well - pymat: didn't check. Seems to use Numeric, test results cover Numeric 23 and Matlab 6.5 only, so this package might be dead? - numarray: didn't check. Is there still any relevance of this package? Best, Mark -- Mark Asbach Institut f?r Nachrichtentechnik, RWTH Aachen University http://www.ient.rwth-aachen.de/cms/team/m_asbach -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4403 bytes Desc: not available URL: From mhagger at alum.mit.edu Wed Jan 14 12:52:24 2009 From: mhagger at alum.mit.edu (Michael Haggerty) Date: Wed, 14 Jan 2009 12:52:24 +0100 Subject: [Image-SIG] Trying to implement the array interface In-Reply-To: References: Message-ID: <496DD1F8.2020300@alum.mit.edu> Mark Asbach wrote: > I'm currently extending the Python wrapper for the Open Computer Vision > Library (opencv) with the goal to interface numerical libraries as > seemless as possible. [...] > - Gnuplot (1.7): uses Numeric, so doesn't work as well Gnuplot.py version 1.8 uses numpy. Maybe that will help? Michael From gael.varoquaux at normalesup.org Wed Jan 14 14:05:18 2009 From: gael.varoquaux at normalesup.org (Gael Varoquaux) Date: Wed, 14 Jan 2009 14:05:18 +0100 Subject: [Image-SIG] [Numpy-discussion] Trying to implement the array interface In-Reply-To: References: Message-ID: <20090114130518.GA21830@phare.normalesup.org> On Wed, Jan 14, 2009 at 12:17:40PM +0100, Mark Asbach wrote: > - Added an __array_interface__ property to the Python side of OpenCV data > structures (matrices and images) [...] > - Added parsing the __array_interface__ of Python objects passed to OpenCV > methods. [...] > I've tried using the following packages with OpenCV this way: > - numpy (1.0.4): everything works as expected. This is the most important > library for OpenCV users, so this is a good sign. [...] _Fantastic_! I read from this e-mail that you are having a few difficulties moving forward, but what you have already achieved is really fantastic and will definitely be very useful to many people. Sorry, I can't help you with the problems you are having, but I wanted to thank you for this effort. Ga?l From berankin99 at yahoo.com Wed Jan 14 16:26:45 2009 From: berankin99 at yahoo.com (Bernard Rankin) Date: Wed, 14 Jan 2009 07:26:45 -0800 (PST) Subject: [Image-SIG] adding overlay & text to many files Message-ID: <933435.46579.qm@web112213.mail.gq1.yahoo.com> Hello, I'm sure this must be a common question, but I could not find any docs on this. Perhapse my google skills needs improvment. Basically, I've got a bunch of pictures from a party/event that I want to do several things to: 1) Resize to 4x6 @ 300 PPI 2) Add a slightly translucent ~ 1" white bar on top of the image (across the bottom). 3) Over the white bar, on the left, place a small 1"x1" logo. 4) Over the white bar, centered on the remainder, put the names of the people in the photo. (Reducing text size if needed to fit on one line.) 5) Over the white bar, centered on the remainder, put the name of the event on the next line. 6) Add a black border to entire image. 7) Export as JPEG. There is a CSV file that contains the "names of the people in each photo" to file name mapping. (One line per image file.) Can this be automated with the PIL? The biggest challenge I imagine would be the step 4 that needs to auto-resize text to fit in a certain area.... That is, it's a single-line text box such that the text inside starts out at some desired size, but is automatically shrunk (in font size) to fit the width of the box if the supplied text is too long. Additionally, for the overlay, it would be nice to use a GIMP file with dummy text as a template that I can supply the correct text and base image file. Is this possible with PIL? Thank you, :) From frederic.mantegazza at gbiloba.org Wed Jan 14 16:49:34 2009 From: frederic.mantegazza at gbiloba.org (=?ISO-8859-1?Q?Fr=E9d=E9ric?=) Date: Wed, 14 Jan 2009 16:49:34 +0100 Subject: [Image-SIG] adding overlay & text to many files In-Reply-To: <933435.46579.qm@web112213.mail.gq1.yahoo.com> Message-ID: Le 14/1/2009, "Bernard Rankin" a ?crit: >I'm sure this must be a common question, but I could not find any docs on this. Perhapse my google skills needs improvment. > >Basically, I've got a bunch of pictures from a party/event that I want to do several things to: > >1) Resize to 4x6 @ 300 PPI >2) Add a slightly translucent ~ 1" white bar on top of the image (across the bottom). >3) Over the white bar, on the left, place a small 1"x1" logo. >4) Over the white bar, centered on the remainder, put the names of the people in the photo. (Reducing text size if needed to fit on one line.) >5) Over the white bar, centered on the remainder, put the name of the event on the next line. >6) Add a black border to entire image. >7) Export as JPEG. > >There is a CSV file that contains the "names of the people in each photo" to file name mapping. (One line per image file.) > >Can this be automated with the PIL? > >The biggest challenge I imagine would be the step 4 that needs to auto-resize text to fit in a certain area.... That is, it's a single-line text box such that the text inside starts out at some desired size, but is >automatically shrunk (in font size) to fit the width of the box if the >supplied text is too long. > >Additionally, for the overlay, it would be nice to use a GIMP file with dummy text as a template that I can supply the correct text and base image file. Is this possible with PIL? I think that it is possible to do all you want. First, I would suggest you have a look at Phatch, a great batch processor, build on PIL. Step 1, 6 and 7 are already done in Phatch default actions. Then, I would write a few Phatch actions to match your needs. I would first build an transparent image with the logo and names, then merge this image with the original. I agree that the tricky part is the text. Anyway, you can start to prototype this with PIL, then turn your code into a Phatch action to have a great batch processor. -- Fr?d?ric From cannon.el at gmail.com Wed Jan 14 17:27:55 2009 From: cannon.el at gmail.com (Laura & Edward Cannon) Date: Wed, 14 Jan 2009 08:27:55 -0800 Subject: [Image-SIG] adding overlay & text to many file In-Reply-To: <933435.46579.qm@web112213.mail.gq1.yahoo.com> References: <933435.46579.qm@web112213.mail.gq1.yahoo.com> Message-ID: Reading gimp files is tricky. Resizing photos is not hard just remember that PIL thinks in pixels, so just multiply your PPI by the dimension to get the size in pixels. Look at the paste function in the Image module for details on adding logos and bars. The ImageDraw function might be useful for the rest of the process. There is a method on font objects, getsize, that will tell you how large your text will be, this would allow you to choose a smaller font if necessary. Happy programing On Wed, Jan 14, 2009 at 7:26 AM, Bernard Rankin wrote: > Hello, > > I'm sure this must be a common question, but I could not find any docs on this. Perhapse my google skills needs improvment. > > Basically, I've got a bunch of pictures from a party/event that I want to do several things to: > > 1) Resize to 4x6 @ 300 PPI > 2) Add a slightly translucent ~ 1" white bar on top of the image (across the bottom). > 3) Over the white bar, on the left, place a small 1"x1" logo. > 4) Over the white bar, centered on the remainder, put the names of the people in the photo. (Reducing text size if needed to fit on one line.) > 5) Over the white bar, centered on the remainder, put the name of the event on the next line. > 6) Add a black border to entire image. > 7) Export as JPEG. > > There is a CSV file that contains the "names of the people in each photo" to file name mapping. (One line per image file.) > > Can this be automated with the PIL? > > The biggest challenge I imagine would be the step 4 that needs to auto-resize text to fit in a certain area.... That is, it's a single-line text box such that the text inside starts out at some desired size, but is > automatically shrunk (in font size) to fit the width of the box if the > supplied text is too long. > > Additionally, for the overlay, it would be nice to use a GIMP file with dummy text as a template that I can supply the correct text and base image file. Is this possible with PIL? > > Thank you, > :) > > > > > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From berankin99 at yahoo.com Wed Jan 14 20:37:29 2009 From: berankin99 at yahoo.com (Bernard Rankin) Date: Wed, 14 Jan 2009 11:37:29 -0800 (PST) Subject: [Image-SIG] adding overlay & text to many files References: Message-ID: <956018.37319.qm@web112222.mail.gq1.yahoo.com> > > I think that it is possible to do all you want. First, I would suggest > you have a look at Phatch, a great batch processor, build on PIL. Step > 1, 6 and 7 are already done in Phatch default actions. > > Then, I would write a few Phatch actions to match your needs. I would > first build an transparent image with the logo and names, then merge > this image with the original. > > I agree that the tricky part is the text. Anyway, you can start to > prototype this with PIL, then turn your code into a Phatch action to > have a great batch processor. > Where can I find Phatch? http://photobatch.stani.be/ seems to only have a screen shot, and no further info or links...... Am I missing something? I do see a version (0.1.5) in the Ubuntu repositories, is that that the latest? From Chris.Barker at noaa.gov Wed Jan 14 20:53:51 2009 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Wed, 14 Jan 2009 11:53:51 -0800 Subject: [Image-SIG] adding overlay & text to many files In-Reply-To: <956018.37319.qm@web112222.mail.gq1.yahoo.com> References: <956018.37319.qm@web112222.mail.gq1.yahoo.com> Message-ID: <496E42CF.7090001@noaa.gov> Bernard Rankin wrote: > Where can I find Phatch? > > http://photobatch.stani.be/ seems to only have a screen shot, and no further info or links...... Am I missing something? look at the bottom of the page -- there are links to download and docs. And yes, that was far more subtle than all the ads! sigh. -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 spe.stani.be at gmail.com Wed Jan 14 22:23:46 2009 From: spe.stani.be at gmail.com (Stani) Date: Wed, 14 Jan 2009 22:23:46 +0100 Subject: [Image-SIG] adding overlay & text to many files In-Reply-To: References: Message-ID: <1231968226.2882.100.camel@blue> Op woensdag 14-01-2009 om 16:49 uur [tijdzone +0100], schreef Fr?d?ric: > Le 14/1/2009, "Bernard Rankin" a ?crit: > > >I'm sure this must be a common question, but I could not find any docs on this. Perhapse my google skills needs improvment. > > > >Basically, I've got a bunch of pictures from a party/event that I want to do several things to: > > > >1) Resize to 4x6 @ 300 PPI > >2) Add a slightly translucent ~ 1" white bar on top of the image (across the bottom). > >3) Over the white bar, on the left, place a small 1"x1" logo. > >4) Over the white bar, centered on the remainder, put the names of the people in the photo. (Reducing text size if needed to fit on one line.) > >5) Over the white bar, centered on the remainder, put the name of the event on the next line. > >6) Add a black border to entire image. > >7) Export as JPEG. > > > >There is a CSV file that contains the "names of the people in each photo" to file name mapping. (One line per image file.) > > > >Can this be automated with the PIL? > > > >The biggest challenge I imagine would be the step 4 that needs to auto-resize text to fit in a certain area.... That is, it's a single-line text box such that the text inside starts out at some desired size, but is > >automatically shrunk (in font size) to fit the width of the box if the > >supplied text is too long. > > > >Additionally, for the overlay, it would be nice to use a GIMP file with dummy text as a template that I can supply the correct text and base image file. Is this possible with PIL? > > I think that it is possible to do all you want. First, I would suggest > you have a look at Phatch, a great batch processor, build on PIL. Step > 1, 6 and 7 are already done in Phatch default actions. And you would get 2 and 3 also for free. For both steps you can use the watermark action: once with a fixed translucent white bar image (.png) and once with the logo. > > Then, I would write a few Phatch actions to match your needs. I would > first build an transparent image with the logo and names, then merge > this image with the original. > > I agree that the tricky part is the text. Anyway, you can start to > prototype this with PIL, then turn your code into a Phatch action to > have a great batch processor. Phatch has already a text action which has done the hard work already as well. Just start from that as a base and hack it to use a csv file as input instead of a fixed text. If you have played with python and PIL already, it should be not that hard. BTW Phatch can be used as a desktop application but also as a server process without a GUI, once you have your action configured. Phatch is available in Ubuntu Intrepid, Fedora, Suse, Arch Linux, ... in the usual repositories. The latest version is 0.1.x (where x are bug fix releases which you probably don't need). Stani From frederic.mantegazza at gbiloba.org Wed Jan 14 23:04:47 2009 From: frederic.mantegazza at gbiloba.org (=?iso-8859-15?q?Fr=E9d=E9ric?=) Date: Wed, 14 Jan 2009 23:04:47 +0100 Subject: [Image-SIG] adding overlay & text to many files In-Reply-To: <1231968226.2882.100.camel@blue> References: <1231968226.2882.100.camel@blue> Message-ID: <200901142304.48223.frederic.mantegazza@gbiloba.org> On mercredi 14 janvier 2009, Stani wrote: > And you would get 2 and 3 also for free. For both steps you can use the > watermark action: once with a fixed translucent white bar image (.png) > and once with the logo. Oh, yes, you're right! > Phatch has already a text action which has done the hard work already as > well. Just start from that as a base and hack it to use a csv file as > input instead of a fixed text. If you have played with python and PIL > already, it should be not that hard. > > BTW Phatch can be used as a desktop application but also as a server > process without a GUI, once you have your action configured. > > Phatch is available in Ubuntu Intrepid, Fedora, Suse, Arch Linux, ... in > the usual repositories. The latest version is 0.1.x (where x are bug fix > releases which you probably don't need). Bernard, Phatch is definitly the tool you need to use to solve your problem! And feel free to share your actions, if you write some ;o) -- Fr?d?ric http://www.gbiloba.org From berankin99 at yahoo.com Thu Jan 15 04:42:47 2009 From: berankin99 at yahoo.com (Bernard Rankin) Date: Wed, 14 Jan 2009 19:42:47 -0800 (PST) Subject: [Image-SIG] adding overlay & text to many files References: <1231968226.2882.100.camel@blue> Message-ID: <108947.9589.qm@web112214.mail.gq1.yahoo.com> > Phatch has already a text action which has done the hard work already as > well. Just start from that as a base and hack it to use a csv file as > input instead of a fixed text. If you have played with python and PIL > already, it should be not that hard. > Thanks for the help. I've taken a look at the tutorial and the existing text.py action. I am new to Python, and have never used PIL, but it does look do-able.. A couple of questions on the existing text action: 1) Is the the "cache" dict the only recommended way to maintain state between invocations? 2) What is the "values" method of the Action class in the text.py file? 3) What does the "global" statement in the init() method do, and why is it there? 4) What is line 38 trying to do, and why is it in the if clause? Also, was this file based on the Watermark code? Many if the code comments would indicate so. (Running out of Ubuntu Intrepid repo) Where can I find further docs on the plug-in / action API? Thank you :) From hoffmann at hiskp.uni-bonn.de Thu Jan 22 21:05:29 2009 From: hoffmann at hiskp.uni-bonn.de (Tim Hoffmann) Date: Thu, 22 Jan 2009 21:05:29 +0100 Subject: [Image-SIG] 16bit TIFF files: error in Image.putpixel() Message-ID: <4978D189.4030000@hiskp.uni-bonn.de> Hello, I think I found a bug in Image.putpixel() for 16bit images. It writes the given x coordinates in bytes, not pixels. i.e. x==0 is lower byte of pixel 0, x==1 addresses upper byte of pixel zero. y indices are ok. The following code shows the problem (using PIL 1.1.6): im = Image.open("text16black.tif") print im.format, im.size, im.mode dx = size[0] for i in range(0, dx): # reopening to restore data every time im = Image.open("test16black.tif") im.putpixel((i, 0), 2) print [im.getpixel((x, 0)) for x in range(0, dx)] output (for completely black test image): TIFF (9, 15) I;16 [2, 0, 0, 0, 0, 0, 0, 0, 0] [512, 0, 0, 0, 0, 0, 0, 0, 0] [0, 2, 0, 0, 0, 0, 0, 0, 0] [0, 512, 0, 0, 0, 0, 0, 0, 0] [0, 0, 2, 0, 0, 0, 0, 0, 0] [0, 0, 512, 0, 0, 0, 0, 0, 0] [0, 0, 0, 2, 0, 0, 0, 0, 0] [0, 0, 0, 512, 0, 0, 0, 0, 0] [0, 0, 0, 0, 2, 0, 0, 0, 0] Because of range checking based on the pixels I cannot even work around supplying the data in an appropriate format. There is no way to address the right half of the line. BTW the same problem occurs in putdata(). Thanks for your comments, Tim From fredrik at pythonware.com Fri Jan 23 14:36:45 2009 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 23 Jan 2009 14:36:45 +0100 Subject: [Image-SIG] 16bit TIFF files: error in Image.putpixel() In-Reply-To: <4978D189.4030000@hiskp.uni-bonn.de> References: <4978D189.4030000@hiskp.uni-bonn.de> Message-ID: <368a5cd50901230536s7f3b1290l4fd78758b5dce706@mail.gmail.com> What's the mode for this image? If it says "I;16" or something similar, it's not fully supported in 1.1.6, and you may have to explicitly convert it to mode "I" to work with it. (there should be an option to open() so you can explicitly tell PIL if you're prepared to work with experimental modes, really, but with the current releases, you have to look for them). On Thu, Jan 22, 2009 at 9:05 PM, Tim Hoffmann wrote: > Hello, > > I think I found a bug in Image.putpixel() for 16bit images. It writes the > given x coordinates in bytes, not pixels. i.e. x==0 is lower byte of pixel > 0, x==1 addresses upper byte of pixel zero. y indices are ok. > > > The following code shows the problem (using PIL 1.1.6): > > > im = Image.open("text16black.tif") > print im.format, im.size, im.mode > dx = size[0] > > for i in range(0, dx): > # reopening to restore data every time > im = Image.open("test16black.tif") > im.putpixel((i, 0), 2) > print [im.getpixel((x, 0)) for x in range(0, dx)] > > output (for completely black test image): > > TIFF (9, 15) I;16 > [2, 0, 0, 0, 0, 0, 0, 0, 0] > [512, 0, 0, 0, 0, 0, 0, 0, 0] > [0, 2, 0, 0, 0, 0, 0, 0, 0] > [0, 512, 0, 0, 0, 0, 0, 0, 0] > [0, 0, 2, 0, 0, 0, 0, 0, 0] > [0, 0, 512, 0, 0, 0, 0, 0, 0] > [0, 0, 0, 2, 0, 0, 0, 0, 0] > [0, 0, 0, 512, 0, 0, 0, 0, 0] > [0, 0, 0, 0, 2, 0, 0, 0, 0] > > > > Because of range checking based on the pixels I cannot even work around > supplying the data in an appropriate format. There is no way to address the > right half of the line. > > BTW the same problem occurs in putdata(). > > Thanks for your comments, > Tim > > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From tibor.arpas at infinit.sk Fri Jan 23 16:34:41 2009 From: tibor.arpas at infinit.sk (Tibor Arpas) Date: Fri, 23 Jan 2009 16:34:41 +0100 Subject: [Image-SIG] feature request: 8-bit alpha transparency PNG;s In-Reply-To: <19a7c8c20901211003k3f18b2f9yd7171af4b0830288@mail.gmail.com> References: <19a7c8c20901211003k3f18b2f9yd7171af4b0830288@mail.gmail.com> Message-ID: <19a7c8c20901230734i15f874e9k78553c6044f30bbc@mail.gmail.com> Hi, I'm using little attached program to convert my RGB and RGBA PNG's to png8. But with RGBA pngs it's limited because it uses only GIF-like 1-bit transparency. Seems that the alpha transparency in 8-bit (and 4-bit) PNG's is little known or supported. But the main browsers seem to support it including IE 6.0. One opensource utility which supports writing these is: http://www.libpng.org/pub/png/apps/pngquant.html . It would be greate if PIL would also do that. Have a nice day, Tibor import Image import random import optparse import sys def quantize_and_invert(alpha): if alpha <= 64: # You may change the threshold value into something other. return 255 return 0 im = Image.open(sys.argv[1]) if im.mode=='RGBA': print "Warning, converting alpha transparency to 1-bit transparency" al = im.split()[3] al = Image.eval(al, quantize_and_invert) colors=255 else: al = None colors=256 if im.mode!='RGB': im = im.convert('RGB') im=im.convert('P', palette=Image.ADAPTIVE, colors=colors) if al: im.paste(255,None,al) im.save('out.png',optimize=1, transparency=255) -------------- next part -------------- An HTML attachment was scrubbed... URL: From odaniil at gmail.com Sat Jan 24 19:17:27 2009 From: odaniil at gmail.com (Daniil Osokin) Date: Sat, 24 Jan 2009 21:17:27 +0300 Subject: [Image-SIG] PIL bug report: touble in save jpeg file with quality=100 and optimize=True Message-ID: Hello I have try to save jpeg file with quality=100 and optimize but get this: ----------------------------------------------------------- Traceback (most recent call last): File "D:\temp\Python-PIL-test\pil_test.py", line 29, in main("image_test.jpg") File "D:\temp\Python-PIL-test\pil_test.py", line 23, in main img.save(file_out, "JPEG", quality=100, optimize=True) File "C:\Python25\Lib\site-packages\PIL\Image.py", line 1405, in save save_handler(self, fp, filename) File "C:\Python25\lib\site-packages\PIL\JpegImagePlugin.py", line 409, in _save ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)]) File "C:\Python25\Lib\site-packages\PIL\ImageFile.py", line 493, in _save raise IOError("encoder error %d when writing image file" % s) IOError: encoder error -2 when writing image file ----------------------------------------------------------- But this lines work fine: img.save(file_out, "JPEG", quality=80, optimize=True) or img.save(file_out, "JPEG", quality=100) PIL version 1.1.6 Python 2.5.4 Windows XP SP3 test files are attached Thanx --- Daniil -------------- next part -------------- A non-text attachment was scrubbed... Name: image_test.jpg Type: image/jpeg Size: 2428090 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: pil_test.py Type: application/octet-stream Size: 772 bytes Desc: not available URL: From fredrik at pythonware.com Sun Jan 25 20:34:42 2009 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 25 Jan 2009 20:34:42 +0100 Subject: [Image-SIG] PIL bug report: touble in save jpeg file with quality=100 and optimize=True In-Reply-To: References: Message-ID: <368a5cd50901251134q2e51f06bq8e4392bb75679156@mail.gmail.com> It's a limitation in the libjpeg library that PIL doesn't work around; the approach described here should still work: http://mail.python.org/pipermail/image-sig/1999-August/000816.html 2009/1/24 Daniil Osokin : > Hello > > I have try to save jpeg file with quality=100 and optimize but get this: > ----------------------------------------------------------- > Traceback (most recent call last): > File "D:\temp\Python-PIL-test\pil_test.py", line 29, in > main("image_test.jpg") > File "D:\temp\Python-PIL-test\pil_test.py", line 23, in main > img.save(file_out, "JPEG", quality=100, optimize=True) > File "C:\Python25\Lib\site-packages\PIL\Image.py", line 1405, in save > save_handler(self, fp, filename) > File "C:\Python25\lib\site-packages\PIL\JpegImagePlugin.py", line > 409, in _save > ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)]) > File "C:\Python25\Lib\site-packages\PIL\ImageFile.py", line 493, in _save > raise IOError("encoder error %d when writing image file" % s) > IOError: encoder error -2 when writing image file > ----------------------------------------------------------- > > But this lines work fine: > img.save(file_out, "JPEG", quality=80, optimize=True) > or > img.save(file_out, "JPEG", quality=100) > > PIL version 1.1.6 > Python 2.5.4 > Windows XP SP3 > > test files are attached From dineshbvadhia at hotmail.com Mon Jan 26 16:04:49 2009 From: dineshbvadhia at hotmail.com (Dinesh B Vadhia) Date: Mon, 26 Jan 2009 07:04:49 -0800 Subject: [Image-SIG] Image Mining Library Message-ID: Hi! I've asked this question before but didn't get a response so let's try again! I'm looking for an (open source) Python image mining library to extract information from images eg. to perform Gabor or Tamura or HSV filtering and others. All help will be appreciated. Cheers ... Dinesh -------------- next part -------------- An HTML attachment was scrubbed... URL: From tim at timhatch.com Mon Jan 26 18:29:06 2009 From: tim at timhatch.com (Tim Hatch) Date: Mon, 26 Jan 2009 09:29:06 -0800 Subject: [Image-SIG] [PIL] ImageColor.getcolor incorrect for grayscale Message-ID: I think I've discovered a bug when using named colors, due to using integer division too early in getcolor, which makes it disagree with the color conversion done in ImagingConvert for a large number of colors (106 of the 147 named colors). To start off, I'm assuming that for grays where r=g=b, that getcolor(name, 'L') should return the same as getcolor(name, 'RGB') [0]. Integer division done too early rounds down, so grays end up slightly too dark in grayscale modes. Here's the line in question (PIL 1.1.6, ImageColor.py line 108): return r*299/1000 + g*587/1000 + b*114/1000 All the true grays except black (that is, darkgray, dimgray, gray, lightgray, and white) exhibit this issue. The one that made me notice this is that 'white' means 254 instead of 255. With the attached patch, it now behaves sanely, i.e.: Image.new('RGB', (1, 1), color).convert('L').getpixel((0, 0)) == Image.new('L', (1, 1), color).getpixel((0, 0)) for all named colors, and ImageColor.getcolor(color, 'L') == ImageColor.getcolor(color, 'RGB')[0] for the grays. Tim -------------- next part -------------- A non-text attachment was scrubbed... Name: imagecolor-rounding.diff Type: application/octet-stream Size: 361 bytes Desc: not available URL: -------------- next part -------------- From lukas.orsin at infinit.sk Mon Jan 26 19:34:34 2009 From: lukas.orsin at infinit.sk (Lukas Orsin) Date: Mon, 26 Jan 2009 19:34:34 +0100 Subject: [Image-SIG] Converting images to palette mode Message-ID: <6fca00fa0901261034h7a60f678t6f75f50c1961a285@mail.gmail.com> Hi, We are converting much images (296,000 tiles) at size 256x256px from RGB to Palette mode. After about 200,000 converted images our simple program crashes with quantization error: ..processing 129.png ..processing 130.png Traceback (most recent call last): File "C:\tmp\to8bit_folders_upgrade.py", line 35, in os.path.walk(cesta,start_image_crush, 'blablabla') File "C:\ActivePython25\lib\ntpath.py", line 334, in walk walk(name, func, arg) File "C:\ActivePython25\lib\ntpath.py", line 334, in walk walk(name, func, arg) File "C:\ActivePython25\lib\ntpath.py", line 334, in walk walk(name, func, arg) File "C:\ActivePython25\lib\ntpath.py", line 334, in walk walk(name, func, arg) File "C:\ActivePython25\lib\ntpath.py", line 334, in walk walk(name, func, arg) File "C:\ActivePython25\lib\ntpath.py", line 328, in walk func(arg, top, names) File "C:\tmp\to8bit_folders_upgrade.py", line 29, in start_image_crush im=im.convert('P', palette=Image.ADAPTIVE, colors=colors) File "C:\ActivePython25\Lib\site-packages\PIL\Image.py", line 663, in convert im = self.im.quantize(colors) ValueError: quantization error Could anybody know whats the matter? We are running at Windows 2003 R2 SP2 32bit / 3.5 GB RAM and using os.path.walk funcion. Lukas -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Tue Jan 27 11:53:33 2009 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 27 Jan 2009 11:53:33 +0100 Subject: [Image-SIG] Converting images to palette mode In-Reply-To: <6fca00fa0901261034h7a60f678t6f75f50c1961a285@mail.gmail.com> References: <6fca00fa0901261034h7a60f678t6f75f50c1961a285@mail.gmail.com> Message-ID: <368a5cd50901270253p1957dce1jd2bee18c9d48a6fc@mail.gmail.com> Does it always stop at the same image, or after roughly the same number of images? Have you checked for memory/cpu consumption during the conversion (in case it's a leak). 2009/1/26 Lukas Orsin : > Hi, > We are converting much images (296,000 tiles) at size 256x256px from RGB to > Palette mode. > After about 200,000 converted images our simple program crashes with > quantization error: > > ..processing 129.png > ..processing 130.png > Traceback (most recent call last): > File "C:\tmp\to8bit_folders_upgrade.py", line 35, in > os.path.walk(cesta,start_image_crush, 'blablabla') > File "C:\ActivePython25\lib\ntpath.py", line 334, in walk > walk(name, func, arg) > File "C:\ActivePython25\lib\ntpath.py", line 334, in walk > walk(name, func, arg) > File "C:\ActivePython25\lib\ntpath.py", line 334, in walk > walk(name, func, arg) > File "C:\ActivePython25\lib\ntpath.py", line 334, in walk > walk(name, func, arg) > File "C:\ActivePython25\lib\ntpath.py", line 334, in walk > walk(name, func, arg) > File "C:\ActivePython25\lib\ntpath.py", line 328, in walk > func(arg, top, names) > File "C:\tmp\to8bit_folders_upgrade.py", line 29, in start_image_crush > im=im.convert('P', palette=Image.ADAPTIVE, colors=colors) > File "C:\ActivePython25\Lib\site-packages\PIL\Image.py", line 663, in > convert > im = self.im.quantize(colors) > ValueError: quantization error > > Could anybody know whats the matter? > We are running at Windows 2003 R2 SP2 32bit / 3.5 GB RAM > and using os.path.walk funcion. > > Lukas > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > From lukas.orsin at infinit.sk Tue Jan 27 17:44:43 2009 From: lukas.orsin at infinit.sk (Lukas Orsin) Date: Tue, 27 Jan 2009 17:44:43 +0100 Subject: [Image-SIG] Converting images to palette mode In-Reply-To: <368a5cd50901270253p1957dce1jd2bee18c9d48a6fc@mail.gmail.com> References: <6fca00fa0901261034h7a60f678t6f75f50c1961a285@mail.gmail.com> <368a5cd50901270253p1957dce1jd2bee18c9d48a6fc@mail.gmail.com> Message-ID: <6fca00fa0901270844g7a5874dcw72f14382b041cd70@mail.gmail.com> Thanks for answers. I am sure no image is broken. If I run my program once again, previously stopped image is processed with no error and no exception. I tested conversion a few times with many little images on two mashines (both 32bit Win 2003 server) and it crashed after allocation 50 - 60 MB of memory. A preliminary test on 64bit Win 2008 server ended well with 200,000 converted images at memory allocation 250 MB in the end. We think problem takes about memory allocation at mass conversion. My script is attached. (usage: python to8bit_folders_upgrade.py c:\temp\images) -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: to8bit_folders_upgrade.py Type: text/x-python Size: 1850 bytes Desc: not available URL: From gregor at kopka.net Wed Jan 28 00:29:49 2009 From: gregor at kopka.net (Gregor Kopka) Date: Wed, 28 Jan 2009 00:29:49 +0100 Subject: [Image-SIG] Converting images to palette mode In-Reply-To: <6fca00fa0901270844g7a5874dcw72f14382b041cd70@mail.gmail.com> References: <6fca00fa0901261034h7a60f678t6f75f50c1961a285@mail.gmail.com> <368a5cd50901270253p1957dce1jd2bee18c9d48a6fc@mail.gmail.com> <6fca00fa0901270844g7a5874dcw72f14382b041cd70@mail.gmail.com> Message-ID: <497F98ED.5070203@kopka.net> Hello Lukas, could be that you found a memleak somewhere in PIL. Maybe try to add some /del() /to force cleanup of the images - i'm not that sure at the moment but i remember i somewhen have read something somewhere about the need to use del(image) to force a correct cleanup in a special case. In case you're curious if i'm right try this version which cleans used stuff explicitly via del(). also while looking at it i'm not that sure why you don't check the extension by checking against /a[-4:] == ".png" /which i feel like a bit more readable compared to your if condition. Do you want to stop your code from processing files with a "." in the name (like 'mypic 02.05.2007.png') ? Gregor def start_image_crush(bla, path, files): os.chdir(path) print '\nACTUAL DIRECTORY: ' + path + '\n' for a in files: # directory and file filter if string.find(a,'.') > 0 and string.split(a,'.')[1]=='png' and len(string.split(a,'.'))==2: print 'Trying '+ a im = Image.open(a) if im.mode!='P': print '.....processing' if im.mode=='RGBA': print "Warning, converting alpha transparency to 1-bit transparency" al = im.split()[3] nal = Image.eval(al, quantize_and_invert) del(al) colors=255 else: nal = None colors=256 if im.mode!='RGB': nim = im.convert('RGB') else: nim = im del(im) try: im=nim.convert('P', palette=Image.ADAPTIVE, colors=colors) except ValueError, e: print 'Python memusage: ' + str( memusage() ) + ' !!!' raise e del(nim) if nal: im.paste(255,None,nal) del(nal) im.save(string.split(a,'.')[0]+'.png',optimize=1, transparency=255) else: print 'Image still converted. No processing !!!' del(im) Lukas Orsin schrieb: > Thanks for answers. > I am sure no image is broken. If I run my program once again, > previously stopped image is processed with no error and no exception. > I tested conversion a few times with many little images on two > mashines (both 32bit Win 2003 server) and it crashed after allocation > 50 - 60 MB of memory. > A preliminary test on 64bit Win 2008 server ended well with 200,000 > converted images at memory allocation 250 MB in the end. > We think problem takes about memory allocation at mass conversion. > > My script is attached. > (usage: python to8bit_folders_upgrade.py c:\temp\images) > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: gregor.vcf Type: text/x-vcard Size: 314 bytes Desc: not available URL: From charlie at begeistert.org Wed Jan 28 10:10:22 2009 From: charlie at begeistert.org (Charlie Clark) Date: Wed, 28 Jan 2009 10:10:22 +0100 Subject: [Image-SIG] Converting images to palette mode In-Reply-To: <497F98ED.5070203@kopka.net> References: <6fca00fa0901261034h7a60f678t6f75f50c1961a285@mail.gmail.com> <368a5cd50901270253p1957dce1jd2bee18c9d48a6fc@mail.gmail.com> <6fca00fa0901270844g7a5874dcw72f14382b041cd70@mail.gmail.com> <497F98ED.5070203@kopka.net> Message-ID: <7FC4301F-21A8-4724-88F1-9B261856E61E@begeistert.org> Am 28.01.2009 um 00:29 schrieb Gregor Kopka: > also while looking at it i'm not that sure why you don't check the > extension by checking against a[-4:] == ".png" which i feel like a > bit more readable compared to your if condition. > Do you want to stop your code from processing files with a "." in > the name (like 'mypic 02.05.2007.png') ? Actually why not rely on os.path to identify things correctly in the first place? Which book still recommends code like this? if string.find(a,'.') > 0 and string.split(a,'.')[1]=='png' and len(string.split(a,'.'))==2 Strings have had methods since Python 1.6! But os.path.splitext() is probably all you need. Sorry that this won't help you find the cause of the crash. Charlie -- Charlie Clark Helmholtzstr. 20 D?sseldorf D- 40215 Tel: +49-211-938-5360 GSM: +49-178-782-6226 From luko.pn at gmail.com Thu Jan 29 11:29:28 2009 From: luko.pn at gmail.com (=?ISO-8859-2?B?THVr4bkgT3K5aW4=?=) Date: Thu, 29 Jan 2009 11:29:28 +0100 Subject: [Image-SIG] Converting images to palette mode Message-ID: <89f2e6100901290229u3819b8f7x66d9a8a095b318e8@mail.gmail.com> Thanks for syntax advices ;) The version with del(image) clause seems to be more successful. Unfortunately it can?t still run to the end. Program crashed at 37 % of processing with 98 MB allocated memory. I am using PIL in 1.1.6 version. Unfortunately we have not the opportunity to test that batch in Linux, just in Windows. PS: I am posting from another e-mail (luko.pn at gmail.com). Posting from my main address (lukas.orsin at infinit.sk), powered by Google Apps for Business, still returns the notification about suspicious header. The same to my colleague @infinit.sk. Could the admin chech it please ? From spe.stani.be at gmail.com Thu Jan 29 17:39:24 2009 From: spe.stani.be at gmail.com (Stani) Date: Thu, 29 Jan 2009 17:39:24 +0100 Subject: [Image-SIG] adding overlay & text to many files In-Reply-To: <108947.9589.qm@web112214.mail.gq1.yahoo.com> References: <1231968226.2882.100.camel@blue> <108947.9589.qm@web112214.mail.gq1.yahoo.com> Message-ID: <1233247164.26585.20.camel@blue> Op woensdag 14-01-2009 om 19:42 uur [tijdzone -0800], schreef Bernard Rankin: > > > > Phatch has already a text action which has done the hard work already as > > well. Just start from that as a base and hack it to use a csv file as > > input instead of a fixed text. If you have played with python and PIL > > already, it should be not that hard. > > > > Thanks for the help. > > I've taken a look at the tutorial and the existing text.py action. > > I am new to Python, and have never used PIL, but it does look do-able.. > > A couple of questions on the existing text action: > > 1) Is the the "cache" dict the only recommended way to maintain state between invocations? Yes. > 2) What is the "values" method of the Action class in the text.py file? The values method convert relative values (given by the user) into absolute values based on image properties (height, width, ...). For example for a pixel value a user can enter absolute pixels, metrics (cm, mm, ...) or a percentage. In the end we need absolute pixels to work with PIL. So metrics are converted to pixels by multiplying with the dpi. Percentage are calculated by multiplying with the appropriate image property. For example for a horizontal offset of 5%, we take 5% of the image width. The font size is based on the average of the image height and width. > 3) What does the "global" statement in the init() method do, and why is it there? Phatch uses a very simple plugin mechanism. It imports all the actions at startup. In order not to load modules which might not be used and to keep one action limited to one file, we need a lazy import for modules which are only necessary when executing the action. Therefore they are grouped in an init method and global is used to make them globally available. > 4) What is line 38 trying to do, and why is it in the if clause? If no (truetype) font is given, Phatch will use the default PIL font which AFAIK can not handle unicode (e.g. chinese characters). Therefore text needs to be converted to ascii. Phatch choses to replace a character with a ? if it can't be encoded. > > Also, was this file based on the Watermark code? Many if the code comments would indicate so. Indeed. Many actions are based on other ones. This is the fastest way to write new actions. > (Running out of Ubuntu Intrepid repo) If you start developing, please checkout phatch from the bazaar repository (bzr lp:phatch) > > Where can I find further docs on the plug-in / action API? I guess you've read already: http://photobatch.wikidot.com/writing-actions The best is to study and understand the source of the other actions and see them in action. > > Thank you You're welcome! Stani From pander at users.sourceforge.net Thu Jan 29 17:53:00 2009 From: pander at users.sourceforge.net (Pander) Date: Thu, 29 Jan 2009 17:53:00 +0100 Subject: [Image-SIG] adding overlay & text to many files In-Reply-To: <1233247164.26585.20.camel@blue> References: <1231968226.2882.100.camel@blue> <108947.9589.qm@web112214.mail.gq1.yahoo.com> <1233247164.26585.20.camel@blue> Message-ID: <4981DEEC.4080503@users.sourceforge.net> Hi all, Here is a way to add text, see attachment. I've extended the test cases with capitols with diacritics. On the list a question regarding this arose, so it was good to double check this. If possible, I would like to have this module included into PIL. Once I had it revied, but would like to resubmit it again since the PIL list has become more active again, especially regarding text overlays. Regards, Pander Stani wrote: > Op woensdag 14-01-2009 om 19:42 uur [tijdzone -0800], schreef Bernard > Rankin: >> >>> Phatch has already a text action which has done the hard work already as >>> well. Just start from that as a base and hack it to use a csv file as >>> input instead of a fixed text. If you have played with python and PIL >>> already, it should be not that hard. >>> >> Thanks for the help. >> >> I've taken a look at the tutorial and the existing text.py action. >> >> I am new to Python, and have never used PIL, but it does look do-able.. >> >> A couple of questions on the existing text action: >> >> 1) Is the the "cache" dict the only recommended way to maintain state between invocations? > Yes. >> 2) What is the "values" method of the Action class in the text.py file? > The values method convert relative values (given by the user) into > absolute values based on image properties (height, width, ...). For > example for a pixel value a user can enter absolute pixels, metrics (cm, > mm, ...) or a percentage. In the end we need absolute pixels to work > with PIL. So metrics are converted to pixels by multiplying with the > dpi. Percentage are calculated by multiplying with the appropriate image > property. For example for a horizontal offset of 5%, we take 5% of the > image width. The font size is based on the average of the image height > and width. > >> 3) What does the "global" statement in the init() method do, and why is it there? > Phatch uses a very simple plugin mechanism. It imports all the actions > at startup. In order not to load modules which might not be used and to > keep one action limited to one file, we need a lazy import for modules > which are only necessary when executing the action. Therefore they are > grouped in an init method and global is used to make them globally > available. > >> 4) What is line 38 trying to do, and why is it in the if clause? > If no (truetype) font is given, Phatch will use the default PIL font > which AFAIK can not handle unicode (e.g. chinese characters). Therefore > text needs to be converted to ascii. Phatch choses to replace a > character with a ? if it can't be encoded. >> Also, was this file based on the Watermark code? Many if the code comments would indicate so. > Indeed. Many actions are based on other ones. This is the fastest way to > write new actions. > >> (Running out of Ubuntu Intrepid repo) > If you start developing, please checkout phatch from the bazaar > repository (bzr lp:phatch) >> Where can I find further docs on the plug-in / action API? > I guess you've read already: > http://photobatch.wikidot.com/writing-actions > > The best is to study and understand the source of the other actions and > see them in action. >> Thank you > You're welcome! > > Stani > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig -------------- next part -------------- A non-text attachment was scrubbed... Name: ImageText.py Type: text/x-python Size: 15370 bytes Desc: not available URL: From fbuchinger at gmail.com Wed Jan 28 20:07:16 2009 From: fbuchinger at gmail.com (Franz Buchinger) Date: Wed, 28 Jan 2009 20:07:16 +0100 Subject: [Image-SIG] Determine byte offset of JPEG SOI marker Message-ID: Hi, I want to implement some sort of "post header checksum" for JPEG images, i.e. the checksum should only change if the actual image data was altered, EXIF/IPTC metadata modifications should have no effect. My plan to do this is to scan for the JPEG SOI marker, read n bytes after this marker and calcultate an MD5/SHA checksum for this. Can PIL tell me the byte offset of this marker? Greetings, Franz -------------- next part -------------- An HTML attachment was scrubbed... URL: From fredrik at pythonware.com Thu Jan 29 19:52:19 2009 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 29 Jan 2009 19:52:19 +0100 Subject: [Image-SIG] Converting images to palette mode In-Reply-To: <89f2e6100901290229u3819b8f7x66d9a8a095b318e8@mail.gmail.com> References: <89f2e6100901290229u3819b8f7x66d9a8a095b318e8@mail.gmail.com> Message-ID: <368a5cd50901291052pc660e9scbb9efb2c44ac010@mail.gmail.com> > I am posting from another e-mail (luko.pn at gmail.com). Posting from my > main address (lukas.orsin at infinit.sk), powered by Google Apps for > Business, still returns the notification about suspicious header. The > same to my colleague @infinit.sk. Could the admin chech it please ? Looks like the mailman filter thinks that your messages are to HTML-y for the list. Try switching off "rich formatting" and see if that helps. (HTML mails used to mess up the archives, iirc, but that might have been fixed). From charlie at begeistert.org Thu Jan 29 19:56:57 2009 From: charlie at begeistert.org (Charlie Clark) Date: Thu, 29 Jan 2009 19:56:57 +0100 Subject: [Image-SIG] Converting images to palette mode In-Reply-To: <89f2e6100901290229u3819b8f7x66d9a8a095b318e8@mail.gmail.com> References: <89f2e6100901290229u3819b8f7x66d9a8a095b318e8@mail.gmail.com> Message-ID: <2210705F-1D4A-4803-AFC0-EA2C3A8430ED@begeistert.org> Am 29.01.2009 um 11:29 schrieb Luk?? Or?in: > Thanks for syntax advices ;) You're welcome. I've learned to appreciate that good Python code is usually compact and legible and that I'm probably doing something wrong when it isn't! > The version with del(image) clause seems to be more successful. > Unfortunately it can?t still run to the end. > Program crashed at 37 % of processing with 98 MB allocated memory. > I am using PIL in 1.1.6 version. > Unfortunately we have not the opportunity to test that batch in Linux, > just in Windows. I'd be happy to run a test on my machine (Mac OS) if you could send a couple of sample image files to me privately. > PS: > I am posting from another e-mail (luko.pn at gmail.com). Posting from my > main address (lukas.orsin at infinit.sk), powered by Google Apps for > Business, still returns the notification about suspicious header. The > same to my colleague @infinit.sk. Could the admin chech it please ? The problem is almost certainly with Google - what is the precise error message? Charlie -- Charlie Clark Helmholtzstr. 20 D?sseldorf D- 40215 Tel: +49-211-938-5360 GSM: +49-178-782-6226 From ben at ekran.org Fri Jan 30 00:06:13 2009 From: ben at ekran.org (B. Bogart) Date: Thu, 29 Jan 2009 15:06:13 -0800 Subject: [Image-SIG] Issues generating large PNGs Message-ID: <49823665.3060905@ekran.org> Hello all, I tried to create a 17600x2400 pixel PNG in PIL. The image appears wrong, and identify reports: identify: Ignoring bad adaptive filter type `montage.png' @ png.c/PNGWarningHandler/1421. identify: Extra compressed data `montage.png' @ png.c/PNGErrorHandler/1404. identify: Corrupt image `montage.png' @ png.c/ReadPNGImage/2892. If I change the output file to tif then everything works: montage.tif TIFF 17600x2400 17600x2400+0+0 8-bit DirectClass 120.8mb Is there an upper limit to the size of PNG files? .b. From tim at timhatch.com Fri Jan 30 00:44:34 2009 From: tim at timhatch.com (Tim Hatch) Date: Thu, 29 Jan 2009 15:44:34 -0800 Subject: [Image-SIG] Issues generating large PNGs In-Reply-To: <49823665.3060905@ekran.org> References: <49823665.3060905@ekran.org> Message-ID: <84C66D0A-E11C-43CB-AF37-1314D407942B@timhatch.com> > Is there an upper limit to the size of PNG files? How big is yours? I was able to create a 17600x2400 one containing just a single color and it works with identify and Preview.app so it's not a dimension issue. Tim From macginitie at charter.net Sat Jan 31 00:51:01 2009 From: macginitie at charter.net (Andrew MacGinitie) Date: Fri, 30 Jan 2009 18:51:01 -0500 Subject: [Image-SIG] installing PIL from source kit for Python 2.6.1 Message-ID: <49839265.8090707@charter.net> ...can it be done? another question: why does the PIL installer for windows demand that Python be "registered"? Can someone fix that (is the installer's source available)? tia, Andrew From Chris.Barker at noaa.gov Sat Jan 31 01:17:34 2009 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Fri, 30 Jan 2009 16:17:34 -0800 Subject: [Image-SIG] installing PIL from source kit for Python 2.6.1 In-Reply-To: <49839265.8090707@charter.net> References: <49839265.8090707@charter.net> Message-ID: <4983989E.4060303@noaa.gov> Andrew MacGinitie wrote: > another question: why does the PIL installer for windows demand that > Python be "registered"? It's Windows that's demanding that. I think you have to pay a bunch of money to get officially registered. It's analogous to SSL site certificates. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker at noaa.gov From fredrik at pythonware.com Sat Jan 31 21:21:21 2009 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 31 Jan 2009 21:21:21 +0100 Subject: [Image-SIG] installing PIL from source kit for Python 2.6.1 In-Reply-To: <49839265.8090707@charter.net> References: <49839265.8090707@charter.net> Message-ID: <368a5cd50901311221t29367cddkc792744161ffbc17@mail.gmail.com> PIL's using Python's standard installation framework (distutils), and that installer requires Python to be registered (that is, linked to by the appropriate entries in the registry) for the installer to be able to figure out which Python versions you have on the machine, and where they are. If you don't want to use the standard installer, you can just unzip the file and put the contents somewhere on the path. On Sat, Jan 31, 2009 at 12:51 AM, Andrew MacGinitie wrote: > ...can it be done? > > another question: why does the PIL installer for windows demand that Python > be "registered"? Can someone fix that (is the installer's source available)? > > tia, > Andrew > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From fredrik at pythonware.com Sat Jan 31 21:22:35 2009 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 31 Jan 2009 21:22:35 +0100 Subject: [Image-SIG] installing PIL from source kit for Python 2.6.1 In-Reply-To: <4983989E.4060303@noaa.gov> References: <49839265.8090707@charter.net> <4983989E.4060303@noaa.gov> Message-ID: <368a5cd50901311222h76dbcfe2uc49dd417add6072f@mail.gmail.com> I suspect he's referring to the distutils installer (which is a part of standard Python), not the signing procedure. (the installer is signed, iirc). On Sat, Jan 31, 2009 at 1:17 AM, Christopher Barker wrote: > Andrew MacGinitie wrote: >> >> another question: why does the PIL installer for windows demand that >> Python be "registered"? > > It's Windows that's demanding that. I think you have to pay a bunch of money > to get officially registered. It's analogous to SSL site certificates. > > > -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 > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From fredrik at pythonware.com Sat Jan 31 21:25:08 2009 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 31 Jan 2009 21:25:08 +0100 Subject: [Image-SIG] installing PIL from source kit for Python 2.6.1 In-Reply-To: <49839265.8090707@charter.net> References: <49839265.8090707@charter.net> Message-ID: <368a5cd50901311225l6ee0cc77q4cf4c9964e283fa5@mail.gmail.com> On Sat, Jan 31, 2009 at 12:51 AM, Andrew MacGinitie wrote: > ...can it be done? There's an installer for Python 2.6 available from here: http://effbot.org/downloads/#pil which seem to indicate that it can be done. If you insist on building it yourself, see the "Build instructions (all platforms)" and "Additional notes for Windows" sections of the README. From lukas.orsin at infinit.sk Wed Jan 28 20:05:02 2009 From: lukas.orsin at infinit.sk (Lukas Orsin) Date: Wed, 28 Jan 2009 20:05:02 +0100 Subject: [Image-SIG] Converting images to palette mode In-Reply-To: <6fca00fa0901270844g7a5874dcw72f14382b041cd70@mail.gmail.com> References: <6fca00fa0901261034h7a60f678t6f75f50c1961a285@mail.gmail.com> <368a5cd50901270253p1957dce1jd2bee18c9d48a6fc@mail.gmail.com> <6fca00fa0901270844g7a5874dcw72f14382b041cd70@mail.gmail.com> Message-ID: <6fca00fa0901281105s54c0a99cgfaad871128c0eeef@mail.gmail.com> Thanks for syntax advices ;) The version with del(image) clause seems to be more successful. Unfortunatelly it can?t still run to the end. Program crashed at 37 % of processing with 98 MB allocated memory. I am using PIL in 1.1.6 version. Unfortunatelly we can't test that batch in Linux, just in Windows. -------------- next part -------------- An HTML attachment was scrubbed... URL: From H.Zahiri at curtin.edu.au Sat Jan 31 16:13:39 2009 From: H.Zahiri at curtin.edu.au (Hani Zahiri) Date: Sun, 1 Feb 2009 00:13:39 +0900 Subject: [Image-SIG] Problem with converting GeoTIFF to Numpy array (ValueError: unrecognised mode) Message-ID: <82200558F6DE2C479D381D3000D1551C01C7942B@EXMSK1.staff.ad.curtin.edu.au> Hi I am trying to read a GeoTIFF and convert it to a Numpy array. Though, I am able to open the image with no problem, however I am keep getting 'ValueError: unrecognised mode' anytime I try to use any methods from PIL's classes. My lines and results are like this: >>import Numpy >>from PIL import Image >>im = Image.open('dem.TIF') >>print im.format, im.size, im.mode >> TIFF (6000, 6000) I;16S >>dem = fromstring(im.tostring(),'int16') .... .... ValueError: unrecognised mode The problem must be because of mode of my data (I;16S) and I don't know how to read it. I really appreciate any help with this. Many Thanks Cheers, Hani -------------- next part -------------- An HTML attachment was scrubbed... URL: From dineshbvadhia at hotmail.com Sat Jan 31 19:57:42 2009 From: dineshbvadhia at hotmail.com (Dinesh B Vadhia) Date: Sat, 31 Jan 2009 10:57:42 -0800 Subject: [Image-SIG] Image Search at Xyggy Message-ID: Hi! This group might be interested in what we are doing at Xyggy (www.xyggy.com), a Bay Area search startup that is building item-based search services as well as an online platform for developers. We have started to showcase the technology with 5 demos including image search which allows you to find similar images by dragging and dropping one or more images into the search oval. Go have a play. The image demo is based on texture (Gabor and Tamura) and color (HSV) features. The Xyggy search engine can operate on features ranging from the simple to the complex (ie. color, texture, luminosity, invariance, edge detection and so on). The features used for any particular image search service are in the developer's control. Another advantage is that an organizations primary data, in this case images, reside on their site to ensure data protection and privacy. We use Python for all prototype development and data processing and is superb for both these functions. Cheers ... Dinesh -------------- next part -------------- An HTML attachment was scrubbed... URL: From cjlesh at gmail.com Fri Jan 30 16:24:22 2009 From: cjlesh at gmail.com (charlie) Date: Fri, 30 Jan 2009 10:24:22 -0500 Subject: [Image-SIG] Windows PIL installer question Message-ID: <7e7202260901300724r524e3461m4dc5a4c7c040f50d@mail.gmail.com> Is there any way to run the *PIL* installer from the command line on Windows in 'silent' mode, without displaying the install screens or requiring any user interaction? I figured out how to do this with MSIs (the Python installer) and with installers created with Inno setup (use innounp), but can't quite figure out how to do this with the PIL installer, or if it is even possible. -------------- next part -------------- An HTML attachment was scrubbed... URL: From YHWANG1 at PARTNERS.ORG Fri Jan 30 16:00:41 2009 From: YHWANG1 at PARTNERS.ORG (Hwang, Youngha,Ph.D.) Date: Fri, 30 Jan 2009 10:00:41 -0500 Subject: [Image-SIG] installation error of PIL1.1.6 Message-ID: <52368789F9A31D43B7D335E33F45868201B1FE95@PHSXMB24.partners.org> Hi, could someone explain to me what the following error means? Thanks, Youngha. building '_imagingtk' extension creating build/temp.linux-i686-2.5/Tk gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/freetype2 -IlibImaging -I/programs/l/python/2.5.2/include -I/usr/local/include -I/usr/include -I/programs/l/python/2.5.2/include/python2.5 -c _imagingtk.c -o build/temp.linux-i686-2.5/_imagingtk.o _imagingtk.c:20:16: error: tk.h: No such file or directory _imagingtk.c:23: error: expected ?)? before ?*? token _imagingtk.c:31: error: expected specifier-qualifier-list before ?Tcl_Interp? _imagingtk.c: In function ?_tkinit?: _imagingtk.c:37: error: ?Tcl_Interp? undeclared (first use in this function) _imagingtk.c:37: error: (Each undeclared identifier is reported only once _imagingtk.c:37: error: for each function it appears in.) _imagingtk.c:37: error: ?interp? undeclared (first use in this function) _imagingtk.c:45: error: expected expression before ?)? token _imagingtk.c:51: error: ?TkappObject? has no member named ?interp? _imagingtk.c:55: warning: implicit declaration of function ?TkImaging_Init? error: command 'gcc' failed with exit status 1 The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Partners Compliance HelpLine at http://www.partners.org/complianceline . If the e-mail was sent to you in error but does not contain patient information, please contact the sender and properly dispose of the e-mail. From fredrik at pythonware.com Sat Jan 31 23:20:44 2009 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 31 Jan 2009 23:20:44 +0100 Subject: [Image-SIG] Problem with converting GeoTIFF to Numpy array (ValueError: unrecognised mode) In-Reply-To: <82200558F6DE2C479D381D3000D1551C01C7942B@EXMSK1.staff.ad.curtin.edu.au> References: <82200558F6DE2C479D381D3000D1551C01C7942B@EXMSK1.staff.ad.curtin.edu.au> Message-ID: <368a5cd50901311420q7d29be90r18ddbac773c441f1@mail.gmail.com> PIL have only limited support for the "I;16" modules; try converting the image to mode "I" before you pass it on to NumPy. 2009/1/31 Hani Zahiri : > Hi > > I am trying to read a GeoTIFF and convert it to a Numpy array. Though, I am > able to open the image with no problem, however I am keep getting > 'ValueError: unrecognised mode' anytime I try to use any methods from PIL's > classes. My lines and results are like this: > > >>>import Numpy >>>from PIL import Image >>>im = Image.open('dem.TIF') >>>print im.format, im.size, im.mode >>> TIFF (6000, 6000) I;16S >>>dem = fromstring(im.tostring(),'int16') > .... > .... > ValueError: unrecognised mode > > The problem must be because of mode of my data (I;16S) and I don't know how > to read it. > I really appreciate any help with this. > > Many Thanks > Cheers, > > Hani > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > From fredrik at pythonware.com Sat Jan 31 23:26:38 2009 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 31 Jan 2009 23:26:38 +0100 Subject: [Image-SIG] installation error of PIL1.1.6 In-Reply-To: <52368789F9A31D43B7D335E33F45868201B1FE95@PHSXMB24.partners.org> References: <52368789F9A31D43B7D335E33F45868201B1FE95@PHSXMB24.partners.org> Message-ID: <368a5cd50901311426s1675348ctcf8c806a119e3501@mail.gmail.com> You're missing the Tcl/Tk developer files; see e.g. http://mail.python.org/pipermail/image-sig/2008-December/005308.html "This probably means that you have enough of Tcl/Tk installed for the installation process to think it's worth building the Tkinter support, but, as Karsten points out, not enough of it to actually be able to build that support. To fix this, either install tcl-dev/tk-dev (or whatever the packages are called on your machine), or tweak setup.py to skip that part of the process." PS. Next time you get an unexpected error message, try googling for a representative part of the message. Chances are that you're not the first one that's seen the same message. On Fri, Jan 30, 2009 at 4:00 PM, Hwang, Youngha,Ph.D. wrote: > > Hi, could someone explain to me what the following error means? > > Thanks, Youngha. > > > > building '_imagingtk' extension > creating build/temp.linux-i686-2.5/Tk > gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall > -Wstrict-prototypes -fPIC -I/usr/include/freetype2 -IlibImaging > -I/programs/l/python/2.5.2/include -I/usr/local/include -I/usr/include > -I/programs/l/python/2.5.2/include/python2.5 -c _imagingtk.c -o > build/temp.linux-i686-2.5/_imagingtk.o > _imagingtk.c:20:16: error: tk.h: No such file or directory > _imagingtk.c:23: error: expected ')' before '*' token > _imagingtk.c:31: error: expected specifier-qualifier-list before 'Tcl_Interp' > _imagingtk.c: In function '_tkinit': > _imagingtk.c:37: error: 'Tcl_Interp' undeclared (first use in this function) > _imagingtk.c:37: error: (Each undeclared identifier is reported only once > _imagingtk.c:37: error: for each function it appears in.) > _imagingtk.c:37: error: 'interp' undeclared (first use in this function) > _imagingtk.c:45: error: expected expression before ')' token > _imagingtk.c:51: error: 'TkappObject' has no member named 'interp' > _imagingtk.c:55: warning: implicit declaration of function 'TkImaging_Init' > error: command 'gcc' failed with exit status 1 > > > The information in this e-mail is intended only for the person to whom it is > addressed. If you believe this e-mail was sent to you in error and the e-mail > contains patient information, please contact the Partners Compliance HelpLine at > http://www.partners.org/complianceline . If the e-mail was sent to you in error > but does not contain patient information, please contact the sender and properly > dispose of the e-mail. > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From fredrik at pythonware.com Sat Jan 31 23:30:56 2009 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 31 Jan 2009 23:30:56 +0100 Subject: [Image-SIG] Windows PIL installer question In-Reply-To: <7e7202260901300724r524e3461m4dc5a4c7c040f50d@mail.gmail.com> References: <7e7202260901300724r524e3461m4dc5a4c7c040f50d@mail.gmail.com> Message-ID: <368a5cd50901311430n9541521r321acb82d7073ce1@mail.gmail.com> Hint: C:\>unzip -v \effbot.org\downloads\PIL-1.1.5.win32-py2.5.exe Archive: /effbot.org/downloads/PIL-1.1.5.win32-py2.5.exe warning [/effbot.org/downloads/PIL-1.1.5.win32-py2.5.exe]: 62010 extra bytes at beginning or within zipfile (attempting to process anyway) Length Method Size Ratio Date Time CRC-32 Name -------- ------ ------- ----- ---- ---- ------ ---- 5 Defl:N 7 -40% 06-04-24 14:17 34d6cc96 PLATLIB/PIL.pth 12658 Defl:N 3006 76% 05-04-06 10:13 3b4dbaad PLATLIB/PIL/ArgImagePlugin.py 3470 Defl:N 1362 61% 05-04-06 10:13 94cb46df PLATLIB/PIL/BdfFontFile.py 6914 Defl:N 2182 68% 05-04-06 10:13 c2710661 PLATLIB/PIL/BmpImag (etc) This is true for all package installers built w. distutils. (You can either use your favourite command-line unzip utility, or even write a simple installation script using Python's zipfile module). 2009/1/30 charlie : > Is there any way to run the PIL installer from the command line on > Windows in 'silent' mode, without displaying the install screens or > requiring any user interaction? > > I figured out how to do this with MSIs (the Python installer) and with > installers created with Inno setup (use innounp), but can't quite figure out > how to do this with the PIL installer, or if it is even possible. > > > > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > From evg.salmin at gmail.com Sat Jan 31 23:39:47 2009 From: evg.salmin at gmail.com (Evgeny Salmin) Date: Sun, 1 Feb 2009 04:39:47 +0600 Subject: [Image-SIG] Converting images to palette mode Message-ID: Hello, I made some basic checks in this problem (quantize error) and have following results now: I've added gc debugging to a script, tried to force collection, but at the time when quantize error happens gc says that there is no leaks. So I've decided to check C implementation of quantize() function and wrote small utility that uses C part of PIL for image quantization. Library is too old, so there is no leaks in quantize() of course :) Debugging of script shows that after processing some files malloc returns 0 (usually it in Quant.c : 1265). Sometimes I get python MemoryError exception after receiving "quantization error", sometimes not. As for memory allocation process it looks like: 7 MB (at start) --> processing --> 50 MB --> seems gc begins working here --> 7 MB -> repeat N times -> quantization error. Now I have some assumptions about it: a) Possible memory leak somewhere in split/eval/paste functions. I can check them, but I don't think it will give any results. b) Leak somewhere in a glue code. Cycle references/memmove ? I have similiar subjects at other mailing lists, maybe they will give some ideas: http://mail.python.org/pipermail/image-sig/2007-December/004720.html http://mail.python.org/pipermail/image-sig/1999-April/000713.html http://www.daniweb.com/forums/thread133133.html How will be better to track an allocation/deallocation of Imaging objects? Anyone have C samples of using C part library of PIL? I'd like to rewrite python script that causes an error in C to make sure that there is no leaks at C part, but have to work with png loading/decoding manually, so an example will be great and help to save time which I spend on examination C API. Any ideas? Regards, Evgeny. -------------- next part -------------- An HTML attachment was scrubbed... URL: