From bbaxter at wadsworth.org Wed Oct 1 10:26:20 2003 From: bbaxter at wadsworth.org (William Baxter) Date: Wed Oct 1 10:27:12 2003 Subject: [Image-SIG] dithered display Message-ID: <3F7AE40C.11334941@wadsworth.org> How come on the SGI, my black & white images look dithered and low-grade when using im.show? In xv they look crisp and sharp. (SGI, IRIX64, Imaging-1.1.4, Python-2.2.3) They also look fine on my linux computer. They start out as floating point images, then I rescale them to 0..255, and convert to grayscale im.convert("L") Nothing shows up if I use ImageOps.grayscale(). From SHUREM at ccf.org Fri Oct 3 09:52:09 2003 From: SHUREM at ccf.org (Mark Shure) Date: Fri Oct 3 09:52:23 2003 Subject: [Image-SIG] Re: Follow-up to Question about ImageDraw.Draw function Message-ID: Fredrik Lundh fredrik at pythonware.com Fri Sep 26 16:26:43 EDT 2003 wrote: > I've found one local machine that had a Python install with exactly > the same problem, but I don't know what installation kits we used > when we installed Python on that machine. > > I haven't been able to repeat the problem using currently available > install kits. > > Have you tried uninstalling and reinstalling PIL? Hi Fredrik, Sorry for the delayed response... After I read your message, I tried uninstalling and reinstalling PIL. This had no effect on the problem. I've switched over to a new installation of Python 2.3 (Enthought Edition from www.enthought.com) which includes PIL 1.1.4 and have had no problems. Mark Shure ------------------------------------------------------------------------------ Confidentiality Note: This message is intended for use only by the individual or entity to which it is addressed and may contain information that is privileged, confidential, and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please contact the sender immediately and destroy the material in its entirety, whether electronic or hard copy. Thank you. Visit us online at our award-winning www.clevelandclinic.org for a complete listing of Cleveland Clinic services, staff and locations from one of the country's leading hospitals. ============================================================================== From xavier.trochu at wanadoo.fr Fri Oct 3 10:32:28 2003 From: xavier.trochu at wanadoo.fr (Xavier Trochu) Date: Fri Oct 3 10:32:55 2003 Subject: [Image-SIG] [PATCH] Fix ordering of color layer for PSD file format Message-ID: <20031003143228.GE10446@farseeker.datamark.fr> The attached patch correct an issue with some photoshop files. The issue occur when the order of the layer in the file in not one that PIL understands (i.e. ARGB was wrongly read as RGBA), the patch fix this by keeping the order consistent when building the tile array. This patch also add support for reading the name of the layers. Greetings, Xavier -------------- next part -------------- --- PsdImagePlugin.py.ori Fri Oct 03 14:10:04 2003 +++ PsdImagePlugin.py Fri Oct 03 14:05:16 2003 @@ -18,7 +18,7 @@ __version__ = "0.4" -import string +import string, struct import Image, ImageFile, ImagePalette MODES = { @@ -38,10 +38,16 @@ # helpers def i16(c): - return ord(c[1]) + (ord(c[0])<<8) + return struct.unpack('>h', c)[0] def i32(c): - return ord(c[3]) + (ord(c[2])<<8) + (ord(c[1])<<16) + (ord(c[0])<<24) + return struct.unpack('>i', c)[0] + +def u16(c): + return struct.unpack('>H', c)[0] + +def u32(c): + return struct.unpack('>I', c)[0] # --------------------------------------------------------------------. # read PSD images @@ -64,21 +70,34 @@ # # header - s = read(26) - if s[:4] != "8BPS" or i16(s[4:]) != 1: + (psd_signature, + psd_version, + psd_channels, + psd_rows, + psd_columns, + psd_depth, + psd_mode) = struct.unpack('>4sh6xhiihh', read(26)) + + if Image.DEBUG > 2: + print "psd_signature is", psd_signature + print "psd_version is", psd_version + print "psd_channels is", psd_channels + print "psd_rows is", psd_rows + print "psd_columns is", psd_columns + print "psd_depth is", psd_depth + print "psd_mode is", psd_mode + + if psd_signature != "8BPS" or psd_version != 1: raise SyntaxError, "not a PSD file" - psd_bits = i16(s[22:]) - psd_channels = i16(s[12:]) - psd_mode = i16(s[24:]) - mode, channels = MODES[(psd_mode, psd_bits)] + mode, channels = MODES[(psd_mode, psd_depth)] if channels > psd_channels: raise IOError, "not enough channels" self.mode = mode - self.size = i32(s[18:]), i32(s[14:]) + self.size = psd_columns, psd_rows # # color mode data @@ -107,7 +126,7 @@ data = read(i32(read(4))) if (len(data) & 1): read(1) # padding - self.resources.append((id, name, data)) + self.resources.append((signature, id, name, data)) # # layer and mask information @@ -164,8 +183,8 @@ # read layerinfo block layers = [] read = file.read - - for i in range(abs(i16(read(2)))): + srange = i16(read(2)) + for i in range(abs(srange)): # bounding box y0 = i32(read(4)); x0 = i32(read(4)) @@ -174,9 +193,10 @@ # image info info = [] mode = [] - for i in range(i16(read(2))): + len = i16(read(2)) + for i in range(len): type = i16(read(2)) - if type == 65535: + if type == -1: m = "A" else: m = "RGB"[type] @@ -185,6 +205,7 @@ info.append((m, size)) # figure out the image mode + modecopy = mode[:] mode.sort() if mode == ["R"]: mode = "L" @@ -197,16 +218,20 @@ # skip over blend flags and extra information filler = read(12) - name = None # FIXME - file.seek(i32(read(4)), 1) + end = u32(read(4)) + file.tell() + file.seek(i32(read(4)), 1) # skip over layer mask/adj data + file.seek(i32(read(4)), 1) # skip over blending range + len = ord(read(1)) + name = read(len) + file.seek(end, 0) # skip to the end of the layer info - layers.append((name, mode, (x0, y0, x1, y1))) + layers.append((name, mode, modecopy, (x0, y0, x1, y1))) # get tiles i = 0 - for name, mode, bbox in layers: + for name, mode, rmode, bbox in layers: tile = [] - for m in mode: + for m in rmode: t = _maketile(file, m, bbox, 1) if t: tile.extend(t) From kevin at cazabon.com Sun Oct 5 02:39:34 2003 From: kevin at cazabon.com (kevin@cazabon.com) Date: Sun Oct 5 03:36:22 2003 Subject: [Image-SIG] Help me test - module for printing to Windows Printers! Message-ID: <001101c38b0b$7164d300$2c0aa8c0@duallie> Hi everyone: I managed to get things working for printing to my non-PostScript Windows printer and have written a stand-alone module for printing PIL images. It works very well with my system here, but I'd like some help testing it with other printers/OS's. If you are interested and can do a couple quick tests, please download the module at: http://www.cazabon.com/python/downloads/WinPILprint.py There's extensive documentation within the file, and it should be pretty self-explanitory. It's very simple to use, as simple as: result, message, settings = WinPILprint.printImage("c:\\temp\\test.tif", imageResPerInch = 300) Major features so far (version 0.0): - can take a filename or a PIL image for printing - full control of image sizing, positioning - multiple methods for sizing and positioning, take your pick to what suits you best! - support for mm, inch, device units - support for pyCMS ICC color management (yay!) if available on your system - can find all installed Windows printers, or just use the default one - can report printer capabilities - automatic sizing, rotation and centering if desired Future features: - a GUI class for user-interactive printer setup and print previewing Thanks, let me know how things go, what printers and OS versions you test on, and any problems you have! Kevin Cazabon. From mstein at egrad.com Sun Oct 5 18:49:23 2003 From: mstein at egrad.com (Marc Stein) Date: Sun Oct 5 18:49:56 2003 Subject: [Image-SIG] Zope, PIL, and Poll Problem Message-ID: When attempting to use the poll product the pie chart displays as a broken graphic. The color boxes appear correctly and everything else about the poll seems fine. I have attempted to use this product under both Debian and Windows with exactly the same results. I have followed the published instructions regarding installing PIL under Windows and don't seem to have any errors. I can import The request which returns the broken graphic is http://localhost:8080/Plone/Portal/poll1/question1/drawGraph?size:int=100 Any assistance would be greatly appreciated. TIA, Marc Stein mstein@egrad.com From fredrik at pythonware.com Mon Oct 6 07:20:49 2003 From: fredrik at pythonware.com (Fredrik Lundh) Date: Mon Oct 6 07:21:01 2003 Subject: [Image-SIG] Re: Follow-up to Question about ImageDraw.Draw function References: Message-ID: Mark Shure wrote: > Sorry for the delayed response... After I read your message, I tried > uninstalling and reinstalling PIL. This had no effect on the problem. I've > switched over to a new installation of Python 2.3 (Enthought Edition > from www.enthought.com) which includes PIL 1.1.4 and have had no > problems. I should have asked earlier, but what PIL distribution did you use originally? (source URL, size in bytes) From SHUREM at ccf.org Mon Oct 6 12:26:19 2003 From: SHUREM at ccf.org (Mark Shure) Date: Mon Oct 6 12:26:36 2003 Subject: [Image-SIG] Re: Follow-up to Question about ImageDraw.Drawfunction Message-ID: >>> "Fredrik Lundh" 10/06/03 07:20AM >>> > > Mark Shure wrote: > >> Sorry for the delayed response... After I read your message, I tried >> uninstalling and reinstalling PIL. This had no effect on the problem. I've >> switched over to a new installation of Python 2.3 (Enthought Edition >> from www.enthought.com) which includes PIL 1.1.4 and have had no >> problems. > > I should have asked earlier, but what PIL distribution did you > use originally? (source URL, size in bytes) > > PIL-1.1.4.win32-py2.2.exe (401,474 bytes) downloaded from: http://effbot.org/downloads/PIL-1.1.4.win32-py2.2.exe I just now verified that the distribution file I used (I still have it on disk) has the same file size as the current file at that URL. Mark ------------------------------------------------------------------------------ Confidentiality Note: This message is intended for use only by the individual or entity to which it is addressed and may contain information that is privileged, confidential, and exempt from disclosure under applicable law. If the reader of this message is not the intended recipient or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please contact the sender immediately and destroy the material in its entirety, whether electronic or hard copy. Thank you. Visit us online at our award-winning www.clevelandclinic.org for a complete listing of Cleveland Clinic services, staff and locations from one of the country's leading hospitals. ============================================================================== From SteveC at innocent.com Wed Oct 8 18:49:38 2003 From: SteveC at innocent.com (Steven M. Castellotti) Date: Wed Oct 8 18:49:54 2003 Subject: [Image-SIG] Using PIL to display resized images over the web Message-ID: <1065653377.29742.15.camel@phaedrus> Hey all-- I have a simple photo website written in python. I would like to be able to use Python Imaging Library to read an image file from the disk, resize/thumbnail it in memory, and then print the modified image (sending it to the client web browser after the proper MIME headings). Currently, I have only managed to do this via Image.save() to a temporary file and then sending that, but of course that is somewhat inefficient. Surely there's an easier way to do this, perhaps via file descriptors? Cheers -Steve Castellotti SteveC (at) Innocent.com http://www.deltaflux.org From chris at cogdon.org Wed Oct 8 19:06:23 2003 From: chris at cogdon.org (Chris Cogdon) Date: Wed Oct 8 19:08:03 2003 Subject: [Image-SIG] Using PIL to display resized images over the web In-Reply-To: <1065653377.29742.15.camel@phaedrus> Message-ID: <0962FBBB-F9E4-11D7-8635-000A95E3823E@cogdon.org> On Wednesday, Oct 8, 2003, at 15:49 US/Pacific, Steven M. Castellotti wrote: > Hey all-- > > I have a simple photo website written in python. I would like to be > able to use Python Imaging Library to read an image file from the disk, > resize/thumbnail it in memory, and then print the modified image > (sending it to the client web browser after the proper MIME headings). > > Currently, I have only managed to do this via Image.save() to a > temporary file and then sending that, but of course that is somewhat > inefficient. Surely there's an easier way to do this, perhaps via file > descriptors? the 'save' method can take a string or a file object. If you pass a string it will 'open' that file and write the image to it. If you pass a file object, it will simply write to that file object. So... if you want to save it into a string for later processing, create a StringIO object and pass it to the save method. -- ("`-/")_.-'"``-._ Chris Cogdon . . `; -._ )-;-,_`) (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' ((,.-' ((,/ fL From SteveC at innocent.com Wed Oct 8 19:58:44 2003 From: SteveC at innocent.com (Steven M. Castellotti) Date: Wed Oct 8 20:01:11 2003 Subject: [Image-SIG] Using PIL to display resized images over the web In-Reply-To: <0962FBBB-F9E4-11D7-8635-000A95E3823E@cogdon.org> References: <0962FBBB-F9E4-11D7-8635-000A95E3823E@cogdon.org> Message-ID: <1065657524.2211.3.camel@odyssey> Chris- Many thanks for the tip. I had never used StringIO before, so after a little research I was able to figure out what I needed to know. For the sake of the list archive, here's sample code for the answer to my question: #!/usr/bin/env python import Image, cStringIO sample_image = '/archive/sample.jpg' # The physical image path file = open(sample_image, 'r') im = Image.open(file) format = im.format # remember to maintain image format when saving im = im.resize((640, 480)) file_out = cStringIO.StringIO() im.save(file_out, format) file_out.reset() print "Content-Type: image/jpeg\n" print file_out.read() file_out.close() file.close() Cheers -Steve Castellotti SteveC (at) Innocent.com http://www.deltaflux.org On Thu, 2003-10-09 at 12:06, Chris Cogdon wrote: > On Wednesday, Oct 8, 2003, at 15:49 US/Pacific, Steven M. Castellotti > wrote: > > > Hey all-- > > > > I have a simple photo website written in python. I would like to be > > able to use Python Imaging Library to read an image file from the disk, > > resize/thumbnail it in memory, and then print the modified image > > (sending it to the client web browser after the proper MIME headings). > > > > Currently, I have only managed to do this via Image.save() to a > > temporary file and then sending that, but of course that is somewhat > > inefficient. Surely there's an easier way to do this, perhaps via file > > descriptors? > > the 'save' method can take a string or a file object. If you pass a > string it will 'open' that file and write the image to it. If you pass > a file object, it will simply write to that file object. > > So... if you want to save it into a string for later processing, create > a StringIO object and pass it to the save method. > From chris at cogdon.org Wed Oct 8 20:06:12 2003 From: chris at cogdon.org (Chris Cogdon) Date: Wed Oct 8 20:06:17 2003 Subject: [Image-SIG] Using PIL to display resized images over the web In-Reply-To: <1065657524.2211.3.camel@odyssey> Message-ID: <64BE1F88-F9EC-11D7-8635-000A95E3823E@cogdon.org> On Wednesday, Oct 8, 2003, at 16:58 US/Pacific, Steven M. Castellotti wrote: > print file_out.read() I suggest using: sys.stdout.write ( file_out.read() ) Using print will add an unnecessary (and possibly harmful) CR-LF pair to the end of the image. Especially since you're relying on the web server to calculate the Content-Length from the data presented in the stream. -- ("`-/")_.-'"``-._ Chris Cogdon . . `; -._ )-;-,_`) (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' ((,.-' ((,/ fL From bplatzen at sosnetz.de Fri Oct 10 09:06:09 2003 From: bplatzen at sosnetz.de (Bjoern Platzen) Date: Fri Oct 10 09:09:58 2003 Subject: [Image-SIG] How to convert mode 'RGB' into 'P' Message-ID: <200310101506.09953.bplatzen@sosnetz.de> Hello List, I'm a Newbie to the PIL and I'm trying to make a composite of 2 PNG-files using a 3rd as mask. PNG1 is a map and PNG2 is a Border that should be drawn on top of the map. The only way to do this, seemed to be by generating a new Image ('RGB', (sizeX, sizeY), (65535, 65535, 65535)) and paste my PNG1 into it. Then I generate a new image with Image.composite(PNG2, NewImage, mask). The saved Image looks good, but it has about 220 kb and it's mode is 'RGB' If I do a Image.composite(PNG2, PNG1, mask), the image has only 94 kb and it's mode is 'P'. But in this case, the border (from PNG2) is not rendered correctly. Here's the code-snippet: import Image import PngImagePlugin Image._initialized = 1 ##Open all the images, we need... mymap = Image.open('map800.png') mask = Image.open('rahmen.png') myborder = Image.open('rahmen_t.png') ##build a new image as the base of the new image... white = Image.new('RGB', mymap.size,(65535,65535,65535)) ##paste the map onto the white background white.paste(mymap,(0,0)) ##building the output-image by composing the Border with the new Image, ##using a transparent Border-Image as the transparency-mask... outimg = Image.composite(myborder, white, mask) outimg2 = Image.composite(myborder, mymap, mask) outimg.save('combined.png', 'PNG', optimize=1) outimg2.save('combined2.png', 'PNG', optimize=1) I tried outimg.convert('P') but it had no effect. The image was still in 'RGB'-Mode. Is there anyway to do this? I think my images will become smaller when they are in mode 'P'. Thanks in advance, Bjoern. -- small office solutions info@sosnetz.de - http://www.sosnetz.de From martinxyz at gmx.ch Fri Oct 10 10:43:24 2003 From: martinxyz at gmx.ch (Martin Renold) Date: Fri Oct 10 10:43:32 2003 Subject: [Image-SIG] How to convert mode 'RGB' into 'P' In-Reply-To: <200310101506.09953.bplatzen@sosnetz.de> References: <200310101506.09953.bplatzen@sosnetz.de> Message-ID: <20031010144324.GA21796@old.homeip.net> On Fri, Oct 10, 2003 at 03:06:09PM +0200, Bjoern Platzen wrote: > I tried outimg.convert('P') but it had no effect. The image was still in > 'RGB'-Mode. I guess outimg.convert() returns a new image without altering the old one. bye Martin From chris at cogdon.org Fri Oct 10 11:55:54 2003 From: chris at cogdon.org (Chris Cogdon) Date: Fri Oct 10 11:56:02 2003 Subject: [Image-SIG] How to convert mode 'RGB' into 'P' In-Reply-To: <200310101506.09953.bplatzen@sosnetz.de> Message-ID: <3AC24B5C-FB3A-11D7-A217-000A95E3823E@cogdon.org> On Friday, Oct 10, 2003, at 06:06 US/Pacific, Bjoern Platzen wrote: > I tried outimg.convert('P') but it had no effect. The image was still > in > 'RGB'-Mode. > > Is there anyway to do this? I think my images will become smaller when > they are in mode 'P'. -- ("`-/")_.-'"``-._ Chris Cogdon . . `; -._ )-;-,_`) (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' ((,.-' ((,/ fL When you convert to 'P' mode, you need to specify a palette. For example: p_image = rgb_image.convert ( "P", palette=Image.ADAPTIVE, dither=Image.NONE, colors=256 ) If you want to ensure you're using the same palette as the original 'P' image, you can do this: p_image = rgb_image.convert ( "P", palette=old_p_image.palette, dither=Image.NONE ) And, remember that 'convert' returns a new image, rather than affecting the object. Hope that helps. -- ("`-/")_.-'"``-._ Ch'marr, a.k.a. . . `; -._ )-;-,_`) Chris Cogdon (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' FC1.3: FFH3cmA+>++C++D++H++M++P++R++T+++WZ++Sm++ ((,.-' ((,/ fL RLCT acl+++d++e+f+++h++i++++jp-sm++ From bplatzen at sosnetz.de Tue Oct 14 03:12:25 2003 From: bplatzen at sosnetz.de (Bjoern Platzen) Date: Tue Oct 14 03:16:00 2003 Subject: [Image-SIG] How to convert mode 'RGB' into 'P' In-Reply-To: <3AC24B5C-FB3A-11D7-A217-000A95E3823E@cogdon.org> References: <3AC24B5C-FB3A-11D7-A217-000A95E3823E@cogdon.org> Message-ID: <200310140912.26039.bplatzen@sosnetz.de> Sorry for my late reply... Thanks! It works now! Bye, Bjoern. Am Freitag, 10. Oktober 2003 17:55 schrieb Chris Cogdon: > On Friday, Oct 10, 2003, at 06:06 US/Pacific, Bjoern Platzen wrote: > > I tried outimg.convert('P') but it had no effect. The image was > > still in > > 'RGB'-Mode. > > > > Is there anyway to do this? I think my images will become smaller > > when they are in mode 'P'. -- small office solutions info@sosnetz.de - http://www.sosnetz.de From bplatzen at sosnetz.de Tue Oct 14 03:44:49 2003 From: bplatzen at sosnetz.de (Bjoern Platzen) Date: Tue Oct 14 03:48:15 2003 Subject: [Image-SIG] Installing PIL 1.1.4 Error on make Message-ID: <200310140944.49887.bplatzen@sosnetz.de> Hi List, I'm trying to install PIL 1.1.4 and I get Errors on 'make': $ ./configure $ make gcc -O -I./. -I/usr/local/include -DHAVE_CONFIG_H -c -o coretest.o coretest.c In file included from Imaging.h:21, from coretest.c:19: ImPlatform.h:14: #error Sorry, this library requires support for ANSI prototypes. ImPlatform.h:17: #error Sorry, this library requires ANSI header files. ImPlatform.h:35: #error Cannot find required 32-bit integer type ImPlatform.h:47: #error Cannot find required 32-bit floating point type make: *** [coretest.o] Fehler 1 When I try (after rm config.cache and make clean): $ CC="gcc -ansi" ./configure $ make I get: gcc -ansi -O -I./. -I/usr/local/include -DHAVE_CONFIG_H -c -o coretest.o coretest.c In file included from Imaging.h:21, from coretest.c:19: ImPlatform.h:14: #error Sorry, this library requires support for ANSI prototypes. ImPlatform.h:17: #error Sorry, this library requires ANSI header files. ImPlatform.h:35: #error Cannot find required 32-bit integer type ImPlatform.h:47: #error Cannot find required 32-bit floating point type make: *** [coretest.o] Fehler 1 I'm on a SuSE Linux 8.0 Box and I've downloaded the Imaging-1.1.4.tar.gz Package from the Pythonware-Homepage. Can somebody give me a hint what to do?? Thanks in advance, Bjoern. -- small office solutions info@sosnetz.de - http://www.sosnetz.de From hancock at anansispaceworks.com Wed Oct 15 22:15:19 2003 From: hancock at anansispaceworks.com (Terry Hancock) Date: Wed Oct 15 22:13:12 2003 Subject: [Image-SIG] Using PIL to display resized images over the web In-Reply-To: <1065653377.29742.15.camel@phaedrus> References: <1065653377.29742.15.camel@phaedrus> Message-ID: On Wednesday 08 October 2003 05:49 pm, Steven M. Castellotti wrote: > I have a simple photo website written in python. I would like to be > able to use Python Imaging Library to read an image file from the disk, > resize/thumbnail it in memory, and then print the modified image > (sending it to the client web browser after the proper MIME headings). If you were to use Zope, you could do this trivially with my VarImage product, which you can download at http://www.anansispaceworks.com/papers_html . OTOH, in the apparently more likely event that you don't want to use Zope, you'll find foveal thumbnailing and other operations in the Operator sub- directory of the VarImage distribution, which may be of use to you. This code passes file-like objects using the StringIO module in Python, which avoids actually writing a temporary file. You should be able to use something similar even in a plain CGI environment. Either way, I hope this helps you out, Terry -- Terry Hancock ( hancock at anansispaceworks.com ) Anansi Spaceworks http://www.anansispaceworks.com From jay at jaydorsey.com Wed Oct 15 22:30:40 2003 From: jay at jaydorsey.com (Jay Dorsey) Date: Wed Oct 15 22:32:49 2003 Subject: [Image-SIG] Using PIL to display resized images over the web In-Reply-To: References: <1065653377.29742.15.camel@phaedrus> Message-ID: <3F8E02D0.3070305@jaydorsey.com> >> I have a simple photo website written in python. I would like to be >>able to use Python Imaging Library to read an image file from the disk, >>resize/thumbnail it in memory, and then print the modified image >>(sending it to the client web browser after the proper MIME headings). > I missed the OP's message, but how about something like this: from cStringIO import StringIO import Image import sys tmp = StringIO() img = Image.open("/path/to/my/image.jpg") img.thumbnail(img, (100, 100)) img.save(tmp, "JPEG", quality=70) tmp = tmp.getvalue(tmp.seek(0)) sys.stdout.write("HTTP/1.1 200 OK\nConnection: Close\nContent-type: image/jpeg\nContent-length: %d\n\n%s" % (int(len(tmp)), tmp) I used something similar to the above in a thumbnailing project I did a while ago. Jay From bplatzen at sosnetz.de Thu Oct 16 03:02:16 2003 From: bplatzen at sosnetz.de (Bjoern Platzen) Date: Thu Oct 16 03:05:51 2003 Subject: [Image-SIG] Installing PIL 1.1.4 Error on make In-Reply-To: <20031015193902.GA22001@sebigbos.hepe.com> References: <200310140944.49887.bplatzen@sosnetz.de> <20031015193902.GA22001@sebigbos.hepe.com> Message-ID: <200310160902.16914.bplatzen@sosnetz.de> Hi Aaron, I'm not sure what I've got... $ gcc -v Reading specs from /usr/lib/gcc-lib/i486-suse-linux/2.95.3/specs gcc version 2.95.3 20010315 (SuSE) ^^^^^^ Maybe this tells me, that it is just a smalltime version made by SuSE, but I was able to compile lots of other libs and progs with it (eg. UMN Mapserver, GD2, Freetype2, ...) I'll try to get another gcc downloaded and maybe it then works. Thanks, Bjoern. Am Mittwoch, 15. Oktober 2003 21:39 schrieb Aaron Optimizer Digulla: > On Tue, Oct 14, 2003 at 09:44:49AM +0200, Bjoern Platzen wrote: > > Hi List, > > > > I'm trying to install PIL 1.1.4 and I get Errors on 'make': > > > > $ ./configure > > $ make > > gcc -O -I./. -I/usr/local/include -DHAVE_CONFIG_H -c -o > > coretest.o coretest.c > > In file included from Imaging.h:21, > > from coretest.c:19: > > ImPlatform.h:14: #error Sorry, this library requires support for > > ANSI prototypes. > >[...] > > I'm on a SuSE Linux 8.0 Box and I've downloaded the > > Imaging-1.1.4.tar.gz Package from the Pythonware-Homepage. > > Check which GCC you have installed. You must have the "real" gcc, > not some smalltime version which can only compile the Linux > kernel. -- small office solutions info@sosnetz.de - http://www.sosnetz.de From chris at cogdon.org Thu Oct 16 03:21:32 2003 From: chris at cogdon.org (Chris Cogdon) Date: Thu Oct 16 03:21:35 2003 Subject: [Image-SIG] Installing PIL 1.1.4 Error on make In-Reply-To: <200310160902.16914.bplatzen@sosnetz.de> Message-ID: <5E090414-FFA9-11D7-BDA9-000A95E3823E@cogdon.org> On Thursday, Oct 16, 2003, at 00:02 US/Pacific, Bjoern Platzen wrote: > Hi Aaron, > > I'm not sure what I've got... > $ gcc -v > Reading specs from /usr/lib/gcc-lib/i486-suse-linux/2.95.3/specs > gcc version 2.95.3 20010315 (SuSE) > ^^^^^^ > Maybe this tells me, that it is just a smalltime version made by SuSE, > but I was able to compile lots of other libs and progs with it (eg. UMN > Mapserver, GD2, Freetype2, ...) > > I'll try to get another gcc downloaded and maybe it then works. Just checked this with a debian linux system running gcc 2.95.4. Imaging-1.1.4 compiles just fine. There might be something else wrong with your gcc or include file installation that a reinstall will fix. IT's possible that gcc is pulling the include files from the wrong place. This could well be the fault of the configure scripts making 'assumptions ' that aren't valid for your system. Who knows :) -- ("`-/")_.-'"``-._ Chris Cogdon . . `; -._ )-;-,_`) (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' ((,.-' ((,/ fL From hancock at anansispaceworks.com Thu Oct 16 03:32:52 2003 From: hancock at anansispaceworks.com (Terry Hancock) Date: Thu Oct 16 03:30:00 2003 Subject: [Image-SIG] Using PIL to display resized images over the web In-Reply-To: <3F8E02D0.3070305@jaydorsey.com> References: <1065653377.29742.15.camel@phaedrus> <3F8E02D0.3070305@jaydorsey.com> Message-ID: On Wednesday 15 October 2003 09:30 pm, Jay Dorsey wrote: > from cStringIO import StringIO Mind you, I noticed some problems with larger strings using cStringIO, and I went back to the python StringIO implementation. It's slower, I suppose, but apparently a bit more robust. I can't remember exactly what the error was that I kept running into, but switching modules solved my problem. Cheers, Terry -- Terry Hancock ( hancock at anansispaceworks.com ) Anansi Spaceworks http://www.anansispaceworks.com From mark at diversiform.com Wed Oct 15 17:41:51 2003 From: mark at diversiform.com (mark) Date: Thu Oct 16 08:28:32 2003 Subject: [Image-SIG] Using PIL Message-ID: <003401c39365$25054c30$5501a8c0@markxp> I feel fairly well versed in getting Tkinter to do what I want, but now I'm venturing into the whole imaging thing, and placing text and graphics over some static background image. Here's the code: class Imaging: def __init__(self, parent): working = self.working = Toplevel(parent) type = gui.mediavar.get() print type if type == 15: print 'Should see small label' self.labelimage = 'labelsmall.gif' elif type == 25: print 'Should see large label' self.labelimage = 'labelbig.gif' self.img = PhotoImage(file = 'C:/ClearView_Printer/' + self.labelimage) self.width = self.img.width() self.height = self.img.height() self.canvas = Canvas(working, width = self.width, height = self.height, selectborderwidth = 0) self.canvas.pack(side = TOP, fill = BOTH, expand = 0) self.canvas.create_image(0, 0, anchor = NW, image = self.img) I'm currently getting code reference from Python and Tkinter Programming by John E. Grayson. Most of the stuff in there is heavy in image mapping, but there seem to be some core elements I can use, I just don't seem to be using them correctly. This code results in a correctly sized new window with a gray background, no image. I can successfully draw objects in this window, but the .gif image won't display. I am trying to avoid using show(), as the manual I read suggests this is only for debugging purposes. Of course, using show() lets me see the image. Any input would be appreciated. TIA, - Mark -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/image-sig/attachments/20031015/34e7f07e/attachment.html From fsoganda at mitre.org Thu Oct 16 13:16:35 2003 From: fsoganda at mitre.org (Frank Sogandares) Date: Thu Oct 16 13:16:43 2003 Subject: [Image-SIG] Question about PIL fonts Message-ID: <3F8ED273.4C74ED8@mitre.org> Our sysadmins are installing PIL on the corporate LAN, which supports both linux and solaris. I also have some PIL fonts that I'd like them to install. I ask because I'd prefer not to have to hardcode a fontpath in my code. I'd like to be able to get the fonts when I import PIL (without specifying any font paths) 1] Is there a recommended location for the fonts so that I can just import pil? 2] If not, am I stuck hardcoding a fontpath into my code? Thanks -------------- next part -------------- A non-text attachment was scrubbed... Name: fsoganda.vcf Type: text/x-vcard Size: 695 bytes Desc: Card for Frank Sogandares Url : http://mail.python.org/pipermail/image-sig/attachments/20031016/964892c8/fsoganda.vcf From digulla at hepe.com Thu Oct 16 16:20:21 2003 From: digulla at hepe.com (Aaron Optimizer Digulla) Date: Thu Oct 16 16:20:40 2003 Subject: [Image-SIG] Installing PIL 1.1.4 Error on make In-Reply-To: <200310160902.16914.bplatzen@sosnetz.de> References: <200310140944.49887.bplatzen@sosnetz.de> <20031015193902.GA22001@sebigbos.hepe.com> <200310160902.16914.bplatzen@sosnetz.de> Message-ID: <20031016202021.GA2189@sebigbos.hepe.com> On Thu, Oct 16, 2003 at 09:02:16AM +0200, Bjoern Platzen wrote: > Hi Aaron, > > I'm not sure what I've got... > $ gcc -v > Reading specs from /usr/lib/gcc-lib/i486-suse-linux/2.95.3/specs > gcc version 2.95.3 20010315 (SuSE) > ^^^^^^ > Maybe this tells me, that it is just a smalltime version made by SuSE, > but I was able to compile lots of other libs and progs with it (eg. UMN > Mapserver, GD2, Freetype2, ...) Yes, a lot of software will compile with K&C style C code but PIL needs an ANSI C compiler. > I'll try to get another gcc downloaded and maybe it then works. What does rpm -qi gcc say? And if that fails, try rpm -qf $(which gcc) -- Aaron "Optimizer" Digulla a.k.a. Philmann Dark "It's not the universe that's limited, it's our imagination. Follow me and I'll show you something beyond the limits." http://www.philmann-dark.de/ From digulla at hepe.com Thu Oct 16 16:20:22 2003 From: digulla at hepe.com (Aaron Optimizer Digulla) Date: Thu Oct 16 16:20:44 2003 Subject: [Image-SIG] Question about PIL fonts In-Reply-To: <3F8ED273.4C74ED8@mitre.org> References: <3F8ED273.4C74ED8@mitre.org> Message-ID: <20031016202022.GA2202@sebigbos.hepe.com> On Thu, Oct 16, 2003 at 01:16:35PM -0400, Frank Sogandares wrote: > Our sysadmins are installing PIL on the corporate LAN, which supports both linux and solaris. > > I also have some PIL fonts that I'd like them to install. I ask because I'd prefer not to have to hardcode a fontpath in my code. I'd like to be able to get the fonts when I import PIL (without specifying any font paths) > > 1] Is there a recommended location for the fonts so that I can just import pil? Not that I know of. > 2] If not, am I stuck hardcoding a fontpath into my code? No, I'd suggest that you use os.getenv("PIL_FONTS") in your code, then every user can just set the env variable PIL_FONTS and put the fonts where they want them. Even more comfortable: def findFont (name): for path in os.getenv("PIL_FONTS").split(":"): file = os.path.join (path, name) if os.path.exists (file): return file throw "Font %s not found. Please set PIL_FONTS!" % name I guess the python library needs a path-searching module :-) -- Aaron "Optimizer" Digulla a.k.a. Philmann Dark "It's not the universe that's limited, it's our imagination. Follow me and I'll show you something beyond the limits." http://www.philmann-dark.de/ From bplatzen at sosnetz.de Thu Oct 16 16:37:54 2003 From: bplatzen at sosnetz.de (Bjoern Platzen) Date: Thu Oct 16 16:41:30 2003 Subject: [Image-SIG] Installing PIL 1.1.4 Error on make In-Reply-To: <20031016202021.GA2189@sebigbos.hepe.com> References: <200310140944.49887.bplatzen@sosnetz.de> <200310160902.16914.bplatzen@sosnetz.de> <20031016202021.GA2189@sebigbos.hepe.com> Message-ID: <200310162237.54609.bplatzen@sosnetz.de> Hi Aaron, rpm -qi gcc gives the following: # rpm -qi gcc Name : gcc Relocations: (not relocateable) Version : 2.95.3 Vendor: SuSE AG, Nuernberg, Germany Release : 216 Build Date: Sam 23 M?r 2002 18:48:46 CET Install date: Die 27 Aug 2002 10:18:24 CEST Build Host: Macintyre.suse.de Group : Development/Languages/C and C++ Source RPM: gcc-2.95.3-216.src.rpm Size : 3278824 License: GPL Packager : feedback@suse.de Summary : The GNU C compiler and support files Description : NOTE: Be sure to install at least the following packages besides this one, or you won't be able to compile: binutils and glibc-devel. Compiled with support for g77 and pascal. Authors: -------- [...] SuSE series: d Distribution: SuSE Linux 8.0 (i386) Now I've downloaded gcc 3.3.1 and I'm going to compile it tomorrow. If I understood right, that one supports ANSI C. I let you know if that helped. Bye and thanks, Bjoern. Am Donnerstag, 16. Oktober 2003 22:20 schrieb Aaron Optimizer Digulla: > On Thu, Oct 16, 2003 at 09:02:16AM +0200, Bjoern Platzen wrote: > > Hi Aaron, > > > > I'm not sure what I've got... > > $ gcc -v > > Reading specs from /usr/lib/gcc-lib/i486-suse-linux/2.95.3/specs > > gcc version 2.95.3 20010315 (SuSE) > > ^^^^^^ > > Maybe this tells me, that it is just a smalltime version made by > > SuSE, but I was able to compile lots of other libs and progs with > > it (eg. UMN Mapserver, GD2, Freetype2, ...) > > Yes, a lot of software will compile with K&C style C code but > PIL needs an ANSI C compiler. > > > I'll try to get another gcc downloaded and maybe it then works. > > What does rpm -qi gcc say? And if that fails, try > > rpm -qf $(which gcc) -- small office solutions info@sosnetz.de - http://www.sosnetz.de From chris at cogdon.org Thu Oct 16 16:47:56 2003 From: chris at cogdon.org (Chris Cogdon) Date: Thu Oct 16 16:48:07 2003 Subject: [Image-SIG] Installing PIL 1.1.4 Error on make In-Reply-To: <200310162237.54609.bplatzen@sosnetz.de> Message-ID: <052B2D91-001A-11D8-BDA9-000A95E3823E@cogdon.org> On Thursday, Oct 16, 2003, at 13:37 US/Pacific, Bjoern Platzen wrote: > Hi Aaron, > > rpm -qi gcc gives the following: > # rpm -qi gcc > Name : gcc Relocations: (not > relocateable) > Version : 2.95.3 Vendor: SuSE AG, > Nuernberg, Germany > Release : 216 Build Date: Sam 23 M?r 2002 > 18:48:46 CET > Install date: Die 27 Aug 2002 10:18:24 CEST Build Host: > Macintyre.suse.de > Group : Development/Languages/C and C++ Source RPM: > gcc-2.95.3-216.src.rpm > Size : 3278824 License: GPL > Packager : feedback@suse.de > Summary : The GNU C compiler and support files > Description : > NOTE: Be sure to install at least the following packages besides this > one, or you won't be able to compile: binutils and glibc-devel. > > Compiled with support for g77 and pascal. > > Authors: > -------- > [...] > > SuSE series: d > Distribution: SuSE Linux 8.0 (i386) > > Now I've downloaded gcc 3.3.1 and I'm going to compile it tomorrow. If > I > understood right, that one supports ANSI C. 2.95.3 supports ANSI C just fine, however. In fact, I think GCC has supported ANSI C since its conception. There's something ELSE wrong with your setup, which may or may not be fixed by installing a new version of the compiler. -- ("`-/")_.-'"``-._ Chris Cogdon . . `; -._ )-;-,_`) (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' ((,.-' ((,/ fL From bplatzen at sosnetz.de Thu Oct 16 17:02:55 2003 From: bplatzen at sosnetz.de (Bjoern Platzen) Date: Thu Oct 16 17:06:31 2003 Subject: [Image-SIG] Installing PIL 1.1.4 Error on make In-Reply-To: <052B2D91-001A-11D8-BDA9-000A95E3823E@cogdon.org> References: <052B2D91-001A-11D8-BDA9-000A95E3823E@cogdon.org> Message-ID: <200310162302.55376.bplatzen@sosnetz.de> Hi Chris, Am Donnerstag, 16. Oktober 2003 22:47 schrieb Chris Cogdon: > > 2.95.3 supports ANSI C just fine, however. In fact, I think GCC has > supported ANSI C since its conception. > > There's something ELSE wrong with your setup, which may or may not be > fixed by installing a new version of the compiler. Maybe it's what Aaron said, that I only have a 'castrated' version of gcc on my box (it's definitly precompiled by SuSE). Then it will be fixed by installing the new (full) version of gcc. We will see... ... if that doesn't help, I will have to dig deeper... ...though I'm not yet sure where to search next. I'm more a Linux-user than an admin... Bye, Bjoern. -- small office solutions info@sosnetz.de - http://www.sosnetz.de From fsoganda at mitre.org Fri Oct 17 07:49:02 2003 From: fsoganda at mitre.org (Frank Sogandares) Date: Fri Oct 17 07:49:10 2003 Subject: [Image-SIG] Question about PIL fonts Message-ID: <3F8FD72E.8EE97A6@mitre.org> this is good... thanks... -------------- next part -------------- A non-text attachment was scrubbed... Name: fsoganda.vcf Type: text/x-vcard Size: 695 bytes Desc: Card for Frank Sogandares Url : http://mail.python.org/pipermail/image-sig/attachments/20031017/f58c47cb/fsoganda.vcf From chris at cogdon.org Fri Oct 17 13:56:22 2003 From: chris at cogdon.org (Chris Cogdon) Date: Fri Oct 17 13:56:30 2003 Subject: [Image-SIG] Clearing house for PIL patches? Message-ID: <3815C86A-00CB-11D8-9379-000A95E3823E@cogdon.org> Is there a clearing house or some kind of central location or index of 'unofficial patches' for PIL? (Where 'unofficial patches' means fixes and features that haven't yet made it into the next official release from pythonware) If not, would people find it worthwhile if someone (and I'll volunteer) to set one up? -- ("`-/")_.-'"``-._ Chris Cogdon . . `; -._ )-;-,_`) (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' ((,.-' ((,/ fL From bob at redivi.com Fri Oct 17 14:01:23 2003 From: bob at redivi.com (Bob Ippolito) Date: Fri Oct 17 14:02:07 2003 Subject: [Image-SIG] Clearing house for PIL patches? In-Reply-To: <3815C86A-00CB-11D8-9379-000A95E3823E@cogdon.org> Message-ID: On Friday, Oct 17, 2003, at 13:56 America/New_York, Chris Cogdon wrote: > Is there a clearing house or some kind of central location or index of > 'unofficial patches' for PIL? (Where 'unofficial patches' means fixes > and features that haven't yet made it into the next official release > from pythonware) > > If not, would people find it worthwhile if someone (and I'll > volunteer) to set one up? Sounds like a good thing to use a wiki for. I think it's worthwhile to do. There's the python.org wiki, and I've got one at pythonmac.org if you want to use that. The only patch I've used so far is the one that enhances the TIFF support with libtiff. -bob From Layne.Bilyeu at robbstucky.net Tue Oct 21 16:04:52 2003 From: Layne.Bilyeu at robbstucky.net (AdvertisingDept) Date: Tue Oct 21 16:07:48 2003 Subject: [Image-SIG] PSDraw yields Undefined Error gsize when output on PSdevice Message-ID: I am trying to follow the example for PostScript Printing in the PIL manual. When I use PSDraw() to generate postscript from an image, I can't print it. Example from the Python Image Library Manual import Image, PSDraw im = Image.open('lena.gif').convert('L') box = (1*72, 2*72, 7*72, 10*72) outfp = open('lena.ps','w') ps = PSDraw.PSDraw(outfp) ps.begin_document() ps.image(box,im,72) ps.rectangle(box) ps.end_document() When I try to send 'lena.ps' to the printer, the print job is aborted. The error it gives is always related to gsize. Error: undefined gsize It does this on several different PostScript Devices. I've tried converting to RGB, L, and CMYK modes to no avail. I've searched the various mailing lists and noticed that this has been asked before, but no-one ever responds. What is the secret to getting the PSDraw example in the PIL Manual to function correctly? Thanks In Advance. From kevin_cazabon at hotmail.com Tue Oct 21 16:39:39 2003 From: kevin_cazabon at hotmail.com (kevin_cazabon@hotmail.com) Date: Tue Oct 21 16:44:06 2003 Subject: [Image-SIG] PSDraw yields Undefined Error gsize when output onPSdevice References: Message-ID: While I can't answer your question directly, if your printer has a standard Windows driver I may have an alternative for you. I've written a module for printing to non-PS Windows printers (including a cool graphical printer setup dialog), and will post it for you tonite. Kevin. ----- Original Message ----- From: "AdvertisingDept" To: Sent: Tuesday, October 21, 2003 1:04 PM Subject: [Image-SIG] PSDraw yields Undefined Error gsize when output onPSdevice > I am trying to follow the example for PostScript Printing in the PIL > manual. > > When I use PSDraw() to generate postscript from an image, I can't print > it. > > Example from the Python Image Library Manual > > import Image, PSDraw > im = Image.open('lena.gif').convert('L') > box = (1*72, 2*72, 7*72, 10*72) > outfp = open('lena.ps','w') > ps = PSDraw.PSDraw(outfp) > ps.begin_document() > ps.image(box,im,72) > ps.rectangle(box) > ps.end_document() > > When I try to send 'lena.ps' to the printer, the print job is aborted. > > The error it gives is always related to gsize. > > Error: undefined gsize > > It does this on several different PostScript Devices. > I've tried converting to RGB, L, and CMYK modes to no avail. > > I've searched the various mailing lists and noticed that this has been > asked before, but no-one ever responds. > > What is the secret to getting the PSDraw example in the PIL Manual to > function correctly? > > Thanks In Advance. > > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig > > From Layne.Bilyeu at robbstucky.net Tue Oct 21 16:55:11 2003 From: Layne.Bilyeu at robbstucky.net (AdvertisingDept) Date: Tue Oct 21 16:58:42 2003 Subject: [Image-SIG] PSDraw yields Undefined Error gsize when output onPSdevice Message-ID: Thanks, but there are no Microsoft(TM) Products at this location. Therefore I don't have a proprietary Windows(TM) Driver installed. I am printing to multiple PostScript Devices. So I need to stay within the PostScript Language. Has anyone gotten the Example from the PIL manual to work? From kevin at cazabon.com Tue Oct 21 23:18:11 2003 From: kevin at cazabon.com (kevin@cazabon.com) Date: Wed Oct 22 00:14:51 2003 Subject: [Image-SIG] PSDraw yields Undefined Error gsize when output onPSdevice References: Message-ID: <006e01c3984b$21708fe0$2c0aa8c0@duallie> I've posted the next version of my printer driver for Windows for those that are interested, MUCH improved over the early version, and it now includes a graphical printer setup dialog class. This should enable you to print to basically any printer with a normal Windows driver, and has lots of options on how to size/position the image on the page. See documentation in the module for details, send me feedback and bug reports. The module has been renamed to ImagePrintWin.py http://www.cazabon.com/python/ImagePrintWin/ Kevin Cazabon ----- Original Message ----- From: "AdvertisingDept" To: Cc: Sent: Tuesday, October 21, 2003 2:55 PM Subject: Re: [Image-SIG] PSDraw yields Undefined Error gsize when output onPSdevice > Thanks, > > but there are no Microsoft(TM) Products at this location. > Therefore I don't have a proprietary Windows(TM) Driver installed. > > I am printing to multiple PostScript Devices. > So I need to stay within the PostScript Language. > > > Has anyone gotten the Example from the PIL manual to work? > From weinhand at unileoben.ac.at Wed Oct 22 05:52:32 2003 From: weinhand at unileoben.ac.at (WEINHANDL Herbert) Date: Wed Oct 22 02:50:20 2003 Subject: [Image-SIG] PSDraw yields Undefined Error gsize when output on PSdevice In-Reply-To: References: Message-ID: <3F965360.9030109@unileoben.ac.at> AdvertisingDept wrote: > I am trying to follow the example for PostScript Printing in the PIL manual > > When I use PSDraw() to generate postscript from an image, I can't print it. > When I try to send 'lena.ps' to the printer, the print job is aborted. > > The error it gives is always related to gsize. > > Error: undefined gsize you are totally right : it should be gsave instead of gsize if you correct it in lena.ps it can be viewed with ghostscript you should correct it in PSDraw.py too > It does this on several different PostScript Devices. > I've tried converting to RGB, L, and CMYK modes to no avail. > > I've searched the various mailing lists and noticed that this has been > asked before, but no-one ever responds. > > What is the secret to getting the PSDraw example in the PIL Manual to > function correctly? > > Thanks In Advance. Happy pythoning Herbert PS: postscript is a nice programming language too ;-) From sivachandra_br at yahoo.com Wed Oct 22 06:30:15 2003 From: sivachandra_br at yahoo.com (Siva Chandra) Date: Wed Oct 22 06:30:20 2003 Subject: [Image-SIG] Improving speed of PIL applications.... In-Reply-To: <3F965360.9030109@unileoben.ac.at> Message-ID: <20031022103015.46274.qmail@web40712.mail.yahoo.com> hello, I am working on an Image processing project and am using PIL for that. Evrything works fine but its all so damn slow. Is there a fast algorithm to implement region growing? And is there a fast way of doing point processing which cannot be done by a Look up table? thanx ===== Siva Chandra B-Tech, Electrical Engineering, IIT Madras. Currently pursuing MS by research at IIIT, Hyderabad visit www.geocities.com/sivachandra_br __________________________________ Do you Yahoo!? The New Yahoo! Shopping - with improved product search http://shopping.yahoo.com From Layne.Bilyeu at robbstucky.net Wed Oct 22 10:25:38 2003 From: Layne.Bilyeu at robbstucky.net (AdvertisingDept) Date: Wed Oct 22 10:29:53 2003 Subject: [Image-SIG] PSDraw yields Undefined Error gsize when output on PSdevice Message-ID: Thank You Herbert!!!! Your solution ... editing PSDraw.py and replacing gsize with gsave fixes the problem! PSDraw now works correctly. -original message ---------------------------------------------- > I am trying to follow the example for PostScript Printing > in the PIL manual. When I use PSDraw() to generate postscript > from an image, I can't print it. > When I try to send 'lena.ps' to the printer, the print job > is aborted. The error it gives is always related to gsize. > > Error: undefined gsize you are totally right : it should be gsave instead of gsize if you correct it in lena.ps it can be viewed with ghostscript you should correct it in PSDraw.py too From digulla at hepe.com Wed Oct 22 14:25:36 2003 From: digulla at hepe.com (Aaron Optimizer Digulla) Date: Wed Oct 22 14:25:46 2003 Subject: [Image-SIG] Improving speed of PIL applications.... In-Reply-To: <20031022103015.46274.qmail@web40712.mail.yahoo.com> References: <3F965360.9030109@unileoben.ac.at> <20031022103015.46274.qmail@web40712.mail.yahoo.com> Message-ID: <20031022182536.GA12279@sebigbos.hepe.com> On Wed, Oct 22, 2003 at 03:30:15AM -0700, Siva Chandra wrote: > > hello, > > I am working on an Image processing project and am > using PIL for that. Evrything works fine but its all > so damn slow. Is there a fast algorithm to implement > region growing? And is there a fast way of doing point > processing which cannot be done by a Look up table? Look for Numpy which is an extension to Python to process large arrays of numbers or matrices. Also, Pygame might be interesting (because it's speed optimized). -- Aaron "Optimizer" Digulla a.k.a. Philmann Dark "It's not the universe that's limited, it's our imagination. Follow me and I'll show you something beyond the limits." http://www.philmann-dark.de/ From kevin at cazabon.com Mon Oct 27 01:33:03 2003 From: kevin at cazabon.com (kevin@cazabon.com) Date: Mon Oct 27 02:29:37 2003 Subject: [Image-SIG] ImagePrintWin now has a preview tab... Message-ID: <012401c39c54$2d6fe680$2c0aa8c0@duallie> I've released version 0.3 of ImagePrintWin (module for printing PIL images to any normal Windows Printer). The printerSetup GUI now has a proper preview tab for showing how the image will be sized/positioned on the page. It also has a number of small bug fixes. I'd appreciate any testing reports to verify if this module works properly with a wide range of printers. The module, if run as __main__ will run a demo that allows you to select, size, and print an image file. You'll need Pmw to use the printerSetup GUI, sorry! http://www.cazabon.com/python/ImagePrintWin/ Kevin. From janssen at parc.com Wed Oct 29 21:30:31 2003 From: janssen at parc.com (Bill Janssen) Date: Wed Oct 29 21:31:02 2003 Subject: [Image-SIG] PIL 1.1.4 breaks Python 2.3 on Mac OS X 10.3 Panther Message-ID: <03Oct29.183038pst."58611"@synergy1.parc.xerox.com> When I install PIL 1.1.4 against the default /usr/bin/python on Panther (Mac OS 10.3), things seem to build and install fine. The little "coretest" program in PIL runs OK. However, when I fire up python, and try to "import Image", I get the following: % /usr/bin/python Python 2.3 (#1, Sep 13 2003, 00:49:11) [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import Image Fatal Python error: Interpreter not initialized (version mismatch?) Abort % I've tried re-building python from source and re-installing PIL, with the same results. Any ideas? Bill From fredm at smartypantsco.com Thu Oct 30 00:18:01 2003 From: fredm at smartypantsco.com (Alfred Milgrom) Date: Thu Oct 30 01:04:02 2003 Subject: [Image-SIG] optimizing GIF images Message-ID: <5.1.0.14.0.20031030154717.03391d90@192.168.1.1> Hi: I wonder if anyone can help me. I am trying to reduce the size of PIL-generated GIF images, but having no success. 1. The documentation in PIL mentions that GIF image saving now supports the optimize flag, but there is no usage example. I have tried im.save(filepath, optimize=1) but this did not produce a different-sized image. Am I doing it wrong? 2. In the PIL 1.1.4 distribution, the file GifImagePlugin.py contains the following lines at the end: # # Uncomment the following line if you wish to use NETPBM/PBMPLUS # instead of the built-in "uncompressed" GIF encoder # Image.register_save(GifImageFile.format, _save_netpbm) How do I get _save_netpbm for use on Windows? 3. It is my understanding that the patent on GIF format has expired this year. Has anyone developed a Python program that enables saving of compressed GIF files? (I couldn't find any reference on Google) Any other suggestions would be welcome. I am using Python 2.2, PIL 1.1.4 on Windows. Thanks in anticipation, Alfred Milgrom From chris at cogdon.org Thu Oct 30 01:22:04 2003 From: chris at cogdon.org (Chris Cogdon) Date: Thu Oct 30 01:22:09 2003 Subject: [Image-SIG] optimizing GIF images In-Reply-To: <5.1.0.14.0.20031030154717.03391d90@192.168.1.1> References: <5.1.0.14.0.20031030154717.03391d90@192.168.1.1> Message-ID: <61494665-0AA1-11D8-B114-000A95E3823E@cogdon.org> On Oct 29, 2003, at 21:18, Alfred Milgrom wrote: > 3. It is my understanding that the patent on GIF format has expired > this year. Has anyone developed a Python program that enables saving > of compressed GIF files? (I couldn't find any reference on Google) > > Any other suggestions would be welcome. I am using Python 2.2, PIL > 1.1.4 on Windows. > Thanks in anticipation, > Alfred Milgrom I'm really looking forward to that myself, I'm generating very large GIF thumbnails at the moment :) Be careful, though. The patent has expired in the **US** this year, it's still valid for one more year in some European countries. -- ("`-/")_.-'"``-._ Chris Cogdon . . `; -._ )-;-,_`) (v_,)' _ )`-.\ ``-' _.- _..-_/ / ((.' ((,.-' ((,/ fL From janssen at parc.com Thu Oct 30 22:01:12 2003 From: janssen at parc.com (Bill Janssen) Date: Thu Oct 30 22:01:40 2003 Subject: [Image-SIG] PIL setup.py broken for MacOS 10.3 Message-ID: <03Oct30.190121pst."58611"@synergy1.parc.xerox.com> This still doesn't fix my main problem of not being able to install, but I should note that when I try to build 1.1.4 from source on MacOS 10.3, I get the following error: % python setup.py build Traceback (most recent call last): File "setup.py", line 287, in ? extra_compile_args=EXTRA_COMPILE_ARGS, NameError: name 'EXTRA_COMPILE_ARGS' is not defined % Bill From bob at redivi.com Thu Oct 30 22:10:55 2003 From: bob at redivi.com (Bob Ippolito) Date: Thu Oct 30 22:11:20 2003 Subject: [Image-SIG] PIL setup.py broken for MacOS 10.3 In-Reply-To: <03Oct30.190121pst."58611"@synergy1.parc.xerox.com> References: <03Oct30.190121pst."58611"@synergy1.parc.xerox.com> Message-ID: On Oct 30, 2003, at 10:01 PM, Bill Janssen wrote: > This still doesn't fix my main problem of not being able to install, > but I should note that when I try to build 1.1.4 from source on MacOS > 10.3, I get the following error: > > % python setup.py build > Traceback (most recent call last): > File "setup.py", line 287, in ? > extra_compile_args=EXTRA_COMPILE_ARGS, > NameError: name 'EXTRA_COMPILE_ARGS' is not defined > % At a glance, this looks like it happens when you do not have _tkinter, but you do have freetype. Definitely a bug in the setup.py. I'd toss the extra_compile_* lines, they can't possibly do anything useful in your scenario. -bob From janssen at parc.com Thu Oct 30 22:34:41 2003 From: janssen at parc.com (Bill Janssen) Date: Thu Oct 30 22:35:00 2003 Subject: [Image-SIG] PIL setup.py broken for MacOS 10.3 In-Reply-To: Your message of "Thu, 30 Oct 2003 19:10:55 PST." Message-ID: <03Oct30.193443pst."58611"@synergy1.parc.xerox.com> I set EXTRA_COMPILE_ARGS = None at the top of the file, and it fixes this. Bill From fredrik at pythonware.com Fri Oct 31 08:21:44 2003 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri Oct 31 08:22:07 2003 Subject: [Image-SIG] Re: PIL setup.py broken for MacOS 10.3 References: <03Oct30.190121pst."58611"@synergy1.parc.xerox.com> Message-ID: Bill Janssen wrote: > This still doesn't fix my main problem of not being able to install, > but I should note that when I try to build 1.1.4 from source on MacOS > 10.3, I get the following error: > > % python setup.py build > Traceback (most recent call last): > File "setup.py", line 287, in ? > extra_compile_args=EXTRA_COMPILE_ARGS, > NameError: name 'EXTRA_COMPILE_ARGS' is not defined > % if you google for that exception and click "I feel lucky", you'll end up on this page: http://effbot.org/zone/pil-errata-114.htm cheers /F From Kevin.Smith at sas.com Fri Oct 31 08:59:23 2003 From: Kevin.Smith at sas.com (Kevin D. Smith) Date: Fri Oct 31 08:59:05 2003 Subject: [Image-SIG] Problem reading PNG image Message-ID: <6EB84633-0BAA-11D8-B1DA-000393829ED2@sas.com> I have some images generated by the dvi2bitmap program that don't seem to work in PIL. PIL gives me the size correctly, but if I try to do anything with it (e.g. getbbox), I get an IOError in the load method. See the attached image as an example. -------------- next part -------------- A non-text attachment was scrubbed... Name: eqn-0005.png Type: image/png Size: 834 bytes Desc: not available Url : http://mail.python.org/pipermail/image-sig/attachments/20031031/67347d46/eqn-0005.png -------------- next part -------------- Kevin Smith Kevin.Smith@sas.com From bob at redivi.com Fri Oct 31 09:05:58 2003 From: bob at redivi.com (Bob Ippolito) Date: Fri Oct 31 09:06:21 2003 Subject: [Image-SIG] Problem reading PNG image In-Reply-To: <6EB84633-0BAA-11D8-B1DA-000393829ED2@sas.com> References: <6EB84633-0BAA-11D8-B1DA-000393829ED2@sas.com> Message-ID: <59F23DF1-0BAB-11D8-8AA8-000A95686CD8@redivi.com> On Oct 31, 2003, at 8:59 AM, Kevin D. Smith wrote: > I have some images generated by the dvi2bitmap program that don't seem > to work in PIL. PIL gives me the size correctly, but if I try to do > anything with it (e.g. getbbox), I get an IOError in the load method. > See the attached image as an example. I can reproduce this problem (OS X 10.3, PIL compiled with libtiff, libjpeg, libpng, freetype against vendor Python 2.3). I'm not sure what the solution is, but the OS itself reads the png just fine (I see it inline in your message). -bob From hancock at anansispaceworks.com Fri Oct 31 13:52:49 2003 From: hancock at anansispaceworks.com (Terry Hancock) Date: Fri Oct 31 13:48:37 2003 Subject: [Image-SIG] Problem reading PNG image In-Reply-To: <59F23DF1-0BAB-11D8-8AA8-000A95686CD8@redivi.com> References: <6EB84633-0BAA-11D8-B1DA-000393829ED2@sas.com> <59F23DF1-0BAB-11D8-8AA8-000A95686CD8@redivi.com> Message-ID: On Friday 31 October 2003 08:05 am, Bob Ippolito wrote: > On Oct 31, 2003, at 8:59 AM, Kevin D. Smith wrote: > > I have some images generated by the dvi2bitmap program that don't seem > > to work in PIL. PIL gives me the size correctly, but if I try to do > > anything with it (e.g. getbbox), I get an IOError in the load method. > > See the attached image as an example. > > I can reproduce this problem (OS X 10.3, PIL compiled with libtiff, > libjpeg, libpng, freetype against vendor Python 2.3). I'm not sure > what the solution is, but the OS itself reads the png just fine (I see > it inline in your message). As documented, PIL does *not* support all PNG files, only non-interlaced ones, IIRC. The bevavior you described is consistent with this limitation. PIL doesn't actually try to read image data immediately, but only when needed -- which is why you get the error afterwards. I'm pretty sure that IOError is in fact what it throws when this happens, though it probably ought to throw something more descriptive. Anyway, I have a small collection of PIL-incompatible PNG files I use for testing failure modes, which gives me, e.g.: >>> q = p.convert('RGB') Traceback (most recent call last): File "", line 1, in ? File "/usr/local/narya/lib/python2.1/site-packages/PIL/Image.py", line 439, in convert self.load() File "/usr/local/narya/lib/python2.1/site-packages/PIL/ImageFile.py", line 166, in load raise IOError, "decoder error %d when reading image file" % e IOError: decoder error -3 when reading image file As I see it, you have three choices: 1) Avoid these types of image (use something else to convert them to a PIL safe format). Probably easiest, if you have control over which images are used. 2) Fix PIL's PNG reader so that it does all PNGs (which would, of course, help more than just you!). 3) Put an error trap in your program and communicate the error (with perhaps more useful behavior) to the user. This'll do in a pinch, if you need it to work generally -- and unsupported PNG format images aren't the only unreadable image you might run into. Cheers, Terry -- Terry Hancock ( hancock at anansispaceworks.com ) Anansi Spaceworks http://www.anansispaceworks.com From janssen at parc.com Fri Oct 31 20:56:27 2003 From: janssen at parc.com (Bill Janssen) Date: Fri Oct 31 20:57:04 2003 Subject: [Image-SIG] PIL anti-aliasing issue on Opteron with Suse 8.2 Linux Message-ID: <03Oct31.175637pst."58611"@synergy1.parc.xerox.com> I've been trying some PIL operations on a new 64-bit Opteron running Suse 8.2. It more or less works, but I've found one odd failure mode. I read a TIFF file in, mode == 'P' or '1', then convert it to RGB, then scale that version to 1/10 the original size, using Image.ANTIALIAS. The result is all black, though the image is mainly white. If I use Image.BICUBIC, or Image.BILINEAR, or anything else, the reduced-size image looks right. It just fails with Image.ANTIALIAS. I don't know whether this is a 64-bit issue, a little-endian issue (I usually work on Suns or Macs), a gcc 3.3 issue, or just what. Any ideas would be much appreciated. Bill From janssen at parc.com Wed Oct 29 02:24:39 2003 From: janssen at parc.com (janssen) Date: Tue Nov 4 00:22:39 2003 Subject: [Image-SIG] PIL 1.1.4 and Python 2.3 on Mac OS X 10.3? Message-ID: <20031029072439.07E821BE55A@wolfe.parc.com> I've just upgraded my Mac to 10.3, and I'm trying to install PIL 1.1.4 under /usr/bin/python, which is now 2.3. Build seems to go alright. But no soap -- I keep getting the following error: % /usr/bin/python Python 2.3 (#1, Sep 13 2003, 00:49:11) [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import Image Fatal Python error: Interpreter not initialized (version mismatch?) Abort % Anyone know the issue? Bill