From federo at email.si Mon Sep 1 15:48:40 2008 From: federo at email.si (Federo) Date: Mon, 01 Sep 2008 15:48:40 +0200 Subject: [Image-SIG] PyTesser: OCR is not triggered ... Message-ID: <20080901134841.EBAEE9B250@www1.email.si> Hi I am new in PyTesser. I have instolled PyTesser from http://code.google.com/p/pytesser/ and PIL from http://www.pythonware.com/products/pil/ PIL has exe for instalation. For PyTesser I simply unziped all files to c:\Python25\lib\side-packages Than I tried the following code: import Image, ImageGrab import pytesser # Taking ScreenShot im = ImageGrab.grab() # Konverzija image Formata - Ni nujno potrebna if im.mode=='RGBA': im=im.convert('RGB') # PyTesser funkcija izvede OCR print = image_to_string(im) I recived the following error: Traceback (most recent call last): File "", line 1, in File "C:\Python25\lib\site-packages\pytesser.py", line 31, in image_to_string call_tesseract(scratch_image_name, scratch_text_name_root) File "C:\Python25\lib\site-packages\pytesser.py", line 21, in call_tesseract proc = subprocess.Popen(args) File "C:\Python25\lib\subprocess.py", line 594, in __init__ errread, errwrite) File "C:\Python25\lib\subprocess.py", line 816, in _execute_child startupinfo) WindowsError: [Error 2] The system cannot find the file specified WHAT IS MISSING IN MY INSTALATION? Loking forward to your reply, Fedo ____________________ http://www.email.si/ From olau at iola.dk Mon Sep 1 18:26:36 2008 From: olau at iola.dk (Ole Laursen) Date: Mon, 1 Sep 2008 18:26:36 +0200 Subject: [Image-SIG] Bug in rotate with expand=True In-Reply-To: References: Message-ID: I hate to quote myself, but I just realized that I had to apply this patch again against a new server install. Did somebody look at my bug report from back in April? It's a one-line fix so it really shouldn't be too hard to review. :) Is this the wrong forum? Again, please keep the CC as I'm not subscribed to the list. On Fri, Apr 4, 2008 at 11:31 AM, Ole Laursen wrote: > Hi, > > Try this > > import Image, ImageDraw > > i = Image.new("RGBA", (100, 100), (255, 0, 0, 0)) > draw = ImageDraw.Draw(i) > draw.line([(0, 50), (100, 50)], fill=(255, 0, 0), width=3) > i.save("original.png") > > i.rotate(15, Image.BICUBIC, True).save("enlarged.png") > i.rotate(15, Image.BICUBIC, False).save("not-enlarged.png") > > Then take a look at "enlarged.png". Contrary to "not-enlarged.png", > it's not anti-aliased in spite of both having Image.BICUBIC set. I > believe this is a bug in rotate(). It appears to be a question of line > 1320 in Image.py > > return self.transform((w, h), AFFINE, matrix) > > missing the resample parameter > > return self.transform((w, h), AFFINE, matrix, resample) > > > (Please keep the CC as I'm not subscribed to the list.) > > -- > Ole Laursen > http://www.iola.dk/ -- Ole Laursen http://www.iola.dk/ From fredrik at pythonware.com Mon Sep 1 18:56:29 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 01 Sep 2008 18:56:29 +0200 Subject: [Image-SIG] Bug in rotate with expand=True In-Reply-To: References: Message-ID: Ole Laursen wrote: > I hate to quote myself, but I just realized that I had to apply this > patch again against a new server install. Did somebody look at my bug > report from back in April? there hasn't been a new release since april, but it's fixed in the trunk, and you're credited in the CHANGES file, so it'll definitely appear in the next release. From gareth at spacetaken.net Tue Sep 2 13:48:33 2008 From: gareth at spacetaken.net (Gareth) Date: Tue, 02 Sep 2008 12:48:33 +0100 Subject: [Image-SIG] is this a bug? Message-ID: <48BD2811.70509@spacetaken.net> I believe I have found a bug with PIL. It can be illustrated by the following code: from PIL import Image, ImageFile path = file = open(path, 'rb') p = ImageFile.Parser() p.feed(file.read()) img = p.close() file.close() img.thumbnail((380, 380), Image.ANTIALIAS) img.save() - this works fine it the path is not to a png but to a jpg or gif, but given that is points to a (valid) png it chucks the following error: Traceback (most recent call last): File "piltest.py", line 12, in img.save('C:/Documents and Settings/gareth0/Desktop/thumb.png') File "C:\Python25\Lib\site-packages\PIL\Image.py", line 1372, in save self.load() File "C:\Python25\Lib\site-packages\PIL\ImageFile.py", line 189, in load s = read(self.decodermaxblock) File "C:\Python25\Lib\site-packages\PIL\PngImagePlugin.py", line 365, in load_read return self.fp.read(bytes) File "C:\Python25\Lib\site-packages\PIL\ImageFile.py", line 300, in read data = self.data[pos:pos+bytes] TypeError: 'NoneType' object is unsubscriptable - i hope someone can help me out here, this has been driving me insane, thanks! From ashishbitsgoa at gmail.com Wed Sep 3 11:10:03 2008 From: ashishbitsgoa at gmail.com (Ashish Sethi) Date: Wed, 3 Sep 2008 14:40:03 +0530 Subject: [Image-SIG] Converting a binary file to ascii Message-ID: I have PPM-P6 image file which is in binary format .The file is of the type :- P6 128 128 255 ?????{??~??x??y??f??l??y??j??h??u??y??v??p???ub?^Y?f](c)g ..........and so on. How can i read the 4th line (binary) and convert it to an equivalent ascii string. I used the following method but couldn't get the desired result.. import binascii from binascii import b2a_uu infile=open("C:\\Documents and Settings\\Desktop\\lena.ppm") a=infile.readline() b=infile.readline() c=infile.readline() d=infile.readline() z=b2a_uu(d) print z This script gave me some random absurd data as output. Plz help From karsten.hiddemann at mathematik.uni-dortmund.de Wed Sep 3 11:09:11 2008 From: karsten.hiddemann at mathematik.uni-dortmund.de (Karsten Hiddemann) Date: Wed, 03 Sep 2008 11:09:11 +0200 Subject: [Image-SIG] Converting a binary file to ascii In-Reply-To: References: Message-ID: <48BE5437.8080805@mathematik.uni-dortmund.de> Ashish Sethi schrieb: > How can i read the 4th line (binary) and convert it to an equivalent > ascii string. [...] > > This script gave me some random absurd data as output. Have you tried using d=infile.read() to really read in *all* the remaining data from the file? From ned at nedbatchelder.com Wed Sep 3 13:27:43 2008 From: ned at nedbatchelder.com (Ned Batchelder) Date: Wed, 03 Sep 2008 07:27:43 -0400 Subject: [Image-SIG] Converting a binary file to ascii In-Reply-To: References: Message-ID: <48BE74AF.9000007@nedbatchelder.com> Since you are on Windows, you need to provide the "rb" mode to open, or it will convert newline characters in your file, which can trash your binary data. Also, I don't understand what b2a_uu does, but the docs say its input string should be at most 45 characters, so it doesn't seem like what you want. When you say "convert it to an equivalent ascii string", what do you mean? --Ned. http://nedbatchelder.com Ashish Sethi wrote: > I have PPM-P6 image file which is in binary format .The file is of the type :- > > P6 > 128 128 > 255 > ?????{??~??x??y??f??l??y??j??h??u??y??v??p???ub?^Y?f](c)g ..........and so on. > > How can i read the 4th line (binary) and convert it to an equivalent > ascii string. I used the following method but couldn't get the desired > result.. > > import binascii > from binascii import b2a_uu > infile=open("C:\\Documents and Settings\\Desktop\\lena.ppm") > a=infile.readline() > b=infile.readline() > c=infile.readline() > d=infile.readline() > z=b2a_uu(d) > print z > > This script gave me some random absurd data as output. > Plz help > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > -- Ned Batchelder, http://nedbatchelder.com From adeuring at gmx.net Wed Sep 3 15:52:02 2008 From: adeuring at gmx.net (abel deuring) Date: Wed, 03 Sep 2008 15:52:02 +0200 Subject: [Image-SIG] Converting a binary file to ascii In-Reply-To: References: Message-ID: <48BE9682.1080500@gmx.net> On 03.09.2008 11:10, Ashish Sethi wrote: > I have PPM-P6 image file which is in binary format .The file is of the type :- > > P6 > 128 128 > 255 > ?????{??~??x??y??f??l??y??j??h??u??y??v??p???ub?^Y?f](c)g ..........and so on. > > How can i read the 4th line (binary) and convert it to an equivalent > ascii string. I used the following method but couldn't get the desired > result.. Please define more precisely what you mean with "equivalent ascii string". Strictly speaking, b2a_uu produces an equivalent string in the sense that running a2b_uu gives you the original string back, but this is obviously not what you want. In other words, there is 1:1 mapping between arbitrary binary data and their "UU" representation. If you want to get the "P3" format: Use something like intvals = [ord(i) for i in d] (where d is the string with the binary image data read from the P6-format file) and create an ASCII representation for the elements of the list intvals. > > import binascii > from binascii import b2a_uu > infile=open("C:\\Documents and Settings\\Desktop\\lena.ppm") > a=infile.readline() > b=infile.readline() > c=infile.readline() > d=infile.readline() > z=b2a_uu(d) > print z > > This script gave me some random absurd data as output. As Ned already wrote, you should open the file in binary mode on Windows. And as Karsten wrote, you should use infile.read() to get the image data. readline() is not useful to read binary data: You will get the data up to the first byte with the value 10 (ASCII meaning: "line feed"), or perhaps for Windows up to the first byte with the value 13 (ASCII meaning "carriage return"). But these values have for P6 files a different "meaning", when they appear after the leading "255" line: They simply give the value of the red, blue or green component of a pixel. Abel From cannon.el at gmail.com Wed Sep 3 17:17:03 2008 From: cannon.el at gmail.com (Laura & Edward Cannon) Date: Wed, 3 Sep 2008 08:17:03 -0700 Subject: [Image-SIG] is this a bug? In-Reply-To: References: <48BD2811.70509@spacetaken.net> Message-ID: From: Laura & Edward Cannon Date: Wed, Sep 3, 2008 at 8:16 AM Subject: Re: [Image-SIG] is this a bug? To: Gareth I tried this out as well and got the same error. I agree this seems to be a bug, but in the short term try to get around it by using the Image.open() function. code would look like this import Image path = img = Image.open(path) img.thumbnail((380, 380), Image.ANTIALIAS) img.save() this is probably the preferred method when working with real files, the ImageFile is mostly for things sent over the network. It is possible you are also using a png with some interesting compression, the documentation states "If the file cannot be identified, the parser will raise an IOError exception in the close method. If the file can be identified, but not decoded (for example, if the data is damaged, or if it uses an unsupported compression method), the parser will raise an IOError exception as soon as possible, either in feed or close. " On Tue, Sep 2, 2008 at 4:48 AM, Gareth wrote: > > I believe I have found a bug with PIL. It can be illustrated by the following code: > > from PIL import Image, ImageFile > > path = > > file = open(path, 'rb') > p = ImageFile.Parser() > p.feed(file.read()) > img = p.close() > file.close() > > img.thumbnail((380, 380), Image.ANTIALIAS) > img.save() > > - this works fine it the path is not to a png but to a jpg or gif, but given that is points to a (valid) png it chucks the following error: > > Traceback (most recent call last): > File "piltest.py", line 12, in > img.save('C:/Documents and Settings/gareth0/Desktop/thumb.png') > File "C:\Python25\Lib\site-packages\PIL\Image.py", line 1372, in save > self.load() > File "C:\Python25\Lib\site-packages\PIL\ImageFile.py", line 189, in load > s = read(self.decodermaxblock) > File "C:\Python25\Lib\site-packages\PIL\PngImagePlugin.py", line 365, in load_read > return self.fp.read(bytes) > File "C:\Python25\Lib\site-packages\PIL\ImageFile.py", line 300, in read > data = self.data[pos:pos+bytes] > TypeError: 'NoneType' object is unsubscriptable > > - i hope someone can help me out here, this has been driving me insane, thanks! > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig From ashishbitsgoa at gmail.com Thu Sep 4 06:32:27 2008 From: ashishbitsgoa at gmail.com (Ashish Sethi) Date: Thu, 4 Sep 2008 10:02:27 +0530 Subject: [Image-SIG] Converting a binary file to ascii In-Reply-To: <48BE9682.1080500@gmx.net> References: <48BE9682.1080500@gmx.net> Message-ID: > Please define more precisely what you mean with "equivalent ascii > string". Strictly speaking, b2a_uu produces an equivalent string in the > sense that running a2b_uu gives you the original string back, but this > is obviously not what you want. In other words, there is 1:1 mapping > between arbitrary binary data and their "UU" representation. > > If you want to get the "P3" format: Use something like > > intvals = [ord(i) for i in d] Thanks all of you. Your suggestions solved my problem. From fredrik at pythonware.com Sat Sep 6 13:18:16 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 06 Sep 2008 13:18:16 +0200 Subject: [Image-SIG] is this a bug? In-Reply-To: <48BD2811.70509@spacetaken.net> References: <48BD2811.70509@spacetaken.net> Message-ID: Gareth wrote: > I believe I have found a bug with PIL. It can be illustrated by the > following code: > > from PIL import Image, ImageFile > > path = > > file = open(path, 'rb') > p = ImageFile.Parser() > p.feed(file.read()) > img = p.close() > file.close() > > img.thumbnail((380, 380), Image.ANTIALIAS) > img.save() > > - this works fine it the path is not to a png but to a jpg or gif, but > given that is points to a (valid) png it chucks the following error: > TypeError: 'NoneType' object is unsubscriptable sure looks like a bug to me. as a workaround, try changing the "except IOError:" line in this section of ImageFile.py # attempt to open this file try: try: fp = _ParserFile(self.data) im = Image.open(fp) finally: fp.close() # explicitly close the virtual file except IOError: # <-- this line pass # not enough data to except (IOError, TypeError): also, if you can, mail me a copy of the offending file (or post it somewhere and send me an URL) so I can investigate further. From david at flowgram.com Sat Sep 6 02:24:16 2008 From: david at flowgram.com (David Gobaud) Date: Fri, 5 Sep 2008 17:24:16 -0700 Subject: [Image-SIG] Image paste method resulting in garbage pixels in images Message-ID: <028c01c90fb6$e5fb83a0$fdfefe0a@stanford.edu> Hi, We are using PIL to render images. When we use the Image paste method to blend 2 RGBA image we end up with garbage pixels in the output as shown below. How can we fix this? Thank you, David Gobaud -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/jpeg Size: 24791 bytes Desc: not available URL: From fredrik at pythonware.com Sun Sep 7 11:12:23 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 07 Sep 2008 11:12:23 +0200 Subject: [Image-SIG] Image paste method resulting in garbage pixels in images In-Reply-To: <028c01c90fb6$e5fb83a0$fdfefe0a@stanford.edu> References: <028c01c90fb6$e5fb83a0$fdfefe0a@stanford.edu> Message-ID: David Gobaud wrote: > We are using PIL to render images. When we use the Image paste method to > blend 2 RGBA image we end up with garbage pixels in the output as shown > below. How can we fix this? can you send me the two image layers used to create that image? (or post them somewhere and mail me a link) From snaury at gmail.com Sun Sep 7 13:22:05 2008 From: snaury at gmail.com (Alexey Borzenkov) Date: Sun, 7 Sep 2008 15:22:05 +0400 Subject: [Image-SIG] Announcing my PIL repository Message-ID: Hello, fellow Image-SIG subscribers, PIL 1.1.6 has been released almost two years ago. And as some of you may remember, I have sent several patches to this list since then, but there hasn't been any reply to my emails from developers for some reason, and I don't even know if my patches are accepted or not, if they require any work, etc. Anyway, previously my PIL branch was part of a bigger repository that I couldn't open to everyone, but now I have found a way to split it into a separate repository (using bzr-svn), so everyone can look at it if they want to: svn://kitsu.ru/pil/trunk Many revisions wouldn't be of any interest to anybody (they just fiddle with setup scripts), but there are some features (I haven't sent to this list yet) that might be interesting to some of you who do raw image data processing and use Image.fromstring and Image.tostring heavily: - Add P;4R raw type, where high and low 4-bits are swapped. - Added RGB to RGBa dummy conversion, plus added BGR;15 and BGR;16 packing code. - Added a very simple RGBa->RGBA conversion And of course it includes all the patches I sent to this list. Binaries for Python 2.4 and Python 2.5 on Windows are also available: http://kitsu.ru/pil The are built using mingw (gcc 4.3.0) and are linked against jpeg-6b, tiff-3.8.2, freetype-2.3.7 and ActiveTcl 8.4.19.1. P.S. Please let me know if there is anything else missing. P.P.S. And I hope that PIL is not dead and we will see some releases in the future. Almost two years without any new release and without any public repository to watch for is very tough. :( From snaury at gmail.com Sun Sep 7 16:53:04 2008 From: snaury at gmail.com (Alexey Borzenkov) Date: Sun, 7 Sep 2008 18:53:04 +0400 Subject: [Image-SIG] Announcing my PIL repository In-Reply-To: <48C3DA28.9060304@users.sourceforge.net> References: <48C3DA28.9060304@users.sourceforge.net> Message-ID: On Sun, Sep 7, 2008 at 5:42 PM, Pander wrote: > Thanks for your work. Did you get any replies from the original authors? Well, It's just that nobody replied to my patch emails. They went to the list completely silently, and that felt a little bit odd. :-/ > Attached you will find a contribution from my side. I hope it can find > its way into PIL. Please review the code and report back any issues you > might encounter. I'm afraid you might have misunderstood me. I don't have anything to do with PythonWare or Secret Labs AB, so I absolutely can't decide what goes and what doesn't go into PIL. :-/ As for the review I see at least some problems with your code: 1) It's too specialized. I would recommend, if possible, splitting image generation and caching code into different functions, so that one returns unsaved images and the other checks file cache and in case of a cache-miss uses the first one and saves it on disk. 2) You hard-code text to be str in utf-8 encoding. Even worse, different functions expect different things (for example, getWidth[Height] expects a ascii/unicode string, but generateLabel expects utf-8 string), you even make the mistake of incorrectly calling them in your own code. Just make users call your functions with ascii/unicode strings and convert to unicode if you really need to, don't special-case on utf-8 or any other encoding. ~ Alexey From fredrik at pythonware.com Sun Sep 7 17:07:00 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 07 Sep 2008 17:07:00 +0200 Subject: [Image-SIG] Announcing my PIL repository In-Reply-To: References: Message-ID: Alexey Borzenkov wrote: > P.P.S. And I hope that PIL is not dead and we will see some releases > in the future. http://mail.python.org/pipermail/image-sig/2008-July/005101.html From agi20dla at gmail.com Mon Sep 8 01:12:45 2008 From: agi20dla at gmail.com (agi20dla) Date: Sun, 07 Sep 2008 19:12:45 -0400 Subject: [Image-SIG] IP Geolocation Message-ID: <48C45FED.1050806@gmail.com> I created an IP geolocation script with another popular scripting language using the Tiger/LINE database from the Census Bureau. Is there such a module for Python? I need to get street level IP Geo for at least USA addresses, but also for overseas addresses if possible. agi20dla From jwevandijk at xs4all.nl Mon Sep 8 16:17:41 2008 From: jwevandijk at xs4all.nl (Janwillem van Dijk) Date: Mon, 08 Sep 2008 16:17:41 +0200 Subject: [Image-SIG] Image.open problem Message-ID: <48C53405.7090805@xs4all.nl> It all worked nicely but after a re-install of my systems (linux pc, linux laptop, windows pc) I have a problem with Image.open(fname). Under linux (python2.5 ubuntu 8.04) I get: Traceback (most recent call last): File "/media/DATAWINDOWS/Python/SobelQuality/open_image.py", line 6, in image = Image.open(fname) File "/usr/lib/python2.5/site-packages/PIL/Image.py", line 1902, in open return factory(fp, filename) File "/usr/lib/python2.5/site-packages/PIL/ImageFile.py", line 82, in __init__ self._open() File "/usr/lib/python2.5/site-packages/PIL/JpegImagePlugin.py", line 270, in _open handler(self, i) File "/usr/lib/python2.5/site-packages/PIL/JpegImagePlugin.py", line 154, in DQT self.quantization[v&15] = array.array("b", s[1:65]) AttributeError: 'module' object has no attribute 'array' with this simple test script: #open test image import sys, os.path, time from PIL import Image t = time.time() fname = os.path.join(sys.path[0],'lena.jpg') image = Image.open(fname) print 'Open %s width,height %d,%d took %.3f sec' % \ (fname,image.size[0],image.size[1],time.time()-t) On windows XP it works as it should. What went wrong and how to get it running again many thanks, Janwillem From fredrik at pythonware.com Mon Sep 8 16:49:27 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon, 08 Sep 2008 16:49:27 +0200 Subject: [Image-SIG] Image.open problem In-Reply-To: <48C53405.7090805@xs4all.nl> References: <48C53405.7090805@xs4all.nl> Message-ID: Janwillem van Dijk wrote: > It all worked nicely but after a re-install of my systems (linux pc, > linux laptop, windows pc) I have a problem with Image.open(fname). Under > linux (python2.5 ubuntu 8.04) I get: > > Traceback (most recent call last): > File "/media/DATAWINDOWS/Python/SobelQuality/open_image.py", line 6, in > > image = Image.open(fname) > File "/usr/lib/python2.5/site-packages/PIL/Image.py", line 1902, in open > return factory(fp, filename) > File "/usr/lib/python2.5/site-packages/PIL/ImageFile.py", line 82, in > __init__ > self._open() > File "/usr/lib/python2.5/site-packages/PIL/JpegImagePlugin.py", line > 270, in _open > handler(self, i) > File "/usr/lib/python2.5/site-packages/PIL/JpegImagePlugin.py", line > 154, in DQT > self.quantization[v&15] = array.array("b", s[1:65]) > AttributeError: 'module' object has no attribute 'array' > > with this simple test script: > #open test image > import sys, os.path, time > from PIL import Image > t = time.time() > fname = os.path.join(sys.path[0],'lena.jpg') > image = Image.open(fname) > print 'Open %s width,height %d,%d took %.3f sec' % \ > (fname,image.size[0],image.size[1],time.time()-t) PIL's JPEG module attempts to load the standard library module called "array", but it looks as if "import array" fetches some other module. check your Python paths for things named "array.py" or similar. From cannon.el at gmail.com Mon Sep 8 20:04:00 2008 From: cannon.el at gmail.com (Laura & Edward Cannon) Date: Mon, 8 Sep 2008 11:04:00 -0700 Subject: [Image-SIG] IP Geolocation In-Reply-To: <48C45FED.1050806@gmail.com> References: <48C45FED.1050806@gmail.com> Message-ID: On Sun, Sep 7, 2008 at 4:12 PM, agi20dla wrote: > I created an IP geolocation script with another popular scripting > language using the Tiger/LINE database from the Census Bureau. Is there > such a module for Python? I need to get street level IP Geo for at > least USA addresses, but also for overseas addresses if possible. > > agi20dla > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > It sounds like you need a commercial solution, this kind of thing is not at all what PIL does, PIL is a general purpose image library. From snaury at gmail.com Mon Sep 8 20:54:50 2008 From: snaury at gmail.com (Alexey Borzenkov) Date: Mon, 8 Sep 2008 22:54:50 +0400 Subject: [Image-SIG] Announcing my PIL repository In-Reply-To: References: <48C3DA28.9060304@users.sourceforge.net> Message-ID: On Mon, Sep 8, 2008 at 5:28 PM, Kent Tenney wrote: >> Ah, I found what you are talking about. >> >> There is a patch by Lowell Alleman, who posted it to this list on 23 >> February 2007, and it's a pure-python patch. So, no, this was not my >> patch. :) > +1 to preserving PngInfo by default. Why would you want to do so by default? If you want to have text chunks (or any other chunks) you can use PngInfo yourself: pnginfo = PngInfo() pnginfo.add_text("blah", "some value") pnginfo.add_text("another", "some other value", zip=1) im.save("filename.png", pnginfo=pnginfo) Other than that text chunks are currently exposed via im_info dictionary, which cannot be used for generating tEXt chunks as it is (this dictionary has other keys that have nothing to do with text chunks, and any backwards compatible solution would have to either be guesswork, which is -1 by me, or a separate set/dictionary containing a set of keys that are text chunks, and maybe a flag whether it was tEXt or zTXt, which is not ideal either). In what situations do you find it useful so preserve text tags by default? From agi20dla at gmail.com Tue Sep 9 12:59:12 2008 From: agi20dla at gmail.com (Jason S) Date: Tue, 09 Sep 2008 06:59:12 -0400 Subject: [Image-SIG] IP Geolocation In-Reply-To: References: <48C45FED.1050806@gmail.com> Message-ID: <48C65700.8090905@gmail.com> Laura & Edward Cannon wrote: > On Sun, Sep 7, 2008 at 4:12 PM, agi20dla wrote: > >> I created an IP geolocation script with another popular scripting >> language using the Tiger/LINE database from the Census Bureau. Is there >> such a module for Python? I need to get street level IP Geo for at >> least USA addresses, but also for overseas addresses if possible. >> >> agi20dla >> _______________________________________________ >> Image-SIG maillist - Image-SIG at python.org >> http://mail.python.org/mailman/listinfo/image-sig >> >> > It sounds like you need a commercial solution, this kind of thing is > not at all what PIL does, PIL is a general purpose image library. > > I posted here because the Image SIG said this would provide "...an open forum for Python users interested in image handling and processing; anything from simply reading and writing image files to scientific image processing, *****geographical information***** systems, remote sensing, and more. " If that's not IP Geolocation, do you know of a SIG that can help me? The commercial solutions are not that good or are expensive. J From newz at bearfruit.org Tue Sep 9 16:08:30 2008 From: newz at bearfruit.org (Matthew Nuzum) Date: Tue, 9 Sep 2008 09:08:30 -0500 Subject: [Image-SIG] IP Geolocation In-Reply-To: <48C65700.8090905@gmail.com> References: <48C45FED.1050806@gmail.com> <48C65700.8090905@gmail.com> Message-ID: On Tue, Sep 9, 2008 at 5:59 AM, Jason S wrote: > Laura & Edward Cannon wrote: >> On Sun, Sep 7, 2008 at 4:12 PM, agi20dla wrote: >>> I created an IP geolocation script with another popular scripting >>> language using the Tiger/LINE database from the Census Bureau. Is there >>> such a module for Python? I need to get street level IP Geo for at >>> least USA addresses, but also for overseas addresses if possible. >>> >> It sounds like you need a commercial solution, this kind of thing is >> not at all what PIL does, PIL is a general purpose image library. > I posted here because the Image SIG said this would provide Well, let me just say this, having been listening on this list for quite a while there has not been much discussion on this (I can't remember any at least). Therefore if you're willing to be a bit of a pioneer this is probably a fine place to discuss it. I see two parts: 1. getting the geoip info out of the image 2. doing the lat/long to address lookup Part 1 is definitely on-topic, though I can be of little help. I don't see any reason why you'd have to pay for a tool to extract the data to do this (though sometimes that does help you get your task done more quickly). Regarding part 2, I've done address to lat/long lookup using google's apis but the reverse is not possible directly (though there is some community contributed tools for doing it, with limitations). However you may get more experienced and knowledgable answers on this last part in other forums. I've done my research in the context of Google maps and found some good information in their google group. Back to part 1, is this information stored in the exif header? Do you have a sample image you can post somewhere? -- Matthew Nuzum newz2000 on freenode From fredrik at pythonware.com Fri Sep 12 17:51:01 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 12 Sep 2008 17:51:01 +0200 Subject: [Image-SIG] pil sightings Message-ID: this definitely made my day: http://vanrees.org/weblog/archive/2008/09/12/python-calculated-coin excellent work, stani. and congrats for winning! (just wish I could figure out how to order one from here ;-) From Bob.Klepfer at dynetics.com Fri Sep 12 18:53:18 2008 From: Bob.Klepfer at dynetics.com (Klepfer, Bob) Date: Fri, 12 Sep 2008 11:53:18 -0500 Subject: [Image-SIG] pil sightings In-Reply-To: References: Message-ID: This is brilliant! Anyone from the list willing to arrange to mail one over the pond? Bob -- Bob Klepfer Research Analyst Dynetics, Inc. Huntsville, AL 35806 http://dynetics.com -----Original Message----- From: image-sig-bounces+bob.klepfer=dynetics.com at python.org [mailto:image-sig-bounces+bob.klepfer=dynetics.com at python.org] On Behalf Of Fredrik Lundh Sent: Friday, September 12, 2008 10:51 AM To: image-sig at python.org Subject: [Image-SIG] pil sightings this definitely made my day: http://vanrees.org/weblog/archive/2008/09/12/python-calculated-coin excellent work, stani. and congrats for winning! (just wish I could figure out how to order one from here ;-) _______________________________________________ Image-SIG maillist - Image-SIG at python.org http://mail.python.org/mailman/listinfo/image-sig From pricewhelan at mac.com Sat Sep 13 07:26:21 2008 From: pricewhelan at mac.com (Adrian Price-Whelan) Date: Sat, 13 Sep 2008 01:26:21 -0400 Subject: [Image-SIG] PIL Compile Error Mac 10.5.4 Message-ID: Hey - Having an issue building PIL on my intel Macbook Pro running 10.5.4.: ld: in /sw/lib/libxml2.2.dylib, file is not of required architecture for architecture ppc collect2: ld returned 1 exit status lipo: can't open input file: /var/folders/U8/U8oYQjnOFIi8el0mQQiHaU++ +TI/-Tmp-//ccZZXwfx.out (No such file or directory) error: command 'gcc' failed with exit status 1 Not quite sure whats going on with this...any help would be much appreciated. Thanks! -Adrian From spe.stani.be at gmail.com Sun Sep 14 22:56:25 2008 From: spe.stani.be at gmail.com (Stani) Date: Sun, 14 Sep 2008 22:56:25 +0200 Subject: [Image-SIG] pil sightings In-Reply-To: References: Message-ID: <1221425785.14933.44.camel@blue> Hi Fredrik, At the moment I am working hard with the Royal Dutch Mint to produce the coin. It is quite fascinating to see money making from the secret inside. When the stress is over, I might do a blog post about the whole experience and some higher resolution images, as the current ones are lacking details. The coin is for 90% made with python, PIL & pycairo. Some touches were done with Gimp & Inkscape. So no one should doubt any longer that you can make money with free software ;-) Fredrik, don't worry about ordering a coin, if you email me your postal address, I'll happily ship one to you. Most of my work as a visual artist is PIL powered, so I owe you that one ;-) Other people will be able to order it from the coinshop of the Royal Dutch Mint (link at bottom), but probably it will be sold out quite fast: http://en.knm.nl/domains/knm/pages/article.asp?content=11720000000909_999_11650000000011&navid=11650000000014_11650000000009 Best regards, Stani PS For the curious, the following link is the reason why I started learning PIL in 2002. It's a cross-over between 'The Birds' of Hitchcock and Vanitas paintings: http://88.191.26.71/maria/openlayers.html (Those of you familiar with Chernobyl might recognize the silhouet.) Op vrijdag 12-09-2008 om 17:51 uur [tijdzone +0200], schreef Fredrik Lundh: > this definitely made my day: > > http://vanrees.org/weblog/archive/2008/09/12/python-calculated-coin > > excellent work, stani. and congrats for winning! > > (just wish I could figure out how to order one from here ;-) > > > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig From gwidion at mpc.com.br Sun Sep 14 23:31:04 2008 From: gwidion at mpc.com.br (Joao S. O. Bueno) Date: Sun, 14 Sep 2008 18:31:04 -0300 Subject: [Image-SIG] pil sightings In-Reply-To: <1221425785.14933.44.camel@blue> References: <1221425785.14933.44.camel@blue> Message-ID: <200809141831.04844.gwidion@mpc.com.br> Hi Stani! Nice job!! :-) I had forwarded the news on the coin to the Brazillian python mailing list, and people got quite amused tehre as well. BTW, this week Brazilian's PyCon will take place, if you want I think could display some coin images/other data as a lightning talk on your behalf. Great to hear from you on this unsuspected way. :-) Since next years' LGM is being scheduled to take place in Amsterdam, I guess I will meet you there again. js -><- On Sunday 14 September 2008, Stani wrote: > Hi Fredrik, > > At the moment I am working hard with the Royal Dutch Mint to produce the > coin. It is quite fascinating to see money making from the secret > inside. > > When the stress is over, I might do a blog post about the whole > experience and some higher resolution images, as the current ones are > lacking details. The coin is for 90% made with python, PIL & pycairo. > Some touches were done with Gimp & Inkscape. So no one should doubt any > longer that you can make money with free software ;-) > > Fredrik, don't worry about ordering a coin, if you email me your postal > address, I'll happily ship one to you. Most of my work as a visual > artist is PIL powered, so I owe you that one ;-) > > Other people will be able to order it from the coinshop of the Royal > Dutch Mint (link at bottom), but probably it will be sold out quite > fast: > http://en.knm.nl/domains/knm/pages/article.asp?content=11720000000909_999_1 >1650000000011&navid=11650000000014_11650000000009 > > Best regards, > Stani > > PS For the curious, the following link is the reason why I started > learning PIL in 2002. It's a cross-over between 'The Birds' of Hitchcock > and Vanitas paintings: > > http://88.191.26.71/maria/openlayers.html > > (Those of you familiar with Chernobyl might recognize the silhouet.) > > Op vrijdag 12-09-2008 om 17:51 uur [tijdzone +0200], schreef Fredrik > > Lundh: > > this definitely made my day: > > > > http://vanrees.org/weblog/archive/2008/09/12/python-calculated-coin > > > > excellent work, stani. and congrats for winning! > > > > (just wish I could figure out how to order one from here ;-) > > > > > > > > _______________________________________________ > > Image-SIG maillist - Image-SIG at python.org > > http://mail.python.org/mailman/listinfo/image-sig > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig From oliver.siemoneit at philo.uni-stuttgart.de Fri Sep 12 18:30:53 2008 From: oliver.siemoneit at philo.uni-stuttgart.de (Oliver Siemoneit) Date: Fri, 12 Sep 2008 18:30:53 +0200 Subject: [Image-SIG] Image Correction For Colorblind Users Message-ID: <6B8DFA6E1AD34EA5994FB887040BDFB8@dusk> Hi, I have implemented two image correction algorithms which probably could make images more accessible for people with a color vision defeciency (see for some image samples and python code the zip archive attached). - One algorithm does an optimized color2gray transformation trying to preserve more details and thus overcoming the problems of normal color2gray transformation - Another algorithm does some image correction on colored images, something like the people on http://www.vischeck.com/daltonize/ do. Here my questions: 1.) Is this something for the PIL standard distribution, especially the color2gray algorithm? 2.) My problem is: Both algorithms are very slow. You can't use them really on a productive system (e.g. a server where all pictures which have been uploaded are automattically transformed). Is there a way to speed this up? Is there a way to do some C-Plugin for PIL (I think I cannot optimize the pyhton code anymore)? I need a fast and platform independent way to transform images with the above algorithms (since I try to get that in the Moin Wiki standard distribution, see http://moinmo.in/FeatureRequests/EnhanceTransclusionSyntaxForImages and http://moinmo.in/AccessibleMoin) I would be very happy if I could get some advice how to speed that up and/or how to integrate that with PIL. I am not an expert programmer. I'm at my wids' end. And sorry if this mail is a littel bit "off-topic" on this mailing list. But I had no idea whom to ask. Cheers, Oliver -------------- next part -------------- A non-text attachment was scrubbed... Name: ImageCorrection.zip Type: application/x-zip-compressed Size: 794625 bytes Desc: not available URL: From hpj at urpla.net Tue Sep 16 01:34:20 2008 From: hpj at urpla.net (Hans-Peter Jansen) Date: Tue, 16 Sep 2008 01:34:20 +0200 Subject: [Image-SIG] PIL 'special' edge detection problem Message-ID: <200809160134.21385.hpj@urpla.net> Dear PIL-Pythonistas, I'm trying to solve a problem with PIL which is basically related to edge detection, but please bear with me, since I'm pretty dump, when it comes to image processing apart from the very basics.. All the mess starts with a camera (Canon PowerShot 100 SX), that often creates erroneous images in certain twilight conditions. The ugliest failure is one, where parts of the image are wrapped, and color in that area is mixed up in some way. Hard to explain, here are some (resized) examples: ftp://urpla.net/cap00013.jpg ftp://urpla.net/cap00013-0.jpg ftp://urpla.net/cap00428.jpg Ugly, isn't it. While it would be best to exchange the camera with a model, that doesn't suffer from these problems, that is not an option at this point. Now, I try to detect these folds. My 'solution' misses any sophisticated image processing algorithm, I simply compare one pixel with the one below, convert it to HSV (with ranges: 0..255, 0..100, 0..100), combine h and v deviations into a value, and try to find horizontal runs of patterns with a high enough value. While the below code does it's job in some way, it's way too slow to be really useful, given the the original bitmap is 3264x2448 and that the camera is controlled by a small VIA C7 based system, which is unable to run this code even nearly fast enough :-(. Does some kind soul know some better way to solve my issue (propably python based). What I need is some special kind of horizontal edge detection, but where false positives are highly undesired. I know, that it should be possible with numpy, but maybe PIL filters may fit the job, too... Pointers to some comprehensible theory would also be great. Here's my code (note, that it won't work with the example images, since they are resized, and the thresholds doesn't match anymore). The full images are available in a subdir called fullres in the location above, as is the full script chkimage.py, but remember it's a test script, and it contains lots of unused stuff ATM.. def chkwrappedimage(self, ipixel, width, height, fname): xstep = 20 minvdev = 80 mincnt = 12 foldtres = 80000 def getpixel(x, y): rgb = ipixel[x, y] hsv = RGB2HSV(*rgb) return rgb, hsv def cmppixel(hsv1, hsv2): h1, h2 = hsv1[0], hsv2[0] h = abs(h2 - h1) if h > 180: h = 360 - h v = abs(hsv1[2] - hsv2[2]) return h + v def chkimgfold(x1, x2, xstep, y1, y2): foldd = {} for x in range(x1, x2, xstep): lastpix = None for y in range(y1, y2): rgb, hsv = getpixel(x, y) if lastpix != None: px1, py1, rgb1, hsv1 = lastpix px2, py2, rgb2, hsv2 = x, y, rgb, hsv if (py1, py2) in foldd: mx, lx, dv = foldd[(py1, py2)] if mx >= px2: lastpix = x, y, rgb, hsv continue else: lx, dv = 0, 0 v = cmppixel(hsv1, hsv2) if v >= minvdev: while v >= minvdev: px2 += 1 if px2 >= width: break px1 = px2 rgb1, hsv1 = getpixel(px1, py1) rgb2, hsv2 = getpixel(px2, py2) v = cmppixel(hsv1, hsv2) if v >= minvdev: dv += v n = px2 - x if n >= mincnt: foldd[(py1, py2)] = px2, lx + n, dv lastpix = x, y, rgb, hsv return foldd foldd = chkimgfold(0, width, xstep, 0, height) r = [] for k, d in foldd.items(): mx, lx, dv = d r.append((int(dv), k, lx)) r.sort(reverse = True) if r: dv, xy, lx = r[0] if dv >= foldtres: return 'wrappedimage: %s folded at %s: value: %s (lx: %s)' % ( fname, xy, dv, lx) Any hints/ideas to solve this issue in a sane way are highly appreciated. Thanks in advance, Pete From G.Kloss at massey.ac.nz Tue Sep 16 02:43:14 2008 From: G.Kloss at massey.ac.nz (Guy K. Kloss) Date: Tue, 16 Sep 2008 12:43:14 +1200 Subject: [Image-SIG] PIL 'special' edge detection problem In-Reply-To: <200809160134.21385.hpj@urpla.net> References: <200809160134.21385.hpj@urpla.net> Message-ID: <200809161243.18966.G.Kloss@massey.ac.nz> On Tue, 16 Sep 2008 11:34:20 am Hans-Peter Jansen wrote: > Any hints/ideas to solve this issue in a sane way are highly appreciated. You may try to give OpenCV with its HoughLines2 implementation. Have a look here: http://opencvlibrary.sourceforge.net/CvReference#cv_imgproc_special There are OpenCV bindings to Python, but not everything is exposed. But it may be worth a try as the implementation is done in native code and may work well for your problem. HTH, Guy -- Guy K. Kloss Institute of Information and Mathematical Sciences Te Kura Putaiao o Mohiohio me Pangarau 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://www.massey.ac.nz/~gkloss/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part. URL: From jcupitt at gmail.com Tue Sep 16 14:36:19 2008 From: jcupitt at gmail.com (jcupitt at gmail.com) Date: Tue, 16 Sep 2008 13:36:19 +0100 Subject: [Image-SIG] PIL 'special' edge detection problem In-Reply-To: <200809160134.21385.hpj@urpla.net> References: <200809160134.21385.hpj@urpla.net> Message-ID: <522c6460809160536yed03b3dj64b850e80ff8dcfa@mail.gmail.com> Hi, 2008/9/16 Hans-Peter Jansen : > Now, I try to detect these folds. My 'solution' misses any sophisticated > image processing algorithm, I simply compare one pixel with the one below, > convert it to HSV (with ranges: 0..255, 0..100, 0..100), combine h and v > deviations into a value, and try to find horizontal runs of patterns with a > high enough value. You can make this a lot quicker if you use image processing operations rather than looping yourself for each pixel. I don't actually know the PIL ones very well :-( but try something like: * go to a signed monochrome image You need to be able to handle negative values, and I don't think PIL can do RGB int. Anyway, colour won't be much help here. * subtract every pixel from the one below You can do this with a convolution. Just use a mask like 1 -1 And each pixel will become the difference between itself and the pixel below. Most of these values will be rather small, but if one of your folds is present, you'll see sudden large spikes. * take the absolute value Now you don't need negatives! * find the average value for each row You'd normally do this with a projection operator (sum every row and every column), I'm not sure if PIL has one of these. Shrinking the image to a single column should do the same job. * find peaks over a threshold Now loop down the image and look for values over a certain threshold, perhaps 50? John From pgretchanei at SorensonMedia.COM Thu Sep 18 17:58:27 2008 From: pgretchanei at SorensonMedia.COM (Petro Gretchanei) Date: Thu, 18 Sep 2008 09:58:27 -0600 Subject: [Image-SIG] PIL on intelMac Message-ID: <1DC630CD9B5A5E428B74071D3BB210915E086F@MediaMail.MEDIA.SORENSON.COM> Hello, i had a question if it was possible to use PIL on mac machines? If so, where can i get the installer? Thank you, Best regards, Petro Gretchanei Sorenson Media, Inc. Squeeze QA, Automation Engineer -------------- next part -------------- An HTML attachment was scrubbed... URL: From Chris.Barker at noaa.gov Fri Sep 19 02:32:44 2008 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Thu, 18 Sep 2008 17:32:44 -0700 Subject: [Image-SIG] PIL on intelMac In-Reply-To: <1DC630CD9B5A5E428B74071D3BB210915E086F@MediaMail.MEDIA.SORENSON.COM> References: <1DC630CD9B5A5E428B74071D3BB210915E086F@MediaMail.MEDIA.SORENSON.COM> Message-ID: <48D2F32C.40902@noaa.gov> Petro Gretchanei wrote: > Hello, > i had a question if it was possible to use PIL on mac machines? If so, > where can i get the installer? http://pythonmac.org/packages/py25-fat/index.html note: this works with the python.org Universal Framework build, not the one Apple supplies (though it can be made to work with that one with a kludge or two -- try googling) -Chris > Thank you, > > Best regards, > Petro Gretchanei > Sorenson Media, Inc. > Squeeze QA, Automation Engineer > > > ------------------------------------------------------------------------ > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig -- 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 From nikolai at netlife.no Fri Sep 19 13:27:33 2008 From: nikolai at netlife.no (Nikolai Ugelvik) Date: Fri, 19 Sep 2008 13:27:33 +0200 Subject: [Image-SIG] PIL - XVThumbImagePlugin infinite loop bugfix Message-ID: <48D38CA5.2010006@netlife.no> Hi. The PIL module XVThumbImagePlugin.py has an issue with XVThumb files that do not include #END_OF_COMMENTS (or a comment section at all). I'm not quite sure if the problem is an invalid file (is the comment required?), but we encountered a file like this. Anyway, the result is XVThumbImagePlugin being stuck in an infinite loop. The patch supports files without comments and/or comment sections without #END_OF_COMMENTS. Attached is a diff against XVThumbImagePlugin.py from PIL version 1.1.6. (I didn't figure out where else to send the diff.) -Nikolai -------------- next part -------------- A non-text attachment was scrubbed... Name: XVThumbImagePlugin.diff Type: text/x-diff Size: 789 bytes Desc: not available URL: From cannon.el at gmail.com Fri Sep 19 01:29:05 2008 From: cannon.el at gmail.com (Laura & Edward Cannon) Date: Thu, 18 Sep 2008 16:29:05 -0700 Subject: [Image-SIG] PIL on intelMac In-Reply-To: <1DC630CD9B5A5E428B74071D3BB210915E086F@MediaMail.MEDIA.SORENSON.COM> References: <1DC630CD9B5A5E428B74071D3BB210915E086F@MediaMail.MEDIA.SORENSON.COM> Message-ID: yes it is possible to do PIL on mac.try pythonmac.org 2008/9/18 Petro Gretchanei > Hello, > i had a question if it was possible to use PIL on mac machines? If so, > where can i get the installer? > > Thank you, > > Best regards, > Petro Gretchanei > Sorenson Media, Inc. > Squeeze QA, Automation Engineer > > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From oliver.siemoneit at philo.uni-stuttgart.de Fri Sep 19 23:43:12 2008 From: oliver.siemoneit at philo.uni-stuttgart.de (Oliver Siemoneit) Date: Fri, 19 Sep 2008 23:43:12 +0200 Subject: [Image-SIG] Image Correction For Colorblind Users Message-ID: <64475CE4B40348DC953DBC95C6411FD3@dusk> Hi, I have finally managed to do some C-extensions for the improved color2gray image transformation and the daltonize, see http://moinmo.in/FeatureRequests/EnhanceTransclusionSyntaxForImages for image samples and code. I owe this mainly to Kevin Cazabon, which has already done a very nice Gaussian blur and unsharpen filter for PIL, see http://mail.python.org/pipermail/image-sig/2008-May/005003.html . His code served as a basis for my own coding work This mail is also a reminder / request to consider making these things part of a future PIL release ;-) Oliver ----- Original Message ----- From: "Oliver Siemoneit" To: Sent: Friday, September 12, 2008 6:30 PM Subject: Image Correction For Colorblind Users > Hi, > > I have implemented two image correction algorithms which probably could > make > images more accessible for people with a color vision defeciency (see for > some image samples and python code the zip archive attached). > > - One algorithm does an optimized color2gray transformation trying to > preserve more details and thus overcoming the problems of normal > color2gray > transformation > > - Another algorithm does some image correction on colored images, > something > like the people on http://www.vischeck.com/daltonize/ do. > > Here my questions: > > 1.) Is this something for the PIL standard distribution, especially the > color2gray algorithm? > > 2.) My problem is: Both algorithms are very slow. You can't use them > really > on a productive system (e.g. a server where all pictures which have been > uploaded are automattically transformed). Is there a way to speed this up? > Is there a way to do some C-Plugin for PIL (I think I cannot optimize the > pyhton code anymore)? I need a fast and platform independent way to > transform images with the above algorithms (since I try to get that in the > Moin Wiki standard distribution, see > http://moinmo.in/FeatureRequests/EnhanceTransclusionSyntaxForImages and > http://moinmo.in/AccessibleMoin) > > I would be very happy if I could get some advice how to speed that up > and/or > how to integrate that with PIL. I am not an expert programmer. I'm at my > wids' end. > > And sorry if this mail is a littel bit "off-topic" on this mailing list. > But > I had no idea whom to ask. > > Cheers, > Oliver > > From post at yanone.de Wed Sep 24 13:46:37 2008 From: post at yanone.de (Yanone) Date: Wed, 24 Sep 2008 14:46:37 +0300 Subject: [Image-SIG] Aggdraw: curveto() Message-ID: hello everyone, it seems that this is a known problem: the curveto() function of aggdraw draws straight lines instead of curves, ignoring the given bezier control points. the last post i found about this dates back to march 2006, and even the developer version of aggdraw via svn didn't change this. if i could code in C i would have a look at it myself, but i'm helpless. could this somehow be solved? or is there any other way of drawing postscript curves into an image? the Path() method of reportlab's renderPM isn't implemented yet and i would like to refrain from generating a PDF file and the turn it into an image through imagemagick or something as i need this for a server implementation. many thanks and best regards, yanone From fredrik at pythonware.com Wed Sep 24 20:44:57 2008 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 24 Sep 2008 20:44:57 +0200 Subject: [Image-SIG] Aggdraw: curveto() In-Reply-To: References: Message-ID: Yanone wrote: > it seems that this is a known problem: the curveto() function of aggdraw > draws straight lines instead of curves, ignoring the given bezier > control points. the last post i found about this dates back to march > 2006, and even the developer version of aggdraw via svn didn't change this. > if i could code in C i would have a look at it myself, but i'm helpless. > > could this somehow be solved? here's a workaround, at least: replace the path_close implementation with the following: static PyObject* path_close(PathObject* self, PyObject* args) { if (!PyArg_ParseTuple(args, ":close")) return NULL; self->path->close_polygon(); /* expand curves */ agg::path_storage* path = self->path; agg::conv_curve curve(*path); self->path = new agg::path_storage(); self->path->add_path(curve, 0, false); delete path; Py_INCREF(Py_None); return Py_None; } (not sure this is the best way to fix this, but it should hopefully get you going) From gwidion at mpc.com.br Thu Sep 25 00:13:23 2008 From: gwidion at mpc.com.br (Joao S. O. Bueno) Date: Wed, 24 Sep 2008 19:13:23 -0300 Subject: [Image-SIG] Aggdraw: curveto() In-Reply-To: References: Message-ID: <200809241913.23786.gwidion@mpc.com.br> On Wednesday 24 September 2008, Yanone wrote: > hello everyone, > > it seems that this is a known problem: the curveto() function of > aggdraw draws straight lines instead of curves, ignoring the given > bezier control points. the last post i found about this dates back to > march 2006, and even the developer version of aggdraw via svn didn't > change this. > if i could code in C i would have a look at it myself, but i'm helpless. > > could this somehow be solved? > or is there any other way of drawing postscript curves into an image? > the Path() method of reportlab's renderPM isn't implemented yet and i > would like to refrain from generating a PDF file and the turn it into > an image through imagemagick or something as i need this for a server > implementation. > > many thanks and best regards, yanone Hi there - Sorry, i missed some of the context for this thread, so I don't? know what you have already tried - but you might try using the Cairo Library (and its python bingins, of course) It does implement postscript drawing operators and can render to many back-ends. js -><- From post at yanone.de Thu Sep 25 00:32:30 2008 From: post at yanone.de (Yanone) Date: Thu, 25 Sep 2008 01:32:30 +0300 Subject: [Image-SIG] Aggdraw: curveto() Message-ID: <93BD5F6E-17AC-4AD3-AB05-32328F5A37C8@yanone.de> thanks a lot, it worked. it draws the outlines upside down, which i guess is just due to a different corner of (0,0) of the two canvases (vector and PIL). in case this is the case, i'll work around it by simply turning all y coordinates. many thanks, yanone From starsareblueandfaraway at gmail.com Thu Sep 25 23:53:30 2008 From: starsareblueandfaraway at gmail.com (Roy H. Han) Date: Thu, 25 Sep 2008 17:53:30 -0400 Subject: [Image-SIG] How do I load and display a 16 bit grayscale image? Message-ID: <6a5569ec0809251453u3fd7930yfe6274c8b163f092@mail.gmail.com> Hi, I'm having some trouble displaying an image and I was wondering if someone here can help. Specifically, I loaded a 16 bit grayscale image using the fromstring() method with mode I;16. When I try to display the image, the entire image is white with some specks of black. I think it is because PIL thinks that it is a color image, but I'm not sure. Is there a way to tell PIL that the 16 bit image is actually grayscale? The details are that I am opening GeoTIFFs using GDAL and using PIL's fromstring() to see the resulting images. The multichromatic image seems to display fine when I view each band individually (PIL's merge doesn't seem to work for 16 bit images yet). However, the panchromatic image is washed out in white and I can't see anything. When I open the panchromatic image in qGIS, however, all the trees are plainly visible. Thanks, Roy -------------- next part -------------- An HTML attachment was scrubbed... URL: From szymon at mwg.pl Mon Sep 29 01:30:26 2008 From: szymon at mwg.pl (Szymon Kosok) Date: Mon, 29 Sep 2008 01:30:26 +0200 Subject: [Image-SIG] No "transparency" key in info for transparent PNG Message-ID: <199b51b30809281630o1abf9b56ubef76dd4c3a9720c@mail.gmail.com> Hello, I have transparent PNG (when I open it in Photoshop it's transparent) and when I try to open it with PIL there is no "transparency" key in info. I've tried another transparent PNG (famfamfam icon) and no luck with that too. What can cause that problem? Mode is "RGBA". Best regards, Szymon From cannon.el at gmail.com Mon Sep 29 04:07:47 2008 From: cannon.el at gmail.com (Laura & Edward Cannon) Date: Sun, 28 Sep 2008 19:07:47 -0700 Subject: [Image-SIG] No "transparency" key in info for transparent PNG In-Reply-To: <199b51b30809281630o1abf9b56ubef76dd4c3a9720c@mail.gmail.com> References: <199b51b30809281630o1abf9b56ubef76dd4c3a9720c@mail.gmail.com> Message-ID: As far as I can tell, you should be able to determine whether or not the image has transparency by looking at the mode. if it is RGBA or LA it has transparency, otherwise it does not. If you need to know what parts are transparent, look at the mask, obtained by im.split() On Sun, Sep 28, 2008 at 4:30 PM, Szymon Kosok wrote: > Hello, > > I have transparent PNG (when I open it in Photoshop it's transparent) > and when I try to open it with PIL there is no "transparency" key in > info. I've tried another transparent PNG (famfamfam icon) and no luck > with that too. What can cause that problem? Mode is "RGBA". > > Best regards, > Szymon > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig > From ustrum at gmail.com Mon Sep 29 09:42:36 2008 From: ustrum at gmail.com (Pablo Martin Rodriguez) Date: Mon, 29 Sep 2008 09:42:36 +0200 Subject: [Image-SIG] Splines Message-ID: Hi all I need to draw splines and I don't know how to do it using PIL. The only idea that I have had is to calculate all the points in the spline, given by the user a couple of points, and then draw them with the ImageDraw.point, but it doesn't seem to be a very good option. Any idea?? Maybe using another library is better than using PIL?? I'm sure that somebody has had to draw splines using python before, but I've found nothing when searching in google. Thanks a million! -------------- next part -------------- An HTML attachment was scrubbed... URL: From Chris.Barker at noaa.gov Tue Sep 30 06:50:51 2008 From: Chris.Barker at noaa.gov (Christopher Barker) Date: Mon, 29 Sep 2008 21:50:51 -0700 Subject: [Image-SIG] Splines In-Reply-To: References: Message-ID: <48E1B02B.30700@noaa.gov> Pablo Martin Rodriguez wrote: > I need to draw splines and I don't know how to do it using PIL. http://effbot.org/zone/pythondoc-aggdraw.htm You want to use a Path object, and the curveto() method. -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