From cameron.walsh at gmail.com Fri Dec 1 02:30:58 2006 From: cameron.walsh at gmail.com (Cameron Walsh) Date: Fri, 1 Dec 2006 09:30:58 +0800 Subject: [Image-SIG] PIL throws exception when reading 8bit greyscale bitmap and pnm data In-Reply-To: <106309950611291800l19f38fd7s77001d6ff71e62c@mail.gmail.com> References: <106309950611291800l19f38fd7s77001d6ff71e62c@mail.gmail.com> Message-ID: <106309950611301730w305edb53u817551d05dce2845@mail.gmail.com> On 30/11/06, Cameron Walsh wrote: > Hi all, > > I'm trying to extract the data from a bitmap or .pnm file using the > following code: > > import Image > img = Image.open("test.bmp","r") > data=img.getdata() > > Unfortunately I get the following exception on Linux, but not on Windows: > > >>> data=img.getdata() > Traceback (most recent call last): > File "", line 1, in > File "/usr/local/lib/python2.5/site-packages/PIL/Image.py", line 796, > in getdata > self.load() > File "/usr/local/lib/python2.5/site-packages/PIL/ImageFile.py", line > 147, in load > self.map = mmap.mmap(file.fileno(), size) > EnvironmentError: [Errno 19] No such device > > > At this time, I cannot provide the full bitmap for copyright reasons, > but I can provide some information about the bitmap: > > cameron at cameron-laptop:~$ file test.bmp > test.bmp: PC bitmap data, Windows 3.x format, 1000 x 1000 x 8 > > The same code works for .ppm images in the same folder: > > cameron at cameron-laptop:~$ convert test.bmp test.ppm > cameron at cameron-laptop:~$ python > import Image > img=Image.open("test.ppm") > data=img.getdata() > > But does not work for .pnm images in the same folder: > > cameron at cameron-laptop:~$ convert test.bmp test.pnm > cameron at cameron-laptop:~$ python > import Image > img=Image.open("test.pnm") > data=img.getdata() > Traceback (most recent call last): > File "", line 1, in > File "/usr/local/lib/python2.5/site-packages/PIL/Image.py", line 796, > in getdata > self.load() > File "/usr/local/lib/python2.5/site-packages/PIL/ImageFile.py", line > 147, in load > self.map = mmap.mmap(file.fileno(), size) > EnvironmentError: [Errno 19] No such device > > > > > PIL Version on Linux and Windows: > > $Id: Image.py 2337 2005-03-25 07:50:30Z fredrik $ > > > How can I avoid this error without converting each image into a > different format? Is there any more information required? > > > Thanks and regards, > > Cameron. > Hi all, It turns out the error only arose when reading the file from an ntfs-3g mounted drive in Linux. If I copied the file to my home directory it worked as expected. Regards, Cameron. From ronald at ivec.org Fri Dec 1 05:09:48 2006 From: ronald at ivec.org (Ronald Jones) Date: Fri, 01 Dec 2006 12:09:48 +0800 Subject: [Image-SIG] PIL - tiff : idfs and data types - offer of assistance In-Reply-To: References: Message-ID: <1164946188.4590.41.camel@sambucca.ivec.org> Hello all, I am also offering implement fixes in the tiffImagePlugin for handling IDFs that are contained within the primary IDF. I submitted a patch to handle more data types before so I can help with that also if necessary. Ronald > > -------- Forwarded Message -------- > > From: Zachary Pincus > > To: image-sig at python.org > > Subject: [Image-SIG] PIL and 16-bit image types -- an offer of help > > Date: Wed, 29 Nov 2006 18:51:50 -0800 > > > > Hello folks, > > > > SUMMARY: > > I am offering to implement fixes in PIL to make its handling of 16- > > bit image types less vexing. Are the PIL maintainers interested in > > such help? I have a few questions to ask, and then I could get to > > work if some maintainer would give me a preliminary go-ahead. -- Ronald Jones iVEC, 'The hub of advanced computing in Western Australia' 26 Dick Perry Avenue, Technology Park Kensington WA 6151 Australia Phone: +61 8 6436 8633 Fax: +61 8 6436 8555 Email: ronald.jones at ivec.org WWW: http://www.ivec.org From zpincus at stanford.edu Fri Dec 1 19:00:22 2006 From: zpincus at stanford.edu (Zachary Pincus) Date: Fri, 1 Dec 2006 10:00:22 -0800 Subject: [Image-SIG] PIL - tiff : idfs and data types - offer of assistance In-Reply-To: <1164946188.4590.41.camel@sambucca.ivec.org> References: <1164946188.4590.41.camel@sambucca.ivec.org> Message-ID: <2E641EFC-F589-46B1-A308-FA7F981CE52A@stanford.edu> Cool. I'm going to start working on my proposed changes, though I haven't heard anything from the main developers. (If need be I'll just fork PIL for my project.) I'll let you know if I have any questions! Thanks, Zach On Nov 30, 2006, at 8:09 PM, Ronald Jones wrote: > Hello all, > > I am also offering implement fixes in the tiffImagePlugin for handling > IDFs that are contained within the primary IDF. I submitted a > patch to > handle more data types before so I can help with that also if > necessary. > > Ronald > > >>> -------- Forwarded Message -------- >>> From: Zachary Pincus >>> To: image-sig at python.org >>> Subject: [Image-SIG] PIL and 16-bit image types -- an offer of help >>> Date: Wed, 29 Nov 2006 18:51:50 -0800 >>> >>> Hello folks, >>> >>> SUMMARY: >>> I am offering to implement fixes in PIL to make its handling of 16- >>> bit image types less vexing. Are the PIL maintainers interested in >>> such help? I have a few questions to ask, and then I could get to >>> work if some maintainer would give me a preliminary go-ahead. > > -- > Ronald Jones > iVEC, 'The hub of advanced computing in Western Australia' > 26 Dick Perry Avenue, Technology Park > Kensington WA 6151 > Australia > > Phone: +61 8 6436 8633 > Fax: +61 8 6436 8555 > Email: ronald.jones at ivec.org > WWW: http://www.ivec.org > > _______________________________________________ > Image-SIG maillist - Image-SIG at python.org > http://mail.python.org/mailman/listinfo/image-sig From fredrik at pythonware.com Sat Dec 2 13:03:12 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 02 Dec 2006 13:03:12 +0100 Subject: [Image-SIG] PIL throws exception when reading 8bit greyscale bitmap and pnm data In-Reply-To: <106309950611291800l19f38fd7s77001d6ff71e62c@mail.gmail.com> References: <106309950611291800l19f38fd7s77001d6ff71e62c@mail.gmail.com> Message-ID: Cameron Walsh wrote: > But does not work for .pnm images in the same folder: > > cameron at cameron-laptop:~$ convert test.bmp test.pnm > cameron at cameron-laptop:~$ python > import Image > img=Image.open("test.pnm") > data=img.getdata() > Traceback (most recent call last): > File "", line 1, in > File "/usr/local/lib/python2.5/site-packages/PIL/Image.py", line 796, > in getdata > self.load() > File "/usr/local/lib/python2.5/site-packages/PIL/ImageFile.py", line > 147, in load > self.map = mmap.mmap(file.fileno(), size) > EnvironmentError: [Errno 19] No such device can you try changing the except clause around line 153 from except (AttributeError, IOError, ImportError): to except (AttributeError, EnvironmentError, ImportError): and see if it solves the problem. From fredrik at pythonware.com Sat Dec 2 15:35:38 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 02 Dec 2006 15:35:38 +0100 Subject: [Image-SIG] PIL throws exception when reading 8bit greyscale bitmap and pnm data In-Reply-To: References: <106309950611291800l19f38fd7s77001d6ff71e62c@mail.gmail.com> Message-ID: Fredrik Lundh wrote: > can you try changing the except clause around line 153 from here's an "official" patch: Index: PIL/ImageFile.py =================================================================== --- PIL/ImageFile.py (revision 2929) +++ PIL/ImageFile.py (working copy) @@ -149,7 +149,7 @@ self.map, self.size, d, e, o, a ) readonly = 1 - except (AttributeError, IOError, ImportError): + except (AttributeError, EnvironmentError, ImportError): self.map = None self.load_prepare() From fredrik at pythonware.com Sun Dec 3 14:18:12 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 03 Dec 2006 14:18:12 +0100 Subject: [Image-SIG] ANN: PIL 1.1.6 final (december 3, 2006) Message-ID: PIL 1.1.6 final is now available from: http://effbot.org/downloads/#Imaging (source) http://effbot.org/downloads/#PIL (windows binaries) PIL 1.1.6 supports all Python versions from 1.5.2 and onwards, up to and including Python 2.5. Development of the 1.1.X line will now switch to maintenance mode, and future main releases will most likely require Python 2.3 or later. Anyway, for a hopefully complete list of changes in this release, see: http://effbot.org/zone/pil-changes-116.htm Report bugs to this list. enjoy! /F "Secret Labs -- makers of fine pythonware since 1997." From fredrik at pythonware.com Sun Dec 3 17:27:27 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 03 Dec 2006 17:27:27 +0100 Subject: [Image-SIG] GIF89a for PIL1.1.6? In-Reply-To: <780363.11603.qm@web34506.mail.mud.yahoo.com> References: <780363.11603.qm@web34506.mail.mud.yahoo.com> Message-ID: Hart's Antler wrote: > just wanted to say more complete animated GIF support > for PIL would be a great thing patches are welcome. traditionally, the GIF crowd has only been able to produce abuse, though, so most about everything else has higher priority when it comes to my spare time. From zpincus at stanford.edu Sun Dec 3 18:15:20 2006 From: zpincus at stanford.edu (Zachary Pincus) Date: Sun, 3 Dec 2006 09:15:20 -0800 Subject: [Image-SIG] ANN: PIL 1.1.6 final (december 3, 2006) In-Reply-To: References: Message-ID: <19C9864B-9467-4BFE-9FBB-F686F07CAF5F@stanford.edu> > Report bugs to this list. - A week or so ago, I reported that PIL loads multi-byte (e.g. 16- and 32-bit raster data) TIFF files incorrectly if the files were written as big-endian. (I also and provided a test case and patch.) Now, I just discovered a minor problem in my patch relating to 32-bit images, so I will send a new one in a few hours. This problem has been in PIL for some time, and has basically disqualified it for use in scientific imaging (which uses 16-bit data all of the time). I'd love to get that changed. - There is a buffer-overflow problem in 'struct ImagingMemoryInstance' defined in 'Imaging.h'. Specifically, this struct has a field defined as follows: char mode[4+1]; /* Band names ("1", "L", "P", "RGB", "RGBA", "CMYK") */ However, mode strings with more than 4 characters are copied into this buffer via strcpy, clobbering other data fields in the struct. I will provide a patch that makes the buffer large enough to hold all mode strings that might be used, and changes the strcpy calls to a strncpy. This patch also I will try to provide in a few hours. - The 'fromarray' command is a bit broken in Image.py: Specifically, the following stanza is incorrect -- if mode is None: typestr = arr['typestr'] if not (typestr[0] == '|' or typestr[0] == _ENDIAN or typestr[1:] not in ['u1', 'b1', 'i4', 'f4']): raise TypeError("cannot handle data-type") typestr = typestr[:2] if typestr == 'i4': ... The error is that 'typestr = typestr[:2]' should instead be 'typestr = typestr[1:]' - Also, the to/from array commands don't handle 16-bit images, though it could be accomplished easily. I will provide a patch for this too. - I still think that the handling of 16-bit images itself represents a major bug (see my previous email to the list, but in short, having to deal with big/little endian issues at the high-level API for 16- bit images but no other image types is a bug and causes other bugs in the code). I've been working on a patch to fix this, as described in that earlier email. Probably this patch is too big a change to apply to this release, but I would REALLY like to talk to someone about the chances for 1.7 (or whatever) accepting changes that make 16-bit image handling less vexing. Thanks, Zach Pincus Program in Biomedical Informatics and Department of Biochemistry Stanford University School of Medicine From steve at arachnedesign.net Sun Dec 3 18:36:03 2006 From: steve at arachnedesign.net (Steve Lianoglou) Date: Sun, 3 Dec 2006 12:36:03 -0500 Subject: [Image-SIG] ANN: PIL 1.1.6 final (december 3, 2006) In-Reply-To: References: Message-ID: <39FE776B-11FE-488B-B5B0-DB84FAE89421@arachnedesign.net> Hi, > PIL 1.1.6 final is now available from: > > http://effbot.org/downloads/#Imaging (source) > http://effbot.org/downloads/#PIL (windows binaries) Congrats on the new release ... one question/comment: A few weeks back I was having problems "painting images" pixel by pixel ... it was coming out very poorly running PIL using OS X. You found the problem, however, in PIL/Image.py ~ line 2061: elif sys.platform == "darwin": format = "JPEG" if not command: command = "open -a /Applications/Preview.app" changing JPEG to PNG turned out to solve the problem and the images were being rendered as expected. I just d/led the 1.1.6 and realized that it still defaults to JPEG instead of PNG and was wondering if this was an oversight or not (I'm changing mine back to PNG, though :-). -steve From fredrik at pythonware.com Sun Dec 3 19:08:13 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 03 Dec 2006 19:08:13 +0100 Subject: [Image-SIG] ANN: PIL 1.1.6 final (december 3, 2006) In-Reply-To: <19C9864B-9467-4BFE-9FBB-F686F07CAF5F@stanford.edu> References: <19C9864B-9467-4BFE-9FBB-F686F07CAF5F@stanford.edu> Message-ID: Zachary Pincus wrote: > - A week or so ago, I reported that PIL loads multi-byte (e.g. 16- > and 32-bit raster data) TIFF files incorrectly if the files were > written as big-endian. (I also and provided a test case and patch.) I noticed the post, but haven't had time to look at it; given my current schedule, it's been hard enough to get 1.1.6 out of the door (and in case you wonder, the 1.1.6 feature set has been frozen for quite some time; the last beta was basically a release candidate). > - There is a buffer-overflow problem in 'struct > ImagingMemoryInstance' defined in 'Imaging.h'. Specifically, this > struct has a field defined as follows: > char mode[4+1]; /* Band names ("1", "L", "P", "RGB", "RGBA", > "CMYK") */ > However, mode strings with more than 4 characters are copied into > this buffer via strcpy, clobbering other data fields in the struct. I > will provide a patch that makes the buffer large enough to hold all > mode strings that might be used, and changes the strcpy calls to a > strncpy. This patch also I will try to provide in a few hours. that's a known minor issue, and the struct is intentionally left as is for compatibility reasons (see the mailing list archives for details). this will be fixed in 1.2, where the internal storage model. > - The 'fromarray' command is a bit broken in Image.py: > Specifically, the following stanza is incorrect -- > if mode is None: > typestr = arr['typestr'] > if not (typestr[0] == '|' or typestr[0] == _ENDIAN or > typestr[1:] not in ['u1', 'b1', 'i4', 'f4']): > raise TypeError("cannot handle data-type") > typestr = typestr[:2] > if typestr == 'i4': > ... > > The error is that 'typestr = typestr[:2]' should instead be 'typestr > = typestr[1:]' that code was contributed by the numpy developers, but it sure looks broken. hmm. > - Also, the to/from array commands don't handle 16-bit images, though > it could be accomplished easily. I will provide a patch for this too. > > - I still think that the handling of 16-bit images itself represents > a major bug (see my previous email to the list, but in short, having > to deal with big/little endian issues at the high-level API for 16- > bit images but no other image types is a bug and causes other bugs in > the code). as you might have noticed, the I16 support is only documented in the CHANGES file, where it is labeled as experimental and incomplete; most of it is based on contributed code from a small number of projects that rely on "zero copy" access to underlying data. under PIL 1.2's storage model, all I;16 images will most likely always look like "I" images for ordinary users; if you need to get at the "raw" data, you'd need to explicitly specify that when opening/loading the image. as for the 1.1 branch, we'd like to keep it relatively stable, but "low-hanging fruit" patches are of course still welcome (and nothing prevents us from doing a 1.1.7 maintenance release). From fredrik at pythonware.com Sun Dec 3 20:19:02 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 03 Dec 2006 20:19:02 +0100 Subject: [Image-SIG] ANN: PIL 1.1.6 final (december 3, 2006) In-Reply-To: <39FE776B-11FE-488B-B5B0-DB84FAE89421@arachnedesign.net> References: <39FE776B-11FE-488B-B5B0-DB84FAE89421@arachnedesign.net> Message-ID: Steve Lianoglou wrote: > I just d/led the 1.1.6 and realized that it still defaults to JPEG > instead of PNG and was wondering if this was an oversight or not (I'm > changing mine back to PNG, though :-). it's a damned-if-change-it-damned-if-you-don't issue ;-), and was too late for 1.1.6 anyway. hopefully, 1.2 will provide more flexible image display facilities. From lists.steve at arachnedesign.net Sun Dec 3 20:53:11 2006 From: lists.steve at arachnedesign.net (Steve Lianoglou) Date: Sun, 3 Dec 2006 14:53:11 -0500 Subject: [Image-SIG] ANN: PIL 1.1.6 final (december 3, 2006) In-Reply-To: References: <39FE776B-11FE-488B-B5B0-DB84FAE89421@arachnedesign.net> Message-ID: <2109E4E7-EBDA-402B-B931-5233B704BF54@arachnedesign.net> > Steve Lianoglou wrote: > >> I just d/led the 1.1.6 and realized that it still defaults to JPEG >> instead of PNG and was wondering if this was an oversight or not (I'm >> changing mine back to PNG, though :-). > > it's a damned-if-change-it-damned-if-you-don't issue ;-), and was too > late for 1.1.6 anyway. hopefully, 1.2 will provide more flexible > image > display facilities. Completely understandable ... Just out of curiosity, and so I know what to keep my eyes open for since I changed it to PNG in my compile, what puts it in the "damned - if-you-do" scenario? Is there something I should expect to get hosed? Thanks, -steve From fredrik at pythonware.com Sun Dec 3 22:22:39 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 03 Dec 2006 22:22:39 +0100 Subject: [Image-SIG] ANN: PIL 1.1.6 final (december 3, 2006) In-Reply-To: <2109E4E7-EBDA-402B-B931-5233B704BF54@arachnedesign.net> References: <39FE776B-11FE-488B-B5B0-DB84FAE89421@arachnedesign.net> <2109E4E7-EBDA-402B-B931-5233B704BF54@arachnedesign.net> Message-ID: Steve Lianoglou wrote: > Just out of curiosity, and so I know what to keep my eyes open for > since I changed it to PNG in my compile, what puts it in the "damned - > if-you-do" scenario? Is there something I should expect to get hosed? performance, mostly. doing lossless compression is a lot more costly than doing lossy compression, or not doing compression at all. From zpincus at stanford.edu Mon Dec 4 02:13:59 2006 From: zpincus at stanford.edu (Zachary Pincus) Date: Sun, 3 Dec 2006 17:13:59 -0800 Subject: [Image-SIG] ANN: PIL 1.1.6 final (december 3, 2006) In-Reply-To: References: <19C9864B-9467-4BFE-9FBB-F686F07CAF5F@stanford.edu> Message-ID: <66F69359-1371-41C1-BC22-02D2DDD32BD7@stanford.edu> Thanks for the information, Fredrik. >> - A week or so ago, I reported that PIL loads multi-byte (e.g. 16- >> and 32-bit raster data) TIFF files incorrectly if the files were >> written as big-endian. (I also and provided a test case and patch.) > > I noticed the post, but haven't had time to look at it; given my > current > schedule, it's been hard enough to get 1.1.6 out of the door (and in > case you wonder, the 1.1.6 feature set has been frozen for quite some > time; the last beta was basically a release candidate). No problem. I'll try to provide a minimally-invasive patch to address this issue (it's really simple to do -- the code just needs to pass the correct byte order to Unpack.c, so hopefully this will count as 'low-hanging fruit'). >> - There is a buffer-overflow problem in 'struct >> ImagingMemoryInstance' >> ... > that's a known minor issue, and the struct is intentionally left as is > for compatibility reasons (see the mailing list archives for details). > this will be fixed in 1.2, where the internal storage model. Thanks for the info. I'm glad to hear about the upcoming changes for 1.2, and would be happy to help with some of that if I can... >> - The 'fromarray' command is a bit broken in Image.py: >> ... > that code was contributed by the numpy developers, but it sure looks > broken. hmm. I'll also try to provide a minimally-invasive patch here too. >> - Also, the to/from array commands don't handle 16-bit images, though >> it could be accomplished easily. I will provide a patch for this too. Does this count as low-hanging? I'd be happy to send a patch if it would be useful; otherwise I'll just put it into my code where it interfaces with PIL. > under PIL 1.2's storage model, all I;16 images will most likely always > look like "I" images for ordinary users; if you need to get at the > "raw" > data, you'd need to explicitly specify that when opening/loading > the image. Great -- I'm looking forward to 1.2! Thanks again, Zach From zpincus at stanford.edu Tue Dec 5 02:33:12 2006 From: zpincus at stanford.edu (Zachary Pincus) Date: Mon, 4 Dec 2006 17:33:12 -0800 Subject: [Image-SIG] ANN: PIL 1.1.6 final (december 3, 2006) In-Reply-To: <66F69359-1371-41C1-BC22-02D2DDD32BD7@stanford.edu> References: <19C9864B-9467-4BFE-9FBB-F686F07CAF5F@stanford.edu> <66F69359-1371-41C1-BC22-02D2DDD32BD7@stanford.edu> Message-ID: Hello all, >>> - A week or so ago, I reported that PIL loads multi-byte (e.g. 16- >>> and 32-bit raster data) TIFF files incorrectly if the files were >>> written as big-endian. (I also and provided a test case and patch.) >> >> I noticed the post, but haven't had time to look at it; given my >> current >> schedule, it's been hard enough to get 1.1.6 out of the door (and in >> case you wonder, the 1.1.6 feature set has been frozen for quite some >> time; the last beta was basically a release candidate). > > No problem. I'll try to provide a minimally-invasive patch to address > this issue (it's really simple to do -- the code just needs to pass > the correct byte order to Unpack.c, so hopefully this will count as > 'low-hanging fruit'). Here is a simple patch to make PIL read TIFFs in big-endian format with multibyte pixels properly. The changes are that the 'pack' and 'unpack' raw modes are now keyed to the byte order in the TIFF file, which they were not in the past. I also removed attempts to read and write TIFFs with signed 16-bit integer pixels into 'I;16S' files, because Unpack.c and Pack.c don't have any way to convert rawmode 'I;16S' files to/from user-mode 'I; 16S'. Now these files are properly read in as 'I'-mode files. Will this patch make it into a maintenance release 1.1.7? I'd like to know whether I should keep a fork of PIL until 1.2 comes out, so that people in my lab and others can read image from our microscopes into and out of python/numpy. Zach -------------- next part -------------- A non-text attachment was scrubbed... Name: tiff-endian2.patch Type: application/octet-stream Size: 8288 bytes Desc: not available Url : http://mail.python.org/pipermail/image-sig/attachments/20061204/2d8677bf/attachment.obj From cameron.walsh at gmail.com Sun Dec 3 13:34:20 2006 From: cameron.walsh at gmail.com (Cameron Walsh) Date: Sun, 03 Dec 2006 20:34:20 +0800 Subject: [Image-SIG] PIL throws exception when reading 8bit greyscale bitmap and pnm data In-Reply-To: References: <106309950611291800l19f38fd7s77001d6ff71e62c@mail.gmail.com> Message-ID: <4572C44C.1070007@gmail.com> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20061203/a8e5c58d/attachment.html From Axel.Kowald at rub.de Wed Dec 6 14:35:08 2006 From: Axel.Kowald at rub.de (Axel Kowald) Date: Wed, 06 Dec 2006 14:35:08 +0100 Subject: [Image-SIG] ImageCrackCode Module (finding image in image) ?? Message-ID: <4576C70C.30205@rub.de> Hi everybody, I like to do some image processing using Python and so I found PIL. I need to find the position of a small image in a larger image and looking through the docs it seems that CrackCode in the ImageCrackCode Module could do it. However, I read that this was part of PIL Plus which is no longer available :-( So how can I find the position of a subimage in a larger image using PIL ?? Many thanks, Alex From stef.henry at gmail.com Thu Dec 7 18:11:07 2006 From: stef.henry at gmail.com (Stephane Henry) Date: Thu, 7 Dec 2006 17:11:07 +0000 Subject: [Image-SIG] TIFF16 greyscale to color image Message-ID: <18b571dd0612070911q76c53a23oe20fde8a8200bfc4@mail.gmail.com> Hi, Could someone point me an efficient way to transform 16 bits greyscale tiffimage to a color image; or more simply how to create a color image from an array of value with the possibility to choose the palette, like the function imshow from Matplotlib. Can this be done with using either the function ImageOps.colorize, or putpixel? Thanks Stephane From fredrik at pythonware.com Fri Dec 8 14:12:20 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 8 Dec 2006 14:12:20 +0100 Subject: [Image-SIG] TIFF16 greyscale to color image References: <18b571dd0612070911q76c53a23oe20fde8a8200bfc4@mail.gmail.com> Message-ID: Stephane Henry wrote: > Could someone point me an efficient way to transform 16 bits > greyscale tiffimage to a color image; or more simply how to create a > color image from an array of value with the possibility to choose the > palette, like the function imshow from Matplotlib. quick recipe: - use getextrema to get the min/max value for the image (unless already known) - use point to translate the image down to an "L" image; you can use either a the argument*scale+offset form, or a 64k lookup table: http://effbot.org/imagingbook/image.htm#Image.point - use putpalette to attach a palette to the L image: http://effbot.org/imagingbook/image.htm#Image.putpalette - if necessary, convert back to RGB. From wrybread at gmail.com Tue Dec 12 00:10:25 2006 From: wrybread at gmail.com (Alec Bennett) Date: Mon, 11 Dec 2006 15:10:25 -0800 Subject: [Image-SIG] centering graphical text with PIL? In-Reply-To: References: Message-ID: I'm trying to center some graphical text using the PIL. Anyone have a clue how to do this? If there's some way of knowing how big the resulting graphical word is, I could obviously center it. For example: import ImageFont, ImageDraw, Image image_file = "button.jpg" image = Image.open(image_file) font = "arial.ttf" draw = ImageDraw.Draw(image) font = ImageFont.truetype(font, 12) draw.text((1, 1), "hi there", font=font) image.save("temp.jpg") In the above code, the 1, 1 is the x & y coordinates for the text. From coen at reservoir.nl Tue Dec 12 02:02:51 2006 From: coen at reservoir.nl (coen at reservoir.nl) Date: Tue, 12 Dec 2006 02:02:51 +0100 Subject: [Image-SIG] centering graphical text with PIL? Message-ID: <200612120102.kBC12pa16378@nl10.yourname.nl> Hello, Here is a little something. Maybe it's ugly code but I'm not a programmer. I just make things that work for me! :) Enjoy, Coen. import Image, ImageDraw, ImageFont import aggdraw width = 500 height = 300 mijntekst = "Python" im = Image.new("RGB", (width, height), ("white")) draw = aggdraw.Draw(im) font = aggdraw.Font(("red"), "georgiaz.ttf", 72, opacity=180) # Getting the size of you text mijntekstformaat = draw.textsize(mijntekst, font) textwidth, textheight = mijntekstformaat halftextwidth = 0.5 * textwidth halftextheight = 0.5 * textheight # Position of text on the canvas x = 0.5 * width y = 0.5 * height # Just a little bit up and to the left x1 = x - halftextwidth y1 = y - halftextheight draw.text((x1, y1), mijntekst, font) draw.flush() # im.save ('myfilename.png', 'png') im.show() From fredrik at pythonware.com Tue Dec 12 08:12:59 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 12 Dec 2006 08:12:59 +0100 Subject: [Image-SIG] centering graphical text with PIL? In-Reply-To: References: Message-ID: Alec Bennett wrote: > I'm trying to center some graphical text using the PIL. Anyone have a > clue how to do this? > > If there's some way of knowing how big the resulting graphical word > is, I could obviously center it. http://effbot.org/imagingbook/imagedraw.htm#Draw.textsize From michela at modfilms.com Tue Dec 12 15:10:39 2006 From: michela at modfilms.com (Michela Ledwidge) Date: Tue, 12 Dec 2006 14:10:39 -0000 Subject: [Image-SIG] PIL probs on Debian when resizing In-Reply-To: Message-ID: <009d01c71df7$4e0163b0$0b01a8c0@SIM> Hi I'm using the latest python-imaging package available for my Debian install (1.1.5-11) and unable to get image resizing working. I think the problem is my install because all the sample code I can find is almost identical. I've deleted and reinstalled the package and tested that the package and methods are available to the application. Any advice? This code produces a corrupted thumbnail which is mainly black avatar = Image.open(path) avatar.size = (128,128) avatar.save(filename, "JPG") This code doesn't produce any file at all. Neither does changinig format to PNG avatar = Image.open(path) avatar.thumbnail((128,128), Image.ANTIALIAS) # doesn't work at all avatar.save(filename, "JPG") Also tried avatar.resize method which also didn't produce anything. Best .M. Michela Ledwidge -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.409 / Virus Database: 268.15.16/582 - Release Date: 11/12/2006 From wrybread at gmail.com Tue Dec 12 00:06:28 2006 From: wrybread at gmail.com (Alec Bennett) Date: Mon, 11 Dec 2006 15:06:28 -0800 Subject: [Image-SIG] centering graphical text with PIL? Message-ID: I'm trying to center some graphical text using the PIL. Anyone have a clue how to do this? If there's some way of knowing how big the resulting graphical word is, I could obviously center it. For example: import ImageFont, ImageDraw, Image image_file = "button.jpg" image = Image.open(image_file) font = "arial.ttf" draw = ImageDraw.Draw(image) font = ImageFont.truetype(font, 12) draw.text((1, 1), "hi there", font=font) image.save("temp.jpg") In the above code, the 1, 1 is the x & y coordinates for the text. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20061211/68c48fcc/attachment.htm From adeuring at gmx.net Tue Dec 12 16:29:14 2006 From: adeuring at gmx.net (abel deuring) Date: Tue, 12 Dec 2006 16:29:14 +0100 Subject: [Image-SIG] PIL probs on Debian when resizing In-Reply-To: <009d01c71df7$4e0163b0$0b01a8c0@SIM> References: <009d01c71df7$4e0163b0$0b01a8c0@SIM> Message-ID: <457ECACA.9010802@gmx.net> Hi Michela, > Hi > > I'm using the latest python-imaging package available for my Debian install > (1.1.5-11) and unable to get image resizing working. > > I think the problem is my install because all the sample code I can find is > almost identical. I've deleted and reinstalled the package and tested that > the package and methods are available to the application. > > Any advice? > > This code produces a corrupted thumbnail which is mainly black > > avatar = Image.open(path) > avatar.size = (128,128) Here you set simply an attribute of the image object to a new value, which does not match the real, unchanged, image data. > avatar.save(filename, "JPG") > > This code doesn't produce any file at all. Neither does changinig format to > PNG > > avatar = Image.open(path) > avatar.thumbnail((128,128), Image.ANTIALIAS) > # doesn't work at all > avatar.save(filename, "JPG") This should result in "Key Error: 'JPG'". Try 'JPEG' instead. Abel From rzantow at gmail.com Sat Dec 16 05:34:18 2006 From: rzantow at gmail.com (Dick Zantow) Date: Fri, 15 Dec 2006 23:34:18 -0500 Subject: [Image-SIG] Aggdraw for PIL under Python 2.5 on WinXP? In-Reply-To: <000201c6eec3$29773730$4d001aac@programador> References: <000201c6eec3$29773730$4d001aac@programador> Message-ID: <4583774A.7060408@gmail.com> I've been dawdling about moving to Python 2.5 because various modules I use haven't been available on Windows for people, like me, who have no usable compiler. I've finally decided to bite the bullet, now that most things I want to see are available, but while PIL has a WinXP binary available for 2.5, the aggdraw module doesn't. I have been using aggdraw under 2.4 and I would like to continue to use it. I did try a .dll that another Pythonista supplied, but it doesn't work as it is now constituted -- images I generate under 2.5 do not load into my graphics program, while the same code works fine under 2.4. There also seems to be an issue with the truetype support, and I haven't tracked that down yet. Maybe there is a registry issue? At any rate, I *can* use 2.4 but at this moment it's only the lack of aggdraw that's keeping me from moving entirely to 2.5. Is there any prospect of an updated aggdraw? -- rzed From fredrik at pythonware.com Sat Dec 16 12:20:08 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 16 Dec 2006 12:20:08 +0100 Subject: [Image-SIG] Aggdraw for PIL under Python 2.5 on WinXP? In-Reply-To: <4583774A.7060408@gmail.com> References: <000201c6eec3$29773730$4d001aac@programador> <4583774A.7060408@gmail.com> Message-ID: Dick Zantow wrote: > At any rate, I *can* use 2.4 but at this moment it's only the lack of > aggdraw that's keeping me from moving entirely to 2.5. Is there any > prospect of an updated aggdraw? please don't reply to random old posts when you want to open a new thread; it messes up the archives, and messes things up for people who read this list using threaded readers. I've posted an aggdraw 1.2a3 build for 2.5 here: http://effbot.org/downloads/#aggdraw From rzantow at gmail.com Sat Dec 16 20:06:55 2006 From: rzantow at gmail.com (Dick Zantow) Date: Sat, 16 Dec 2006 14:06:55 -0500 Subject: [Image-SIG] Aggdraw for PIL under Python 2.5 on WinXP? In-Reply-To: References: <000201c6eec3$29773730$4d001aac@programador> <4583774A.7060408@gmail.com> Message-ID: <458443CF.7080504@gmail.com> Fredrik Lundh wrote: > Dick Zantow wrote: > >> At any rate, I *can* use 2.4 but at this moment it's only the lack of >> aggdraw that's keeping me from moving entirely to 2.5. Is there any >> prospect of an updated aggdraw? > > please don't reply to random old posts when you want to open a new > thread; it messes up the archives, and messes things up for people who > read this list using threaded readers. Sorry about that. > > I've posted an aggdraw 1.2a3 build for 2.5 here: > > http://effbot.org/downloads/#aggdraw > Thank you for the 2.5 build! I noticed as a consequence to trying it out that Image.show() has changed on Windows XP (all 'nt' versions, it seems). The behavior of cmd.exe if command extensions is enabled (which it is by default in WinXP) is such that a command like "start /wait %s && del /f %s" % (file, file) does not in fact wait until the application invoked by the start has completed, but returns immediately. So it seems that the 'del' is executed before the image has a chance to display, at least in Paint Shop Pro, which is what I'm using. I suppose it would be the same for other viewers, though I haven't yet tried them. The old method did leave a lot of temp files around, which was a minor annoyance, but at least it would display the image. I've restored the 2.4 behavior on my computer as a getaround, pending a better solution. -- rzed From arnouten at bzzt.net Tue Dec 19 22:34:58 2006 From: arnouten at bzzt.net (Arnout Engelen) Date: Tue, 19 Dec 2006 22:34:58 +0100 Subject: [Image-SIG] PIL regression: AttributeError: pixel_access Message-ID: <45885B02.2090906@bzzt.net> Hi, I'm also submitting a bug report against Gourmet, but I just thought I'd drop you a note: The following error (in the newest version of Gourmet, http://grecipe-manager.sf.net) occurs with PIL 1.1.6, but not with 1.1.5: Traceback (most recent call last): File "gourmet", line 34, in ? import gourmet.GourmetRecipeManager File "C:\python24\Lib\site-packages\gourmet\GourmetRecipeManager.py", line 6, in ? import prefs, prefsGui, shopgui, reccard, convertGui, fnmatch, tempfile File "C:\python24\Lib\site-packages\gourmet\shopgui.py", line 3, in ? import recipeManager, convert, WidgetSaver, reccard File "C:\python24\Lib\site-packages\gourmet\reccard.py", line 7, in ? from recindex import RecIndex File "C:\python24\Lib\site-packages\gourmet\recindex.py", line 3, in ? import WidgetSaver, Undo, ratingWidget File "C:\python24\Lib\site-packages\gourmet\ratingWidget.py", line 144, in ? star_generator = StarGenerator() File "C:\python24\Lib\site-packages\gourmet\ratingWidget.py", line 48, in __in it__ self.unset_img = Image.open(unset_image).resize(self.set_img.size) File "C:\Python24\Lib\site-packages\PIL\Image.py", line 1256, in resize self.load() File "C:\Python24\Lib\site-packages\PIL\ImageFile.py", line 217, in load return Image.Image.load(self) File "C:\Python24\Lib\site-packages\PIL\Image.py", line 599, in load return self.im.pixel_access(self.readonly) AttributeError: pixel_access Kind regards, Arnout From fredrik at pythonware.com Wed Dec 20 08:27:37 2006 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 20 Dec 2006 08:27:37 +0100 Subject: [Image-SIG] PIL regression: AttributeError: pixel_access In-Reply-To: <45885B02.2090906@bzzt.net> References: <45885B02.2090906@bzzt.net> Message-ID: Arnout Engelen wrote: > self.unset_img = Image.open(unset_image).resize(self.set_img.size) > File "C:\Python24\Lib\site-packages\PIL\Image.py", line 1256, in resize > self.load() > File "C:\Python24\Lib\site-packages\PIL\ImageFile.py", line 217, in load > return Image.Image.load(self) > File "C:\Python24\Lib\site-packages\PIL\Image.py", line 599, in load > return self.im.pixel_access(self.readonly) > AttributeError: pixel_access what kind of image does "unset_image" refer to? what does the following commands print on your machine: >>> import Image >>> Image >>> Image.core From elrz at r-p-s.co.uk Fri Dec 22 01:17:26 2006 From: elrz at r-p-s.co.uk (Raphael) Date: Thu, 21 Dec 2006 19:17:26 -0500 Subject: [Image-SIG] revolution Message-ID: <458B2416.9030907@r-p-s.co.uk> An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20061221/a90de955/attachment.htm -------------- next part -------------- A non-text attachment was scrubbed... Name: noon.gif Type: image/gif Size: 9153 bytes Desc: not available Url : http://mail.python.org/pipermail/image-sig/attachments/20061221/a90de955/attachment.gif From tinodb at gmail.com Wed Dec 27 19:18:43 2006 From: tinodb at gmail.com (TiNo) Date: Wed, 27 Dec 2006 13:18:43 -0500 Subject: [Image-SIG] Compiling PIL with JPEG support does not work at all Message-ID: <435b46e50612271018hb77475eoe1a118ed59777f7f@mail.gmail.com> Hi, I know there are many people experiencing the same problem, and there are different solutions around, but I am still unable to compile PIL with JPEG support. I am on a shared webhost (bluehost) and have build python 2.5. I am now trying to build PIL. I have build jpeg-6b from http://www.ijg.org/ in /home/spafenet/lib/lib/jpeg (that now contains bin/ and man/) My setup.py looks like this (relevant part:): --------------------------------------------------------------------- # -------------------------------------------------------------------- # Library pointers. # # Use None to look for the libraries in well-known library locations. # Use a string to specify a single directory, for both the library and # the include files. Use a tuple to specify separate directories: # (libpath, includepath). Examples: # # JPEG_ROOT = "/home/libraries/jpeg-6b" # TIFF_ROOT = "/opt/tiff/lib", "/opt/tiff/include" # # If you have "lib" and "include" directories under a common parent, # you can use the "libinclude" helper: # # TIFF_ROOT = libinclude("/opt/tiff") FREETYPE_ROOT = None JPEG_ROOT = "/home/spafenet/lib/lib/jpeg/bin" TIFF_ROOT = None ZLIB_ROOT = "/home/spafenet/lib/lib/zlib/lib","/home/spafenet/lib/lib/zlib/include" TCL_ROOT = None ------------------------------------------------------------------------------------ I have also tried JPEG_ROOT = "/home/spafenet/lib/lib/jpeg/" but that doesn't work either. Building report (for both options): -------------------------------------------------------------------- PIL 1.1.6 BUILD SUMMARY -------------------------------------------------------------------- version 1.1.6 platform linux2 2.5 (r25:51908, Dec 18 2006, 13:56:40) [GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] -------------------------------------------------------------------- *** TKINTER support not available *** JPEG support not available --- ZLIB (PNG/ZIP) support ok *** FREETYPE2 support not available -------------------------------------------------------------------- To add a missing option, make sure you have the required library, and set the corresponding ROOT variable in the setup.py script. To check the build, run the selftest.py script. ---------------------------------------------------------------------------- It works with the ZLIB though. As it takes my 1.2.3 version over the preinstalled 1.2.1.2 version. (got a warning previously). But it refuses to accept the JPEG. Any suggestions? From barchia at gmail.com Wed Dec 20 21:55:55 2006 From: barchia at gmail.com (barchia) Date: Wed, 20 Dec 2006 21:55:55 +0100 Subject: [Image-SIG] Error with last version PIL Image (AttributeError: pixel_access) Message-ID: Hi to *, Today I update the PIL, because I will try the new version for check if a problem with the font are solved, instead i found a new problem as i write in object... this is the trace of error: >>> import Image, ImageDraw >>> im = Image.new("RGB",(30,30),'white') >>> draw = ImageDraw.Draw(im) Traceback (most recent call last): File "", line 1, in ? File "C:\Python24\Lib\site-packages \PIL\ImageDraw.py", line 294, in Draw return ImageDraw(im, mode) File "C:\Python24\Lib\site-packages\PIL\ImageDraw.py", line 59, in __init__ im.load() File "C:\Python24\Lib\site-packages\PIL\Image.py", line 599, in load return self.im.pixel_access(self.readonly) AttributeError: pixel_access >>> I hope that problem not is hard to solve.... Thanks ! Alessandro Barchi -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20061220/5b1663eb/attachment.html From lab_monkey at mail2world.com Sat Dec 23 07:15:25 2006 From: lab_monkey at mail2world.com (Ior Bock) Date: Fri, 22 Dec 2006 22:15:25 -0800 Subject: [Image-SIG] Fw: Python - WEIRD Code needed (help with) Message-ID: <028701c72659$bc02bf70$0a03010a@mail2world.com> <-----Original Message-----> From: Ior Bock [lab_monkey at mail2world.com] Sent: 12/19/2006 5:55:38 PM To: help at python.org Subject: Python - WEIRD Code needed (help with) Hi, Looking for help with trying to figure out a way to emulate simple tv video feedback with PYTHON using simple scripts. Am presenting this to students and hope to stimulate their interest in this phenomenon. I've a background in Visual Basic, and am using an old version, 4.0, it compiles to a smaller executable which I prefer. I find myself in an odd situation, needing a very simple yet powerful capability of Python for a VB app Im working on. For this scenario I don't know where to begin though, am hoping for some thoughtful input, suggestions, and code samples to get me started would be a God send. Would prefer NOT using DirectX if possible. I know VERY litle about Python and a fair bit about VB. Have included a bunch of links to illustrate what I am looking for. Really what Im after is best represented in the very first link, and this is what I would like to replicate. Would like to do this with integers being used as the feedback medium, so instead of video signal feedback, we use "number feedback" Imagine in the following brief description we have our numbers acting as the signal in and signal out; "Video Feedback is easy and fun for anyone with a video camera and a monitor (TV screen). To make the simplest kind, take the "video out" from the camera and plug it into the "video in" on the monitor, and then point the camera at the monitor, so the monitor displays a picture of the monitor. Now you have a video feedback loop! To get the effects demonstrated in the gallery, careful adjustments of the various knobs and dials on the camera and monitor are required. I also recommended that you get a tripod. This is especially useful for doing rotations, since the camera can be held at a fixed angle. Adjust the tripod so you can rotate the camera about the viewing axis." Have tried this in Visual Basic, so in the VB code, user inputs numbers into some text boxes and these serve as the "video in" and "video out" mechanisms, so through looped recursion; do while loop_counter <> 5000 textbox1.text = 100 represents Camera video out textbox2.text = 75 represents Monitor video in var = new value + (textbox1.text + textbox2.text) recursion value (code here generates graphic spiral ) loop Would like the feedback generated however to be tied directly to the number inputs specifically though. Cheers ------------------ P.S. - got the following response from a VB forum; "Originally Posted by chemicalNova In any way in VB, drawing the graphical spiral will be very very VERY slow. Does it have to be literally the same as whats above? How about, for example, a PictureBox that acts as the screen (video out), and a PictureBox that acts as the camera (video in). The Screen picturebox has a mini version of the camera box, which holds the contents of the Screen Picturebox. Then, you could possibly give exact rotation angles, for the camera, and display it inside the screen picturebox." -------------- Ideally, I'd love to be able to simply have some extremely small executable that just accepts inputs does the calculations above and then spits out the graphical outputs. If I could simply have my VB app, 'call' the name of the tiny Python executable, and then the Python executable just automatically looked for a named text file (created by the VB app) and extracted number file from this, then performed the calcs, then displayes the feedback emulation that would be ideal! Following demonstrates what Im after exactly, note I'm not looking for a solution that needs to be really high fine complex graphics, etc - just want to demonstrate the basic concept. '====================== DESCRIPTIVE LINKS on VIDEO FEEDBACK FOLLOW; ------------- http://www.youtube.com/watch?v=2Jqm62IhLGM http://www.videofeedback.dk/World/ http://www.archive.org/movies/thumbnails.php?identifier=HansLemursonDavi dSkold http://www.youtube.com/watch?v=RuHmtSGbD8s http://www.youtube.com/watch?v=2Jqm62IhLGM http://www.archive.org/movies/thumbnails.php?identifier=HansLemursonDavi dSkold http://www.youtube.com/watch?v=RuHmtSGbD8s http://www.youtube.com/results?search_type=search_videos&search_query=fe edback&search_sort=&search_category=26 http://members.tripod.com/professor_tom/galleries/video/mixer/mixer4.htm l http://members.tripod.com/professor_tom/galleries/video/mixer/mixer5.htm l http://www.videofeedback.dk/World/ http://nyfilmvideo.com/sep2002/screen4.htm ===== Space-Time Dynamics in Video Feedback James P. Crutchfield Video feedback provides a readily available experimental system to study complex spatial and temporal dynamics. This article outlines the use and modeling of video feedback systems. It http://www.youtube.com/results?search_type=search_videos&search_query=fe edback&search_sort=&search_category=26 MediaSculp - Gallery http://www.mediasculp.com/QTVR/ http://www.mediasculp.com/Gallery/videofeedback/index.htm http://www.videofeedback.dk/vf/oversigt.html http://www.videofeedback.com/ http://www.art.pdx.edu/faculty/facultyhome/pirofsky/digital_stupa/digita lstupa.html Click to receive help removing your credit card debt If You Want a Second Mortgage... ...we'll connect you with 4 lenders. It just takes one simple form.

_______________________________________________________________
Get the Free email that has everyone talking at http://www.mail2world.com
Unlimited Email Storage – POP3 – Calendar – SMS – Translator – Much More!
-------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20061222/adc73298/attachment.html