From fredrik at pythonware.com Sun Oct 2 17:37:36 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 2 Oct 2005 17:37:36 +0200 Subject: [Image-SIG] Usage of getpixel References: <000a01c5c2b0$7fa37aa0$057d7053@dell> Message-ID: "alainlioret" wrote: > I try to use getpixel(xy) ... > > But I can't .. > > for example, I try : > > pix = im.getpixel(0,0) > > But I have an error. What's wrong ? > > Can you give me an example ? getpixel expects a coordinate tuple, not two separate arguments. to get the pixel in the upper left corner, use: pix = im.getpixel((0, 0)) From x12345jp at yahoo.com.hk Tue Oct 4 16:30:57 2005 From: x12345jp at yahoo.com.hk (john taylor) Date: Tue, 4 Oct 2005 22:30:57 +0800 (CST) Subject: [Image-SIG] How to deal with BGRA color model in PIL? Message-ID: <20051004143057.57075.qmail@web50415.mail.yahoo.com> hi all, i have a string of pixel values, which uses the BGRA color model, is there an easy way (hopefully the most efficient way) to convert it into the RGBA model, so that the image can be displayed correctly? thanks a lot! john From gandalf at designaproduct.biz Tue Oct 4 16:46:39 2005 From: gandalf at designaproduct.biz (Laszlo Zsolt Nagy) Date: Tue, 04 Oct 2005 16:46:39 +0200 Subject: [Image-SIG] How to deal with BGRA color model in PIL? In-Reply-To: <20051004143057.57075.qmail@web50415.mail.yahoo.com> References: <20051004143057.57075.qmail@web50415.mail.yahoo.com> Message-ID: <434295CF.2010902@designaproduct.biz> john taylor wrote: >hi all, > >i have a string of pixel values, which uses the BGRA >color model, is there an easy way (hopefully the most >efficient way) to convert it into the RGBA model, so >that the image can be displayed correctly? > > b,g,r,a = original_image.split() new_image= Image.merge("RGBA", (r,g,b,a)) BTW, there is an almost identical example in the documentation, section "Cutting, Pasting and Merging Images / Example: Splitting and merging bands" - please read the docs. Les From x12345jp at yahoo.com.hk Wed Oct 5 16:41:08 2005 From: x12345jp at yahoo.com.hk (john taylor) Date: Wed, 5 Oct 2005 22:41:08 +0800 (CST) Subject: [Image-SIG] error in ImageChops.logical_xor ??? Message-ID: <20051005144108.61506.qmail@web50407.mail.yahoo.com> hi all, i want to compare two images, they are of the same mode ('RGB'), same format ('BMP'), same size, etc. i am using ImageChops.logical_xor(img1, img2), but it gives me this error: Traceback (most recent call last): File "", line 1, in ? File "C:\Python24\Lib\site-packages\PIL\ImageChops.py", line 262, in logical_xor return image1._new(image1.im.chop_xor(image2.im)) ValueError: image has wrong mode i've also tried calling img1.im.chop_xor(img2.im), and not surprisingly i get: Traceback (most recent call last): File "", line 1, in ? ValueError: image has wrong mode anybody can help on this? and which is the fastest way to compare two images, if i only want to know if they are identical or not? thanks a lot! john From fredrik at pythonware.com Wed Oct 5 21:23:05 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 5 Oct 2005 21:23:05 +0200 Subject: [Image-SIG] error in ImageChops.logical_xor ??? References: <20051005144108.61506.qmail@web50407.mail.yahoo.com> Message-ID: "john taylor" wrote: > i want to compare two images, they are of the same > mode ('RGB'), same format ('BMP'), same size, etc. here's a reasonably fast way to compare two images: def compare(im1, im2): import ImageChops if im1.mode != im2.mode or im1.size != im2.size: return 0 try: return ImageChops.difference(im1, im2).getbbox() is None except ValueError: return im1.tostring() == im2.tostring() I think the logical operators (which are undocumented) only work on mode "1" images. From fredrik at pythonware.com Thu Oct 6 13:55:58 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 6 Oct 2005 13:55:58 +0200 Subject: [Image-SIG] How to deal with BGRA color model in PIL? References: <20051004143057.57075.qmail@web50415.mail.yahoo.com> Message-ID: "john taylor" wrote: > i have a string of pixel values, which uses the BGRA > color model, is there an easy way (hopefully the most > efficient way) to convert it into the RGBA model, so > that the image can be displayed correctly? if you have data in a string, you can use Image.fromstring to load it into a memory buffer, converting it on the way: import Image pixel = "\x01\x02\x03\x04" im = Image.fromstring("RGBA", (1, 1), pixel, "raw", "BGRA") print im.getpixel((0, 0)) # prints (3, 2, 1, 4) if you have the data in an image memory in the wrong order, you can either use split/merge (see Laszlo's reply), or roundtrip via a string buffer: im = ... new_im = Image.fromstring("RGBA", im.size, im.tostring(), "raw", "BGRA") From b.vinegar at utoronto.ca Thu Oct 6 22:01:41 2005 From: b.vinegar at utoronto.ca (Ben) Date: Thu, 06 Oct 2005 16:01:41 -0400 Subject: [Image-SIG] PIL: Flood Color Replace? Message-ID: <434582A5.5000105@utoronto.ca> Hey all, I was wondering if PIL had an efficient function that would let me replace all pixels of a specific color with another? I could do it myself in Python, but this is for a performance-critical application. Thanks, Ben From fredrik at pythonware.com Thu Oct 6 22:42:45 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 6 Oct 2005 22:42:45 +0200 Subject: [Image-SIG] Flood Color Replace? References: <434582A5.5000105@utoronto.ca> Message-ID: "Ben" wrote: > I was wondering if PIL had an efficient function that would let me > replace all pixels of a specific color with another? I could do it > myself in Python, but this is for a performance-critical application. all pixels of a specific color in the entire image (=point operation), or in a given region that already has another color (=flood fill). From eachand at gmail.com Tue Oct 4 18:37:43 2005 From: eachand at gmail.com (Aman) Date: Tue, 4 Oct 2005 09:37:43 -0700 Subject: [Image-SIG] Multi Page Batch Process Message-ID: <5dc4aea70510040937g6aa98b42v7317491983ad3016@mail.gmail.com> Hi Trying to come up with a routine for joing tiff files: Input : single page G4 tiff files names Out put : Multipage tiff files Does anyone have something along these lines as i have hardly donw development in python. Thanks in advance Aman -- "..I believe that imagination is stronger than knowledge--that myth is more potent than history. I believe that dreams are more powerful than facts--That hope always triumphs over experience--That laughter is the only cure for grief. And I believe that love is stronger than death..."-------------Robert Fulghum -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20051004/390d75ba/attachment.htm From jhu at metrigenix.com Fri Oct 7 23:52:51 2005 From: jhu at metrigenix.com (James Hu) Date: Fri, 7 Oct 2005 17:52:51 -0400 Subject: [Image-SIG] can't show png file with mode "I" Message-ID: <90DEA7ED93F71A4580CEDF76A02682EA03ACBE@torexch.metrigenix.com> Hi, I captured image from digital camera and saved it to png file with: Image.fromstring("I", datasize, origFrame.pBuffer, 'raw', 'I;16') But when I open it with PIL.Image im=Image.open("*.png") Im.show() Got white image, What might be the problem? This png file can be open with IrfanView, or using wx.Image. Thanks in advance. James -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20051007/7536f892/attachment.html From fredrik at pythonware.com Sat Oct 8 21:19:02 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 8 Oct 2005 21:19:02 +0200 Subject: [Image-SIG] can't show png file with mode "I" References: <90DEA7ED93F71A4580CEDF76A02682EA03ACBE@torexch.metrigenix.com> Message-ID: (stuck in the spam filter, due to excessive use of HTML. please post plain text messages to this list if at all possible). James Hu wrote: > I captured image from digital camera and saved it to png file with: > > Image.fromstring("I", datasize, origFrame.pBuffer, 'raw', 'I;16') > > But when I open it with PIL.Image > > im=Image.open("*.png") > Im.show() > > Got white image, > What might be the problem? I've answered this on comp.lang.python: http://article.gmane.org/gmane.comp.python.general/424715 but here's the answer again, for the archives: maybe all pixels in the PNG file are larger than 255 ? show doesn't support 16-bit images, so it clamps the values down to an 8-bit range. adding a print im.getextrema() will tell you what values you have in the image (it returns min and max). to scale things down before you display it, you can use something like: im = im.point(lambda x: x*(1.0/256)) or lo, hi = im.getextrema() if lo == hi: im = im.point(lambda x: 128) # or something else: scale = 255.0 / (hi - lo) offset = -lo * scale + 0.5 im = im.point(lambda x: x*scale + offset) hope this helps! From michele.petrazzo at unipex.it Mon Oct 10 09:39:12 2005 From: michele.petrazzo at unipex.it (Michele Petrazzo) Date: Mon, 10 Oct 2005 09:39:12 +0200 Subject: [Image-SIG] Multi Page Batch Process In-Reply-To: <5dc4aea70510040937g6aa98b42v7317491983ad3016@mail.gmail.com> References: <5dc4aea70510040937g6aa98b42v7317491983ad3016@mail.gmail.com> Message-ID: <434A1AA0.6030908@unipex.it> Aman wrote: > Hi > > Trying to come up with a routine for joing tiff files: > > Input : single page G4 tiff files names Out put : Multipage tiff > files > > > Does anyone have something along these lines as i have hardly donw > development in python. > I don't know if you know freeimagepy, but I develop it because I didn't find any other project that work well with tiff G3/G4 and multipage files. Try it, if you want of course :), and let me know if you have problems. freeimagepy.sf.net > > Thanks in advance Aman > Michele From daviddench at tiscali.co.uk Mon Oct 10 14:07:54 2005 From: daviddench at tiscali.co.uk (David Dench) Date: Mon, 10 Oct 2005 13:07:54 +0100 Subject: [Image-SIG] Image Stacking and AVI processing Message-ID: <434A599A.10207@tiscali.co.uk> Dear All, I am returning to the fold after a long absence and need a quick start. I want to split an AVI into a set of cropped AVI's eg split the AVI from 640x480 sized frames into 4 quarter sized AVIs of same length but smaller frame size. I then want to stack/average each AVI ( usually after aligning on a feature ) and then recombine the stacked images back into a single full size 640x480 image. Some of you may recognize similarities to Registax functionality with good reason. I have done a quick Python trawl and found PyMedia and NumArray which might help in what I want to do ( I know PIL of old and expect to use it ). Have I missed any existing software in my ignorance or are there alternative packages that I should be investigating ? Very best wishes to all, David Dench PS As an alternative, I could glue together some existing Windows GUI intensive Apps. Is there a python Expect like package suitable for the task ? From gwidion at mpc.com.br Mon Oct 10 15:08:27 2005 From: gwidion at mpc.com.br (Joao S. O. Bueno Calligaris) Date: Mon, 10 Oct 2005 10:08:27 -0300 Subject: [Image-SIG] Image Stacking and AVI processing In-Reply-To: <434A599A.10207@tiscali.co.uk> References: <434A599A.10207@tiscali.co.uk> Message-ID: <200510101008.27571.gwidion@mpc.com.br> On Monday 10 October 2005 09:07, David Dench wrote: > Dear All, > I am returning to the fold after a long absence and need a quick > start. I want to split an AVI into a set of cropped AVI's eg split > the AVI from 640x480 sized frames > into 4 quarter sized AVIs of same length but smaller frame size. > I then want to stack/average each AVI ( usually after aligning on a > feature ) and then recombine > the stacked images back into a single full size 640x480 image. > Some of you may recognize similarities to Registax functionality > with good reason. > I have done a quick Python trawl and found PyMedia and NumArray > which might help > in what I want to do ( I know PIL of old and expect to use it ). > Have I missed any existing software in my ignorance or are there > alternative packages that > I should be investigating ? > Very best wishes to all, > David Dench > PS As an alternative, I could glue together some existing Windows > GUI intensive Apps. Is there a python > Expect like package suitable for the task ? This sounds "doable" with the Gimp Animation Package (GIMP-GAP) extension for the GIMP. It won't be trivial, though. If you want to try do do it interactively instead of programatically (you can code python scripts for intermediate steps in the proccess if you need to), go for it. > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig From fredrik at pythonware.com Sat Oct 15 18:18:51 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 15 Oct 2005 18:18:51 +0200 Subject: [Image-SIG] AGG-based drawing for PIL References: Message-ID: > the "aggdraw" module is a prerelease of a new drawing library for PIL, > based on Maxim Shemanarev's antigrain (AGG) graphics library. This > module implements a WCK-style drawing interface (see below), and > provides anti-aliasing and alpha compositing. 1.1 final is now available from: http://effbot.org/downloads/#aggdraw documentation: http://effbot.org/zone/draw-agg.htm (overview) http://effbot.org/zone/pythondoc-aggdraw.htm (api reference) for a list of changes in this release, see: http://effbot.org/downloads/index.cgi/aggdraw-1.1-20051010.zip/CHANGES enjoy /F From dima at shiftingplanes.org Sun Oct 16 01:40:16 2005 From: dima at shiftingplanes.org (Dmitry (Dima) Strakovsky) Date: Sat, 15 Oct 2005 18:40:16 -0500 Subject: [Image-SIG] vector graphics Q Message-ID: <43519360.4040203@shiftingplanes.org> hi all, My question is perhaps related to Fredrik earlier post. I read API doc (understood about 30%) I am basically looking for a way to manupulate vector graphics in Python. So far I have been reading up on SVG and looking at the output from Illustrator and Inkscape (Adobe seems to throw a whole bunch of proprietary stuff into the files, surprise?not) The images for this particular project are going to be generated in Illustrator (the program I am most familiar with) and probably cleaned up with another utility (possibly python script), after which I was going to do a fair amount of manipulation (hopefully python script) and the final output goes to the printer (rastered.) Fredrick does your lib work with SVG? Is there a library out there that is particularly nice (has resize,rotate,copy,paste type functions)for working with SVGs? Am I married to SVG for absolutely no reason? As I stated in an earlier post I am new to both Python and PIL (and a fairly crapy (read not a professional) programmer on top of that :) so links to source code snippets are much appreciated :) <-- and NO there will not be any write-this-whole-program-for-me type follow up questions! thnx in advance, dima From p.f.moore at gmail.com Sun Oct 16 14:54:19 2005 From: p.f.moore at gmail.com (Paul Moore) Date: Sun, 16 Oct 2005 13:54:19 +0100 Subject: [Image-SIG] vector graphics Q In-Reply-To: <43519360.4040203@shiftingplanes.org> References: <43519360.4040203@shiftingplanes.org> Message-ID: <79990c6b0510160554u6d93597fi24ec97c736161996@mail.gmail.com> On 10/16/05, Dmitry (Dima) Strakovsky wrote: > Fredrick does your lib work with SVG? I believe that PIL is for bitmap images only, and as such, SVG isn't supported. If you look in the appendix "Image File Formats" of the PIL handbook (http://www.pythonware.com/library/pil/handbook/index.htm) you'll see that SVG isn't documented as being supported. > Is there a library out there that is particularly nice (has > resize,rotate,copy,paste type functions)for working with SVGs? I also have some interest in vector graphics processing. (Although it's fairly casual so far). One specific thing I would like to be able to do is to take a bitmap format of a line image (a scanned copy of a line drawing, to be specific) and convert it to vector format. I realise that this isn't a trivial task (edge detection, and so on) but are there any tools or libraries that will do this? I haven't found any support in PIL for this, but maybe I've missed something... Thanks, Paul. From dima at shiftingplanes.org Sun Oct 16 15:39:48 2005 From: dima at shiftingplanes.org (Dmitry (Dima) Strakovsky) Date: Sun, 16 Oct 2005 08:39:48 -0500 Subject: [Image-SIG] vector graphics Q In-Reply-To: <79990c6b0510160554u6d93597fi24ec97c736161996@mail.gmail.com> References: <43519360.4040203@shiftingplanes.org> <79990c6b0510160554u6d93597fi24ec97c736161996@mail.gmail.com> Message-ID: <43525824.50707@shiftingplanes.org> Hi Paul, I haven't done any testing of bitmap to SVG myself, so this is not a voice of experience :) hope this helps: http://www.scale-a-vector.de/svg-test4-e.htm http://autotrace.sourceforge.net/ Would love to hear if people on the list have used any of the above tools. Actually handbook is what got me using PIL (thank you Fredrik,Matthew) it is one of the BEST features of the library. I tried using ImageMagick before and encountered severe lack of well written documentation (and lots of crazy uses for pointers and macros.) ouch! However the handbook was written almost 3 years ago and while the core of the library has not changed (i think) some new features might have been added (as demonstrated by Fredrik's post yesterday.) I know I am being a noob, but I figure I gotta ask :) I found the following lib http://www2.sfk.nl/svg ... and once again hit a documentation wall (not as severe in python case.) Has anyone used this lib? It looks like development on it has stopped sometime last year. Is there something comparable brewing somewhere else? Thank you very much for your reply Paul and good luck with bitmap to SVG. If I come accross any more info I'll post it to the list. dima Paul Moore wrote: >On 10/16/05, Dmitry (Dima) Strakovsky wrote: > > >>Fredrick does your lib work with SVG? >> >> > >I believe that PIL is for bitmap images only, and as such, SVG isn't >supported. If you look in the appendix "Image File Formats" of the PIL >handbook (http://www.pythonware.com/library/pil/handbook/index.htm) >you'll see that SVG isn't documented as being supported. > > > >>Is there a library out there that is particularly nice (has >>resize,rotate,copy,paste type functions)for working with SVGs? >> >> > >I also have some interest in vector graphics processing. (Although >it's fairly casual so far). > >One specific thing I would like to be able to do is to take a bitmap >format of a line image (a scanned copy of a line drawing, to be >specific) and convert it to vector format. I realise that this isn't a >trivial task (edge detection, and so on) but are there any tools or >libraries that will do this? I haven't found any support in PIL for >this, but maybe I've missed something... > >Thanks, >Paul. > > > > From fredrik at pythonware.com Sun Oct 16 18:03:00 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 16 Oct 2005 18:03:00 +0200 Subject: [Image-SIG] vector graphics Q References: <43519360.4040203@shiftingplanes.org> Message-ID: Dmitry (Dima) Strakovsky wrote: > My question is perhaps related to Fredrik earlier post. I read API doc > (understood about 30%) > > I am basically looking for a way to manupulate vector graphics in > Python. So far I have been reading up on SVG and looking at the output > from Illustrator and Inkscape (Adobe seems to throw a whole bunch of > proprietary stuff into the files, surprise?not) The images for this > particular project are going to be generated in Illustrator (the program > I am most familiar with) and probably cleaned up with another utility > (possibly python script), after which I was going to do a fair amount of > manipulation (hopefully python script) and the final output goes to the > printer (rastered.) > > Fredrick does your lib work with SVG? aggdraw and PIL only provide a small part of the full "graphics application" stack. a full "stack" (e.g. Illustrator) might look like this: 1. a user interface 2. a data model that represents the drawing 3. an I/O library that can be used to store the drawing on disk 4. a rendering system in your case, you want to replace the user interface with scripts, so you need a "stack" that looks like this: 1. a script engine interface 2. a data model that represents the drawing 3. an I/O library that can be used to store the drawing on disk 4. a rendering system the aggdraw library provides a (somewhat limited) implementation of 4, and some support for 3 (it can parse SVG path descriptors), but nothing more than that. if aggdraw/PIL/Python is a realistic approach depends on what kind of drawings you will work on, and what you need to do it with them. I've been using the following toolchain for a couple of projects: 1. draw in illustrator 2. if necessary, convert to outlines 3. save as SVG 4. load into element structure using ElementTree: http://effbot.org/zone/element-index.htm 5. manipulate element structure 6. render relevant parts using aggdraw 7. save using PIL this is quite useful for simple drawings, such as icons and other symbols, but might need a lot of work if you want to support more illustrator/SVG features (and/or get rid of the second step). From p.f.moore at gmail.com Sun Oct 16 18:44:33 2005 From: p.f.moore at gmail.com (Paul Moore) Date: Sun, 16 Oct 2005 17:44:33 +0100 Subject: [Image-SIG] vector graphics Q In-Reply-To: <43525824.50707@shiftingplanes.org> References: <43519360.4040203@shiftingplanes.org> <79990c6b0510160554u6d93597fi24ec97c736161996@mail.gmail.com> <43525824.50707@shiftingplanes.org> Message-ID: <79990c6b0510160944m264944b0ja0707394c338a1f6@mail.gmail.com> On 10/16/05, Dmitry (Dima) Strakovsky wrote: > I haven't done any testing of bitmap to SVG myself, so this is not a > voice of experience :) > hope this helps: > > http://www.scale-a-vector.de/svg-test4-e.htm > http://autotrace.sourceforge.net/ Thanks for the linke - I'll have a look... Paul. From Chris.Barker at noaa.gov Mon Oct 17 07:08:50 2005 From: Chris.Barker at noaa.gov (Chris Barker) Date: Sun, 16 Oct 2005 22:08:50 -0700 Subject: [Image-SIG] vector graphics Q In-Reply-To: <43525824.50707@shiftingplanes.org> References: <43519360.4040203@shiftingplanes.org> <79990c6b0510160554u6d93597fi24ec97c736161996@mail.gmail.com> <43525824.50707@shiftingplanes.org> Message-ID: <435331E2.9040207@noaa.gov> You might want to also take a look at wxArt2d. Sadly, however, it not yet been wrapped for use with Python. http://wxart2d.sourceforge.net/ -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (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 dima at shiftingplanes.org Wed Oct 19 04:15:55 2005 From: dima at shiftingplanes.org (Dmitry (Dima) Strakovsky) Date: Tue, 18 Oct 2005 21:15:55 -0500 Subject: [Image-SIG] vector graphics Q In-Reply-To: References: <43519360.4040203@shiftingplanes.org> Message-ID: <4355AC5B.6070807@shiftingplanes.org> Thanx Fredrik, I'm slowly making my way through ElementTree code. It's definately an intersting direction and fun code to play with :) Must admit that I am still struggling with OO code, but it is very helthy for me to get my head out of assembly mode every once in a while. thank you again, dima -- Dmitry (Dima) Strakovsky dima at shiftingplanes.org www.shiftingplanes.org Fredrik Lundh wrote: >Dmitry (Dima) Strakovsky wrote: > > > >>My question is perhaps related to Fredrik earlier post. I read API doc >>(understood about 30%) >> >>I am basically looking for a way to manupulate vector graphics in >>Python. So far I have been reading up on SVG and looking at the output >>from Illustrator and Inkscape (Adobe seems to throw a whole bunch of >>proprietary stuff into the files, surprise?not) The images for this >>particular project are going to be generated in Illustrator (the program >>I am most familiar with) and probably cleaned up with another utility >>(possibly python script), after which I was going to do a fair amount of >>manipulation (hopefully python script) and the final output goes to the >>printer (rastered.) >> >>Fredrick does your lib work with SVG? >> >> > >aggdraw and PIL only provide a small part of the full "graphics application" >stack. a full "stack" (e.g. Illustrator) might look like this: > > 1. a user interface > 2. a data model that represents the drawing > 3. an I/O library that can be used to store the drawing on disk > 4. a rendering system > >in your case, you want to replace the user interface with scripts, so you >need a "stack" that looks like this: > > 1. a script engine interface > 2. a data model that represents the drawing > 3. an I/O library that can be used to store the drawing on disk > 4. a rendering system > >the aggdraw library provides a (somewhat limited) implementation of 4, >and some support for 3 (it can parse SVG path descriptors), but nothing >more than that. > >if aggdraw/PIL/Python is a realistic approach depends on what kind of >drawings you will work on, and what you need to do it with them. I've >been using the following toolchain for a couple of projects: > > 1. draw in illustrator > 2. if necessary, convert to outlines > 3. save as SVG > 4. load into element structure using ElementTree: > http://effbot.org/zone/element-index.htm > 5. manipulate element structure > 6. render relevant parts using aggdraw > 7. save using PIL > >this is quite useful for simple drawings, such as icons and other symbols, >but might need a lot of work if you want to support more illustrator/SVG >features (and/or get rid of the second step). > > > > > >_______________________________________________ >Image-SIG maillist - Image-SIG at python.org >http://mail.python.org/mailman/listinfo/image-sig > > > > From dima at shiftingplanes.org Thu Oct 20 06:02:45 2005 From: dima at shiftingplanes.org (Dmitry (Dima) Strakovsky) Date: Wed, 19 Oct 2005 23:02:45 -0500 Subject: [Image-SIG] possible PIL bug? Message-ID: <435716E5.2090106@shiftingplanes.org> Here is a possible PIL bug. I appologise in advance if I am doing something silly python-wise. When using resize method and using BILINEAR, BICUBIC or NEAREST arguments For example: ImageName.resize((200,300),ANTIALIAS) interpreter tells me that the global name "ANTIALIAS" is not defined the globals are definately defined in image.py Shouldn't they be imported as a part of "import Image" routine? Anyways, entering numeric values: ImageName.resize((200,300),1) obviously solves the problem, but makes things a bit harder to read down the line thank you, dima -- Dmitry (Dima) Strakovsky dima at shiftingplanes.org www.shiftingplanes.org From chris at cogdon.org Thu Oct 20 06:09:02 2005 From: chris at cogdon.org (Chris Cogdon) Date: Wed, 19 Oct 2005 21:09:02 -0700 Subject: [Image-SIG] possible PIL bug? In-Reply-To: <435716E5.2090106@shiftingplanes.org> References: <435716E5.2090106@shiftingplanes.org> Message-ID: On Oct 19, 2005, at 9:02 PM, Dmitry (Dima) Strakovsky wrote: > Here is a possible PIL bug. I appologise in advance if I am doing > something silly python-wise. > > When using resize method and using BILINEAR, BICUBIC or NEAREST > arguments > > For example: ImageName.resize((200,300),ANTIALIAS) > > interpreter tells me that the global name "ANTIALIAS" is not defined > > the globals are definately defined in image.py Shouldn't they be > imported as a part of > "import Image" routine? > > Anyways, entering numeric values: ImageName.resize((200,300),1) > obviously solves the problem, but makes things a bit harder to read > down > the line Try Image.ANTIALIAS Python won't 'flood' your namespace with variables unless you explicitly ask it to. -- ("`-/")_.-'"``-._ Chris Cogdon . . `; -._ )-;-,_`) (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' ((,.-' ((,/ fL From dima at shiftingplanes.org Fri Oct 21 04:44:45 2005 From: dima at shiftingplanes.org (Dmitry (Dima) Strakovsky) Date: Thu, 20 Oct 2005 21:44:45 -0500 Subject: [Image-SIG] possible PIL bug? In-Reply-To: References: <435716E5.2090106@shiftingplanes.org> Message-ID: <4358561D.2080907@shiftingplanes.org> Thank for your reply Chris, Chris Cogdon wrote: > > On Oct 19, 2005, at 9:02 PM, Dmitry (Dima) Strakovsky wrote: > >> Here is a possible PIL bug. I appologise in advance if I am doing >> something silly python-wise. >> >> When using resize method and using BILINEAR, BICUBIC or NEAREST >> arguments >> >> For example: ImageName.resize((200,300),ANTIALIAS) >> >> interpreter tells me that the global name "ANTIALIAS" is not defined >> >> the globals are definately defined in image.py Shouldn't they be >> imported as a part of >> "import Image" routine? >> >> Anyways, entering numeric values: ImageName.resize((200,300),1) >> obviously solves the problem, but makes things a bit harder to read >> down >> the line > > > Try Image.ANTIALIAS > > > Python won't 'flood' your namespace with variables unless you > explicitly ask it to. > That actually seems like a great language feature. Thank you for explaining it. d -- Dmitry (Dima) Strakovsky dima at shiftingplanes.org www.shiftingplanes.org From fredrik at pythonware.com Sat Oct 22 15:39:35 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 22 Oct 2005 15:39:35 +0200 Subject: [Image-SIG] AGG-based drawing for PIL References: Message-ID: continuing the tradition of announcing new releases by replying to myself: > the "aggdraw" module is a prerelease of a new drawing library for PIL, > based on Maxim Shemanarev's antigrain (AGG) graphics library. This > module implements a WCK-style drawing interface (see below), and > provides anti-aliasing and alpha compositing. A very early 1.2 alpha is now available. You can now create "drawable Windows DIB surfaces", and blit them to screen under any Windows-based toolkit that lets you access the HWND for a toolkit window. draw = aggdraw.Dib("RGB", (width, height)) ... draw as usual ... draw.expose(hwnd) # blit to screen Here's a Tkinter example: size = width, height draw = aggdraw.Dib("RGB", size) ... draw as usual ... # display the image frame = Frame(width=size[0], height=size[1], bg="") frame.bind("", lambda e: draw.expose(e.widget.winfo_id())) frame.pack() A source kit can be found here: http://effbot.org/downloads/#aggdraw To display aggdraw images under Tkinter on other platforms, you can use PIL's ImageTk.PhotoImage object, or the WCK toolkit. See http://effbot.org/zone/wck-aggview.htm for an example on how to use the latter. From William.T.Bridgman.1 at gsfc.nasa.gov Mon Oct 24 17:30:50 2005 From: William.T.Bridgman.1 at gsfc.nasa.gov (W.T. Bridgman) Date: Mon, 24 Oct 2005 11:30:50 -0400 Subject: [Image-SIG] Undocumented floating-point TIF support in PIL? Message-ID: The PIL documentation claims that TIFF files are supported for "1", "L", "RGB", or "CMYK" data. I was examining the Tiff plug-in and did not find anything that suggested "F" was unsupported so I tried writing and reading a simple floating-point TIFF. It worked. Is this just a missing entry in the docs or does anyone know of potential gotchas should I start using this new found capability? Thanks, Tom -- Dr. William T."Tom" Bridgman Scientific Visualization Studio Global Science & Technology, Inc. NASA/Goddard Space Flight Center Email: William.T.Bridgman.1 at gsfc.nasa.gov Code 610.3 Phone: 301-286-1346 Greenbelt, MD 20771 FAX: 301-286-1634 http://svs.gsfc.nasa.gov/ From janssen at parc.com Tue Oct 25 02:39:07 2005 From: janssen at parc.com (Bill Janssen) Date: Mon, 24 Oct 2005 17:39:07 PDT Subject: [Image-SIG] Image.convert() doesn't dither? Message-ID: <05Oct24.173910pdt."58617"@synergy1.parc.xerox.com> The PIL manual says that calling image.convert('1') on a greyscale image will threshold the image (fairly starkly: "all non-zero values are set to 255 (white).") However, when I try this on a test page of color blocks, I seem to get Floyd-Steinberg dithering instead. The code sequence I use is: import Image, ImageOps im = Image.open(infilename) if im.mode == 'RGB': im = ImageOps.grayscale(im) if im.mode == 'L': im = ImageOps.autocontrast(im) im = im.convert('1') im.save(outfilename, 'TIFF') Is the documentation out of date? If I want thresholding, is there a now a way to do it without using "point"? Using quantize(), perhaps? Is there a difference between Image.convert('L') and ImageOps.grayscale()? Bill From bbaxter at wadsworth.org Tue Oct 25 02:47:28 2005 From: bbaxter at wadsworth.org (William Baxter) Date: Mon, 24 Oct 2005 20:47:28 -0400 Subject: [Image-SIG] ImageTk.py not installed Message-ID: <435D80A0.9EC24E0B@wadsworth.org> How come ImageTk.py is not put in the site-packages/PIL directory with all the other modules? It's there in the src/Imaging-1.1.5/build/lib.linux-etc directory when you build Imaging. But it doesn't appear in site-packages/PIL during the install. The answer is simply to copy it to the place where it's needed, but this has been a 'gotcha' everytime I've installed Imaging. Bill Baxter From fredrik at pythonware.com Tue Oct 25 11:04:32 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 25 Oct 2005 11:04:32 +0200 Subject: [Image-SIG] Image.convert() doesn't dither? References: <05Oct24.173910pdt."58617"@synergy1.parc.xerox.com> Message-ID: Bill Janssen wrote: > The PIL manual says that calling image.convert('1') on a greyscale > image will threshold the image (fairly starkly: "all non-zero values > are set to 255 (white).") However, when I try this on a test page of > color blocks, I seem to get Floyd-Steinberg dithering instead. > Is the documentation out of date? most likely. the draft version at http://effbot.org/imagingbook/image.htm says When converting to a bilevel image (mode "1"), the source image is first converted to black and white. Resulting values larger than 127 are then set to white, and the image is dithered. To use other thresholds, use the point method. (but it doesn't mention the dither option, so it needs to be fixed too) > If I want thresholding, is there a now a way to do it without using > "point"? Using quantize(), perhaps? im = im.convert("1", dither=Image.NONE) should work. > Is there a difference between Image.convert('L') and > ImageOps.grayscale()? nope: def grayscale(image): "Convert to grayscale" return image.convert("L") (all ImageOps operations can be rewritten in terms of core operations; that module's only purpose is to provide a higher-level interface for some commonly used operations. not all operations are quite as trivial as the one above, though...) From fredrik at pythonware.com Tue Oct 25 11:07:01 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 25 Oct 2005 11:07:01 +0200 Subject: [Image-SIG] ImageTk.py not installed References: <435D80A0.9EC24E0B@wadsworth.org> Message-ID: William Baxter wrote: > How come ImageTk.py is not put in the site-packages/PIL directory with > all the other modules? It's there in the > src/Imaging-1.1.5/build/lib.linux-etc directory when you build Imaging. > But it doesn't appear in site-packages/PIL during the install. The > answer is simply to copy it to the place where it's needed, but this has > been a 'gotcha' everytime I've installed Imaging. works for me. what linux release is this, and what Python version ? (has anyone else seen this?) From janssen at parc.com Tue Oct 25 19:34:37 2005 From: janssen at parc.com (Bill Janssen) Date: Tue, 25 Oct 2005 10:34:37 PDT Subject: [Image-SIG] Image.convert() doesn't dither? In-Reply-To: Your message of "Tue, 25 Oct 2005 02:04:32 PDT." Message-ID: <05Oct25.103444pdt."58617"@synergy1.parc.xerox.com> Thanks! Bill From janssen at parc.com Tue Oct 25 19:44:40 2005 From: janssen at parc.com (Bill Janssen) Date: Tue, 25 Oct 2005 10:44:40 PDT Subject: [Image-SIG] Image.convert() doesn't dither? In-Reply-To: Your message of "Tue, 25 Oct 2005 02:04:32 PDT." Message-ID: <05Oct25.104444pdt."58617"@synergy1.parc.xerox.com> > When converting to a bilevel image (mode "1"), the source image > is first converted to black and white. Resulting values larger than I think it would be clearer to say "the source image is first converted to grayscale." > Resulting values larger than > 127 are then set to white, and the image is dithered. To use other > thresholds, use the point method. This doesn't make sense to me. If I take a four-color block, the four colors having luminance values of 0, 33%, 66%, and 100%, the above process would give me an image which is half gray (actually, black) and half white, with some dithering on the gray half. Instead, I get four carefully delineated blocks, two of which are dithered gray, one of which is white, and one of which is black. I think it makes more sense to say, "the image is dithered to bitonal black and white using the Floyd-Steinberg error diffusion filter and a threshold value of 127." Bill From s_t_a_n_i at yahoo.com Tue Oct 25 22:38:47 2005 From: s_t_a_n_i at yahoo.com (www.stani.be) Date: Tue, 25 Oct 2005 13:38:47 -0700 (PDT) Subject: [Image-SIG] AGG-based drawing for PIL In-Reply-To: Message-ID: <20051025203847.21147.qmail@web32607.mail.mud.yahoo.com> Any chance for a cross-platform solution? Stani -- SPE - Stani's Python Editor http://pythonide.stani.be http://pythonide.stani.be/manual/html/manual.html --- Fredrik Lundh wrote: > continuing the tradition of announcing new releases > by replying > to myself: > > > the "aggdraw" module is a prerelease of a new > drawing library for PIL, > > based on Maxim Shemanarev's antigrain (AGG) > graphics library. This > > module implements a WCK-style drawing interface > (see below), and > > provides anti-aliasing and alpha compositing. > > A very early 1.2 alpha is now available. > > You can now create "drawable Windows DIB surfaces", > and blit them > to screen under any Windows-based toolkit that lets > you access the > HWND for a toolkit window. > > draw = aggdraw.Dib("RGB", (width, height)) > ... draw as usual ... > draw.expose(hwnd) # blit to screen > > Here's a Tkinter example: > > size = width, height > > draw = aggdraw.Dib("RGB", size) > ... draw as usual ... > > # display the image > frame = Frame(width=size[0], height=size[1], > bg="") > frame.bind("", lambda e: > draw.expose(e.widget.winfo_id())) > frame.pack() > > A source kit can be found here: > > http://effbot.org/downloads/#aggdraw > > To display aggdraw images under Tkinter on other > platforms, you can use > PIL's ImageTk.PhotoImage object, or the WCK toolkit. > See > > http://effbot.org/zone/wck-aggview.htm > > for an example on how to use the latter. > > > > > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > __________________________________ Yahoo! FareChase: Search multiple travel sites in one click. http://farechase.yahoo.com From fredrik at pythonware.com Wed Oct 26 12:16:42 2005 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 26 Oct 2005 12:16:42 +0200 Subject: [Image-SIG] AGG-based drawing for PIL References: <20051025203847.21147.qmail@web32607.mail.mud.yahoo.com> Message-ID: Stani wrote: > Any chance for a cross-platform solution? aggdraw in itself is cross-platform. if you're not on Windows, or prefer to write portable code, you can either use tostring() or PIL to transfer the images from aggdraw's internal buffer to the format used by the UI toolkit you're using. for example, you can write portable Tkinter code via PIL's ImageTk layer: im = Image.new("RGB", size) draw = aggdraw.Draw(im) ... draw.flush() del draw image = ImageTk.PhotoImage(im) or you can use something like the WCK's ui_image method: draw = aggdraw.Draw(mode, size) ... image = self.ui_image(draw.mode, draw.size, draw.tostring()) for wxPython, something like: draw = aggdraw.Draw("RGB", size) ... image = wx.EmptyImage(*size) image.SetData(draw.tostring()) should work. From arnd.baecker at web.de Wed Oct 26 13:08:22 2005 From: arnd.baecker at web.de (Arnd Baecker) Date: Wed, 26 Oct 2005 13:08:22 +0200 (CEST) Subject: [Image-SIG] AGG-based drawing for PIL In-Reply-To: References: <20051025203847.21147.qmail@web32607.mail.mud.yahoo.com> Message-ID: On Wed, 26 Oct 2005, Fredrik Lundh wrote: > for example, you can write portable Tkinter code via PIL's ImageTk layer: > > im = Image.new("RGB", size) > draw = aggdraw.Draw(im) > ... > draw.flush() > del draw > > image = ImageTk.PhotoImage(im) > > or you can use something like the WCK's ui_image method: > > draw = aggdraw.Draw(mode, size) > ... > image = self.ui_image(draw.mode, draw.size, draw.tostring()) > > for wxPython, something like: > > draw = aggdraw.Draw("RGB", size) > ... > image = wx.EmptyImage(*size) > image.SetData(draw.tostring()) Does the ".tostring()" part cost a lot of performance? I.e. could there be more direct approaches which would be even faster? (I remember there was some discussion on the matplotlib mailing list concerning fast conversion of agg buffers to wx, see http://sourceforge.net/mailarchive/message.php?msg_id=12801822 and the corresponding _wxagg.cpp http://cvs.sourceforge.net/viewcvs.py/matplotlib/matplotlib/src/_wxagg.cpp?rev=1.1&view=auto ) Best, Arnd From Chris.Barker at noaa.gov Wed Oct 26 20:17:23 2005 From: Chris.Barker at noaa.gov (Chris Barker) Date: Wed, 26 Oct 2005 11:17:23 -0700 Subject: [Image-SIG] AGG-based drawing for PIL In-Reply-To: References: <20051025203847.21147.qmail@web32607.mail.mud.yahoo.com> Message-ID: <435FC833.8050409@noaa.gov> Arnd Baecker wrote: > Does the ".tostring()" part cost a lot of performance? Well, I think you get at least two copies of the data: one to make the string, and then another one to make the wx.image. It would be nice to just pass a pointer to the data buffer right through to wx.Image. Fredrik, Have you seen the new "array interface" put out by the NumPy folks? http://numeric.scipy.org/array_interface.html It's not intended to by NumPy specific. the idea is to have a standard interface so that different Python extensions that need to pass blocks of homogeneous data around (like images, for instance) could have a standard interface for doing so. That way each extension only needs to know about the interface, not each other extension it might need to work with. This could be a lot more efficient than using PyStrings to pass data around. I'm hoping to implement it in wxPython for just this kind of thing. It would be great if PIL did it too. I know a lot of folks do work with PIL images and NumPy arrays. The Python Buffer object is another option. -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (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 janssen at parc.com Wed Oct 26 20:11:14 2005 From: janssen at parc.com (Bill Janssen) Date: Wed, 26 Oct 2005 11:11:14 PDT Subject: [Image-SIG] AGG-based drawing for PIL In-Reply-To: Your message of "Wed, 26 Oct 2005 03:16:42 PDT." Message-ID: <05Oct26.111120pdt."58617"@synergy1.parc.xerox.com> > aggdraw in itself is cross-platform. if you're not on Windows, or prefer > to write portable code, you can either use tostring() or PIL to transfer > the images from aggdraw's internal buffer to the format used by the UI > toolkit you're using. Or you could try using pycairo (http://cairographics.org/pycairo) instead, a portable imaging solution. Fredrik, are you using Cairo under WCK? Cairo interests me because it has the ability to exploit hardware acceleration on all the major OS platforms. Bill From james_hu at hotmail.com Sun Oct 9 04:57:54 2005 From: james_hu at hotmail.com (James HU) Date: Sun, 09 Oct 2005 02:57:54 -0000 Subject: [Image-SIG] PIL Image can open all types of pnf files ? Message-ID: An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20051009/90a09dd7/attachment.htm From james_hu at hotmail.com Sun Oct 9 05:20:24 2005 From: james_hu at hotmail.com (James HU) Date: Sun, 09 Oct 2005 03:20:24 -0000 Subject: [Image-SIG] sorry for posting the same Qs again, but Message-ID: An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20051009/718c65b4/attachment.html From andrea_gavana at tin.it Wed Oct 12 00:16:00 2005 From: andrea_gavana at tin.it (Andrea Gavana) Date: Tue, 11 Oct 2005 22:16:00 -0000 Subject: [Image-SIG] Question On "Changing" Colour Message-ID: <00c901c5cf7a$1f615780$69820257@Gavana> Hello NG, I have a small image that looks like a GUI button (with 3D effects given by different pixels colours). The current image has as "basic" colour the grey. For "basic", I mean that the predominant colour in the image is grey and some other pixels are brighter or darker in order to give the 3D effect on that image. Now my question: is it possible to transform the pixels colours in order to have another basic colour (say blue)? In other words, the predominant colour will become the blue, with other pixels in a brighter or darker blue to give the same 3D effects. Thanks a lot for every suggestion, and sorry if it is a basic question. I just started to learn PIL. Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://xoomer.virgilio.it/infinity77 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20051011/e4aa5edf/attachment.htm From jhu at metrigenix.com Sat Oct 15 00:06:06 2005 From: jhu at metrigenix.com (James Hu) Date: Fri, 14 Oct 2005 22:06:06 -0000 Subject: [Image-SIG] open tiff fil in wxImage directlye Message-ID: <90DEA7ED93F71A4580CEDF76A02682EA03ACC2@torexch.metrigenix.com> Hi, all gurus, I need to display 16 bit tiff image on screen directly, but it doesn't work, only black or gray background shown, (converting from tiff to png first is not option though). I checked the document, which says wxImage can open tif! Any info or help will be appreciated greatly!!! BTW, I sent this message in another account, but it doesn't seem to be successful after a few hours. However, if you guys see this message posted twice, please forgive me. James image=wx.Image('output.tif',wxBITMAP_TYPE_TIF) #can't see, still black as the empty bitmap ???do some convertion here? Which function should be used, I couldn't find one. bmp = image.ConvertToBitmap() bmp.SetHeight(self.bmpHeight) bmp.SetWidth(self.bmpWidth) self.staticBitmap1.SetBitmap(bmp) #staticBitmap1 already defined/created before -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20051014/6b7c231b/attachment.html From andrea_gavana at tin.it Sun Oct 16 23:58:43 2005 From: andrea_gavana at tin.it (Andrea Gavana) Date: Sun, 16 Oct 2005 21:58:43 -0000 Subject: [Image-SIG] Help On Converting Colours... Message-ID: <00ab01c5d365$89e12b00$f1a20257@Gavana> Hello NG, I have a small image that looks like a GUI button (with 3D effects given by different pixels colours). The current image has as "basic" colour the grey. For "basic", I mean that the predominant colour in the image is grey and some other pixels are brighter or darker in order to give the 3D effect on that image. Now my question: is it possible to transform the pixels colours in order to have another basic colour (say blue)? In other words, the predominant colour will become the blue, with other pixels in a brighter or darker blue to give the same 3D effects. Thanks a lot for every suggestion, and sorry if it is a basic question. I just started to learn PIL. Andrea. P.S. I am trying also to use Numarray (Numeric) in order to do this transformation. Someone suggested me to use the function rgb_to_hsv on every pixel and then to change only the "hue" value, to obtain another colour for every pixel, in order to obtain the same 3D effect. I think I have found the way to do it, but doing that for every pixel is quite slow... is there a way to do it more "globally" (I mean on the whole image)? Or, as alternative, can I identify the pixels that share the same colour and then apply the transformation on all them? Thanks a lot for all your suggestions. Andrea. "Imagination Is The Only Weapon In The War Against Reality." http://xoomer.virgilio.it/infinity77 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20051016/0870ab03/attachment.htm From bobspoon at funnylab.co.kr Mon Oct 31 17:50:47 2005 From: bobspoon at funnylab.co.kr (=?ks_c_5601-1987?B?w9bBpL/t?=) Date: Tue, 1 Nov 2005 01:50:47 +0900 Subject: [Image-SIG] palette mode animated GIF doesn't show correctly when frame > 1 Message-ID: <000001c5de3b$3e2f4850$bb87fbcb@rok> Python 2.4 PIL 1.1.5 Hi, I want to show a gif animation which using indexed color model. I did like this: Import Image im = Image.open(?animation.gif?) try: im.show() # for debug.. Im.seek(im.tell()+1) except: pass when ?animation.gif? is in RGB mode, this code work as expected. But when the gif image is in indexed(palettized) color mode, it does not show correctly except first frame. I feel this may be caused by something like color shift or palette corruption .. Image is here: http://203.251.135.188/yoshin/animation.gif Best reguard, Choi Jung-uk -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20051101/fb44c732/attachment.html