From pas@xis.xerox.com Fri Apr 2 23:00:04 1999 From: pas@xis.xerox.com (Perry Stoll) Date: Fri, 2 Apr 1999 18:00:04 -0500 Subject: [Image-SIG] some small patches Message-ID: <000f01be7d5c$99e15fe0$4a4df60d@nara.xis.xerox.com> This is a multi-part message in MIME format. ------=_NextPart_000_0009_01BE7D32.A2DFB800 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Here are a couple of small patches, one for TiffImagePlugin.py and one for ImageTk.py. They should be pretty obvious. -Perry ------=_NextPart_000_0009_01BE7D32.A2DFB800 Content-Type: application/octet-stream; name="TiffImagePlugin.py.patch" Content-Disposition: attachment; filename="TiffImagePlugin.py.patch" Content-Transfer-Encoding: base64 KioqIFRpZmZJbWFnZVBsdWdpbi5weS5vcmlnCUZyaSBBcHIgMDIgMTg6NDE6MjUgMTk5OQotLS0g VGlmZkltYWdlUGx1Z2luLnB5CUZyaSBBcHIgMDIgMTg6NDM6MDEgMTk5OQoqKioqKioqKioqKioq KioKKioqIDI4MywyOTIgKioqKgogICAgICAgICAgZm9yIGkgaW4gcmFuZ2UoMCwgbGVuKGRhdGEp LCA4KToKICAgICAgICAgICAgICBudW0gICA9IHNlbGYuaTMyKGRhdGFbaTppKzRdKQogICAgICAg ICAgICAgIGRlbm9tID0gc2VsZi5pMzIoZGF0YVtpKzQ6aSs4XSkKISAgICAgICAgIGlmIGRlbm9t ID09IDA6CiEgICAgICAgICAgICAgbC5hcHBlbmQoMS4wKQohICAgICAgICAgZWxzZToKISAgICAg ICAgICAgICBsLmFwcGVuZChmbG9hdChudW0pL2Zsb2F0KGRlbm9tKSkKICAgICAgICAgIHJldHVy biB0dXBsZShsKQogICAgICBUWVBFU1s1XSA9ICg4LCB1bnBhY2tSYXRpb25hbCkKICAKLS0tIDI4 MywyOTIgLS0tLQogICAgICAgICAgZm9yIGkgaW4gcmFuZ2UoMCwgbGVuKGRhdGEpLCA4KToKICAg ICAgICAgICAgICBudW0gICA9IHNlbGYuaTMyKGRhdGFbaTppKzRdKQogICAgICAgICAgICAgIGRl bm9tID0gc2VsZi5pMzIoZGF0YVtpKzQ6aSs4XSkKISAgICAgICAgICAgICBpZiBkZW5vbSA9PSAw OgohICAgICAgICAgICAgICAgICBsLmFwcGVuZCgxLjApCiEgICAgICAgICAgICAgZWxzZToKISAg ICAgICAgICAgICAgICAgbC5hcHBlbmQoZmxvYXQobnVtKS9mbG9hdChkZW5vbSkpCiAgICAgICAg ICByZXR1cm4gdHVwbGUobCkKICAgICAgVFlQRVNbNV0gPSAoOCwgdW5wYWNrUmF0aW9uYWwpCiAg Cg== ------=_NextPart_000_0009_01BE7D32.A2DFB800 Content-Type: application/octet-stream; name="ImageTk.py.patch" Content-Disposition: attachment; filename="ImageTk.py.patch" Content-Transfer-Encoding: base64 KioqIEltYWdlVGsucHkub3JpZwlGcmkgQXByIDAyIDE4OjQ1OjI3IDE5OTkKLS0tIEltYWdlVGsu cHkJRnJpIEFwciAwMiAxODo0NTozNCAxOTk5CioqKioqKioqKioqKioqKgoqKiogOTAsOTYgKioq KgogIAkgICAga3dbJ21hc3RlciddLnRrLmNhbGwoJ3BhY2thZ2UnLCAncmVxdWlyZScsICdUa2lt YWdpbmcnKQogIAllbHNlOgogIAkgICAgaWYgVGtpbnRlci5fZGVmYXVsdF9yb290IGlzIE5vbmU6 CiEgCQlUaygpLnRrLmNhbGwoJ3BhY2thZ2UnLCAncmVxdWlyZScsICdUa2ltYWdpbmcnKQogIAkg ICAgZWxzZToKICAJCVRraW50ZXIuX2RlZmF1bHRfcm9vdC50ay5jYWxsKCdwYWNrYWdlJywgJ3Jl cXVpcmUnLCAnVGtpbWFnaW5nJykKICAKLS0tIDkwLDk2IC0tLS0KICAJICAgIGt3WydtYXN0ZXIn XS50ay5jYWxsKCdwYWNrYWdlJywgJ3JlcXVpcmUnLCAnVGtpbWFnaW5nJykKICAJZWxzZToKICAJ ICAgIGlmIFRraW50ZXIuX2RlZmF1bHRfcm9vdCBpcyBOb25lOgohIAkJVGtpbnRlci5UaygpLnRr LmNhbGwoJ3BhY2thZ2UnLCAncmVxdWlyZScsICdUa2ltYWdpbmcnKQogIAkgICAgZWxzZToKICAJ CVRraW50ZXIuX2RlZmF1bHRfcm9vdC50ay5jYWxsKCdwYWNrYWdlJywgJ3JlcXVpcmUnLCAnVGtp bWFnaW5nJykKICAK ------=_NextPart_000_0009_01BE7D32.A2DFB800-- From Kevin Cazabon" This is a multi-part message in MIME format. ------=_NextPart_000_000D_01BE7EF7.30AE3E20 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Just wondering if there's plans to 'upgrade' the ImageDraw class to work = properly on images with modes other than '1', 'L', and 'P'? There's some 'simple' fixes for a few of the functions, which I've been = using, but it would be much easier to have them built into the module. For text, I've been using the ImageDraw class to put type on a '1' mode = (black/white) file the same size as my real image. I then create an = Image.new (mode 'RGB') with the background of the color I want my text = to be (again, the same size as my original), and combine them using the = text image as an alpha channel/mask. For lines, I've simply been pasting an Image.new with the correct = size/shape/color on top of the original, but it only works easily for = horizontal/vertical lines. I would have to do the same masking = procedure as above for diagonal lines. My big problem with these procedures is that my 'normal' image size is = between 20-500MB... and when you start having THREE images in memory = (image, mask, and colored background), it's not ideal... even with = 512MB of RAM. Any other suggestions? Kevin Cazabon, kcaza@cymbolic.com kcazabon@rogers.wave.ca ------=_NextPart_000_000D_01BE7EF7.30AE3E20 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Just wondering if there's plans to 'upgrade' the = ImageDraw=20 class to work properly on images with modes other than '1', 'L', and=20 'P'?
 
There's some 'simple' fixes for a few of the = functions, which=20 I've been using, but it would be much easier to have them built into the = module.
 
For text, I've been using the ImageDraw class to put = type on a=20 '1' mode (black/white) file the same size as my real image.  I then = create=20 an Image.new (mode 'RGB') with the background of the color I want my = text to be=20 (again, the same size as my original), and combine them using the text = image as=20 an alpha channel/mask.
 
For lines, I've simply been pasting an Image.new = with the=20 correct size/shape/color on top of the original, but it only works = easily for=20 horizontal/vertical lines.  I would have to do the same masking = procedure=20 as above for diagonal lines.
 
My big problem with these procedures is that my = 'normal' image=20 size is between 20-500MB...  and when you start having THREE images = in=20 memory (image, mask, and colored background), it's not ideal...  = even with=20 512MB of RAM.
 
Any other suggestions?
 
Kevin Cazabon,
kcaza@cymbolic.com
kcazabon@rogers.wave.ca
 
 
------=_NextPart_000_000D_01BE7EF7.30AE3E20-- From jonathan.gilligan@vanderbilt.edu Tue Apr 6 19:52:25 1999 From: jonathan.gilligan@vanderbilt.edu (Jonathan M. Gilligan) Date: Tue, 06 Apr 1999 11:52:25 -0700 Subject: [Image-SIG] Req: Help building PIL 1.0b1 under Win32 Message-ID: <4.1.19990406114722.00c7e580@g.mail.vanderbilt.edu> I have tried to build PIL 1.0b1 with Microsoft Visual C++ 6.0 and although everything builds just fine, I can't get the Tk part to work. If I try to run the "viewer.py" program in the scripts directory, I keep getting TclError: invalid command name "PyImagingPhoto". I have rebuilt the _tkinter.dll module with WITH_PIL and WITH_APPINIT defined, linking it with tkImaging.c and moved it to the Python/DLLs directory. I am using Tcl/Tk 8.0.5 and Python 1.5.1. Can anyone offer any suggestions? Thanks, Jonathan From pas@xis.xerox.com Tue Apr 6 18:37:01 1999 From: pas@xis.xerox.com (Perry Stoll) Date: Tue, 6 Apr 1999 13:37:01 -0400 Subject: [Image-SIG] Req: Help building PIL 1.0b1 under Win32 Message-ID: <007a01be8054$1b5fbd60$4a4df60d@nara.xis.xerox.com> Take a look at Dave Ascher's page: http://starship.python.net/crew/da/PIL/ I think his patch is what you're looking for. -Perry -----Original Message----- From: Jonathan M. Gilligan To: ** PyImage ** Cc: Jonathan M. Gilligan Date: Tuesday, April 06, 1999 1:12 PM Subject: [Image-SIG] Req: Help building PIL 1.0b1 under Win32 >I have tried to build PIL 1.0b1 with Microsoft Visual C++ 6.0 and although >everything builds just fine, I can't get the Tk part to work. If I try to >run the "viewer.py" program in the scripts directory, I keep getting >TclError: invalid command name "PyImagingPhoto". I have rebuilt the >_tkinter.dll module with WITH_PIL and WITH_APPINIT defined, linking it with >tkImaging.c and moved it to the Python/DLLs directory. I am using Tcl/Tk >8.0.5 and Python 1.5.1. > >Can anyone offer any suggestions? > >Thanks, >Jonathan > >_______________________________________________ >Image-SIG maillist - Image-SIG@python.org >http://www.python.org/mailman/listinfo/image-sig > > From trigg@parc.xerox.com Wed Apr 7 20:40:20 1999 From: trigg@parc.xerox.com (Randy Trigg) Date: Wed, 7 Apr 1999 12:40:20 PDT Subject: [Image-SIG] PIL: Saving as pdf gives Key error Message-ID: <370BB4A4.39B4AAD6@parc.xerox.com> Hi. I'm running the 1.0b1 release of Pil on windows NT. I can open images of various formats, but I'm having trouble saving as pdf. I get a Key error when Image.py makes the call: SAVE[string.upper(format)](self, fp, filename) KeyError: PDF Any ideas what's going on? Thanks in advance, - Randy Trigg From fredrik@pythonware.com Wed Apr 14 16:32:37 1999 From: fredrik@pythonware.com (Fredrik Lundh) Date: Wed, 14 Apr 1999 17:32:37 +0200 Subject: [Image-SIG] PIL: Saving as pdf gives Key error References: <370BB4A4.39B4AAD6@parc.xerox.com> Message-ID: <00c301be868c$0a04c220$f29b12c2@pythonware.com> > I'm running the 1.0b1 release of Pil on windows NT. I can open images > of various formats, but I'm having trouble saving as pdf. I get a Key > error when Image.py makes the call: > > SAVE[string.upper(format)](self, fp, filename) > > KeyError: PDF > > Any ideas what's going on? works for me. the following will show you if all drivers are correctly loaded: >>> import Image >>> Image.init() >>> Image.SAVE.keys() ['PNG', 'PDF', 'IM', 'PPM', 'BMP', 'GIF', 'XBM', 'MSP', 'JPEG', 'EPS', 'DES', 'TIFF'] if you don't get the same results, your installation is broken. ... btw, I just noticed that the PDF driver doesn't work for "L" images. "/DctDecode" should be "/DCTDecode". might be problems with "RGB" and "CMYK" images too -- I'll fix that in 1.0 final. Cheers /F fredrik@pythonware.com http://www.pythonware.com From fredrik@pythonware.com Wed Apr 14 20:23:24 1999 From: fredrik@pythonware.com (Fredrik Lundh) Date: Wed, 14 Apr 1999 21:23:24 +0200 Subject: [Image-SIG] Image file to numeric representation References: Message-ID: <00b501be86ac$5bf76770$f29b12c2@pythonware.com> Ken N. Seergobin wrote: > I have what is probably a very simple question... > > Once an image has been opened, how does one go about converting > the internal format to a numeric representation that can > be analyzed? As an example, I would like to assess the pairwise > correlation of various images. here's one way to do it: im = Image.open("data.pgm") data = list(im.getdata()) data is now a "flattened" list containing the pixels for the first row, followed by the second row, etc. also see the various posts on PIL/NumPy integration. Cheers /F fredrik@pythonware.com http://www.pythonware.com From fredrik@pythonware.com Wed Apr 14 20:19:47 1999 From: fredrik@pythonware.com (Fredrik Lundh) Date: Wed, 14 Apr 1999 21:19:47 +0200 Subject: [Image-SIG] ImageDraw (text) on RGB and CMYK images References: <001001be7f31$ded9e6e0$8bba0cce@linuxsrv.ns.bc.rogers.wave.ca> Message-ID: <00b401be86ac$5bb5a380$f29b12c2@pythonware.com> Kevin Cazabon wrote: > Just wondering if there's plans to 'upgrade' the ImageDraw class to work > properly on images with modes other than '1', 'L', and 'P'? what platform are you using? afaik, PIL has supported drawing in RGB, RGBA, and CMYK images for quite a while, but I recently got a bunch of patches for big-endian platforms... Cheers /F fredrik@pythonware.com http://www.pythonware.com From fredrik@pythonware.com Thu Apr 15 11:07:19 1999 From: fredrik@pythonware.com (Fredrik Lundh) Date: Thu, 15 Apr 1999 12:07:19 +0200 Subject: [Image-SIG] ANN: PIL 1.0b1 binaries for Windows References: <001001be7f31$ded9e6e0$8bba0cce@linuxsrv.ns.bc.rogers.wave.ca> <00b401be86ac$5bb5a380$f29b12c2@pythonware.com> Message-ID: <009e01be8727$c063c1b0$f29b12c2@pythonware.com> Greetings, due to popular demand, I just uploaded a ZIP-file with a complete PIL 1.0b1 for Windows. this has only been tested with our py15-distribution, but it's likely to work with the standard distribution too. get your copy from: http://www.pythonware.com/downloads.htm Cheers /F fredrik@pythonware.com http://www.pythonware.com From trigg@parc.xerox.com Fri Apr 16 19:57:50 1999 From: trigg@parc.xerox.com (Randy Trigg) Date: Fri, 16 Apr 1999 11:57:50 PDT Subject: [Image-SIG] PIL: Saving as pdf gives Key error In-Reply-To: <00c301be868c$0a04c220$f29b12c2@pythonware.com> References: <370BB4A4.39B4AAD6@parc.xerox.com> Message-ID: >works for me. the following will show you if >all drivers are correctly loaded: > >>>> import Image >>>> Image.init() >>>> Image.SAVE.keys() >['PNG', 'PDF', 'IM', 'PPM', 'BMP', 'GIF', 'XBM', 'MSP', 'JPEG', 'EPS', >'DES', 'TIFF'] > >if you don't get the same results, your installation >is broken. > >... > >btw, I just noticed that the PDF driver doesn't work >for "L" images. "/DctDecode" should be "/DCTDecode". >might be problems with "RGB" and "CMYK" images too >-- I'll fix that in 1.0 final. Thanks Fredrik for your help. I tried again, this time starting with the call to Image.init (that wasn't in the tutorial docs). That let me save as PDF. As you noted, it seems to have trouble with "L" mode images (I was converting a jpeg). So I tried converting a tif image instead (mode "1"). This time I got a huge pdf file (16Meg), but when I open with Acrobat reader, it comes up blank. Have you ever seen that behavior? Thanks again, - Randy From piers@cs.su.oz.au Sat Apr 17 04:30:04 1999 From: piers@cs.su.oz.au (Piers Lauder) Date: Sat, 17 Apr 1999 13:30:04 +1000 Subject: [Image-SIG] PIL 1.0b1 bug report Message-ID: <199904170334.XAA06683@python.org> I had to add the following code just before the last #include in each of Jpeg{En|De}code.c #undef METHODDEF #define METHODDEF(A) static A #undef GLOBAL #define GLOBAL(A) A Without that, the macros produced code of the form static (void) XXX and I got these errors: JpegEncode.c:40: parse error before `void' JpegEncode.c:46: parse error before `boolean' JpegEncode.c:68: parse error before `void' JpegEncode.c:72: `cinfo' undeclared here (not in a function) JpegEncode.c:72: warning: data definition has no type or storage class JpegEncode.c:73: parse error before `->' JpegEncode.c:74: parse error before `->' JpegEncode.c:74: conflicting types for `longjmp' /usr/include/setjmp.h:63: previous declaration of `longjmp' JpegEncode.c:74: warning: data definition has no type or storage class JpegEncode.c: In function `ImagingJpegEncode': JpegEncode.c:99: warning: assignment makes pointer from integer without a cast make: *** [JpegEncode.o] Error 1 System details: # s libImaging ; gcc -v Reading specs from /gnu/usr/lib/gcc-lib/sparc-sun-solaris2.6/2.8.1/specs gcc version 2.8.1 # s libImaging ; uname -a SunOS staff 5.6 Generic_105181-05 sun4u sparc SUNW,Ultra-2 From piers@cs.su.oz.au Mon Apr 19 01:03:05 1999 From: piers@cs.su.oz.au (Piers Lauder) Date: Mon, 19 Apr 1999 10:03:05 +1000 Subject: [Image-SIG] PIL 1.0b1 Message-ID: <199904190006.UAA02844@python.org> There is an error in the definition of "new" in Image.py the distributed version has def new(mode, size, color = 0): "Create a new image" if color is None: it should be: def new(mode, size, color = None): After that fix, I get an error I can't explain: (I uncommented the print statement in _getdecoder()) ('1',) ('1', '1') Traceback (innermost last): File "/local/usr/bin/facemail", line 4, in ? try: exec "import %s; %s.main(%s.args())" % (mod, mod, mod) File "", line 1, in ? File "/local/usr/lib/facemail/facemail.py", line 680, in main UpdateScan() File "/local/usr/lib/facemail/facemail.py", line 738, in UpdateScan UpdateFaces() File "/local/usr/lib/facemail/facemail.py", line 219, in UpdateFaces newmail = _UpdateFaces(newmail) File "/local/usr/lib/facemail/facemail.py", line 338, in _UpdateFaces c = FaceFrames[row][col].configure(msg) File "/local/usr/lib/facemail/Face.py", line 132, in configure self._details() File "/local/usr/lib/facemail/Face.py", line 246, in _details self.face = getface.GetFaceImage(addr, File "/local/usr/lib/facemail/getface.py", line 186, in GetFaceImage tkim = _makeface(addr, face, file) File "/local/usr/lib/facemail/getface.py", line 231, in _makeface im = Image.fromstring('1', (width, height), bitmap, 'raw', '1') File "/usr/local/lib/python1.5/site-packages/PIL/Image.py", line 869, in fromstring im.fromstring(data, decoder_name, args) File "/usr/local/lib/python1.5/site-packages/PIL/Image.py", line 364, in fromstring d = _getdecoder(self.mode, decoder_name, args) File "/usr/local/lib/python1.5/site-packages/PIL/Image.py", line 225, in _getdecoder return apply(decoder, (mode,) + args + extra) TypeError: illegal argument type for built-in operation (I stupidly trashed the previous version of PIL, so now I'm in a bit of a bind :-) Anyone have a fix? From steve@websentric.com Mon Apr 19 08:14:09 1999 From: steve@websentric.com (Steve Purcell) Date: Mon, 19 Apr 1999 07:14:09 +0000 Subject: [Image-SIG] PIL 1.0b1 References: <199904190006.UAA02844@python.org> Message-ID: <371AD7C1.16D3A41B@websentric.com> Piers Lauder wrote: > > There is an error in the definition of "new" in Image.py > the distributed version has > def new(mode, size, color = 0): > "Create a new image" > > if color is None: > > it should be: > def new(mode, size, color = None): No it shouldn't. '0' is the RGB for black, which the documentation states is the default fill.colour for new images. 'None' means don't initialise the image, which sounds like asking for trouble. :-) -- Steve Purcell | Stunt Programmer & WebSentric Software GmbH | Chief Mad Scientist From piers@cs.su.oz.au Mon Apr 19 08:43:56 1999 From: piers@cs.su.oz.au (Piers Lauder) Date: Mon, 19 Apr 1999 17:43:56 +1000 Subject: [Image-SIG] PIL 1.0b1 References: <199904190006.UAA02844@python.org> <371AD7C1.16D3A41B@websentric.com> Message-ID: <129.78.8.1.126.14461.924508149.426.16025> On Mon, 19 Apr 1999 07:14:09 +0000, Steve Purcell wrote: > > Piers Lauder wrote: > > > > There is an error in the definition of "new" in Image.py > > the distributed version has > > def new(mode, size, color = 0): > > "Create a new image" > > > > if color is None: > > > > it should be: > > def new(mode, size, color = None): > > No it shouldn't. '0' is the RGB for black, which the documentation > states is the default fill.colour for new images. 'None' means don't > initialise the image, which sounds like asking for trouble. :-) I stand corrected :-) Here's the error I though I was fixing: : s ; facemail -w Traceback (innermost last): File "/local/usr/bin/facemail", line 4, in ? try: exec "import %s; %s.main(%s.args())" % (mod, mod, mod) File "", line 1, in ? File "/local/usr/lib/facemail/facemail.py", line 678, in main getface.InitFaceImage(root) File "/local/usr/lib/facemail/getface.py", line 65, in InitFaceImage WhiteFaceImage = ImageTk.BitmapImage(Image.new('1', (width, height))) File "/usr/local/lib/python1.5/site-packages/PIL/Image.py", line 855, in new return Image()._makeself(core.fill(mode, size, color)) SystemError: new style getargs format but argument is not a tuple Anything obvious to look for? (this program works fine with the PIL 0.3b1 release.) From fredrik@pythonware.com Mon Apr 19 09:29:47 1999 From: fredrik@pythonware.com (Fredrik Lundh) Date: Mon, 19 Apr 1999 10:29:47 +0200 Subject: [Image-SIG] PIL 1.0b1 References: <199904190006.UAA02844@python.org> Message-ID: <017501be8a3e$da18dae0$f29b12c2@pythonware.com> Piers Lauder wrote: > There is an error in the definition of "new" in Image.py > the distributed version has > def new(mode, size, color = 0): > "Create a new image" > if color is None: > > it should be: > def new(mode, size, color = None): this is not a bug; for details on the intended behaviour, see the description of "new" at: http://www.pythonware.com/library/pil/handbook/image.htm > File "/local/usr/lib/facemail/getface.py", line 231, in _makeface > im = Image.fromstring('1', (width, height), bitmap, 'raw', '1') > File "/usr/local/lib/python1.5/site-packages/PIL/Image.py", line 869, in fromstring > im.fromstring(data, decoder_name, args) > File "/usr/local/lib/python1.5/site-packages/PIL/Image.py", line 364, in fromstring > d = _getdecoder(self.mode, decoder_name, args) > File "/usr/local/lib/python1.5/site-packages/PIL/Image.py", line 225, in _getdecoder > return apply(decoder, (mode,) + args + extra) > TypeError: illegal argument type for built-in operation hmm. I cannot repeat this problem. does the following snippet work for you: import Image bitmap = (chr(0xaa)+chr(0x55))*4 im = Image.fromstring("1", (8, 8), bitmap, "raw", "1") if it doesn't, you may have a build/configuration problem (e.g. using 0.3b3's script library with 1.0b1's _imaging module is likely to result in problems like this) Cheers /F fredrik@pythonware.com http://www.pythonware.com From fredrik@pythonware.com Mon Apr 19 09:44:16 1999 From: fredrik@pythonware.com (Fredrik Lundh) Date: Mon, 19 Apr 1999 10:44:16 +0200 Subject: [Image-SIG] PIL 1.0b1 bug report Message-ID: <01d901be8a40$cf83e460$f29b12c2@pythonware.com> Piers Lauder wrote: > I had to add the following code just before the last #include > in each of Jpeg{En|De}code.c > #undef METHODDEF > #define METHODDEF(A) static A > #undef GLOBAL > #define GLOBAL(A) A > > Without that, the macros produced code of the form > static (void) XXX this is not a bug. you're using an old version of the JPEG libraries (older than 6a, which is the oldest version listed in the PIL README). recent versions of the JPEG library can be obtained from: http://www.ijg.org/ (but now that you've fixed this, version 6 should work just as well as 6a!) Cheers /F fredrik@pythonware.com http://www.pythonware.com From KCAZA@cymbolic.com Wed Apr 21 00:35:46 1999 From: KCAZA@cymbolic.com (Kevin Cazabon) Date: Tue, 20 Apr 1999 16:35:46 -0700 Subject: [Image-SIG] PIL, Python and memory issues.... HELP! Message-ID: I've written a handy program for splitting up large images into separate panels for printing (including overlap and crop marks, etc), but it's been rendered basically useless due to the memory problems I'm running into. Normally, images that would require being broken up into panels for my application would be in the 300MB-1.5GB range (which is huge, but I'm dealing with a continuous-tone photographic imagesetter at 305dpi which prints up to 50"x100"). Where are the memory bottlenecks likely to be: in Python itself, or in PIL? I'm finding that you basically need to be able to hold the entire image in RAM, plus OS, etc. It doesn't seem to be effectively using the virtual memory on my Win98 or NT test machines, or there's an arbitrary memory limit somewhere in the code. I'm dumping everything I can from memory as I go, but it still has problems. Even processing a 175MB file on an NT machine with 128MB of RAM, and 512MB of VM didn't work (Typically, I will suggest using a 512MB+ machine for real images, but this is sufficient for testing. And yes, I've tested it successfully with 60MB images). Anyone have suggestions for using Python/PIL with such large images, short of parsing the files pixel for pixel (or line by line)? I'd hate to have to start over again in C, because Python is so convenient for this type of thing (if not amazingly fast). Thanks, Kevin Cazabon. From da@ski.org Wed Apr 21 06:00:40 1999 From: da@ski.org (David Ascher) Date: Tue, 20 Apr 1999 22:00:40 -0700 (PDT) Subject: [Image-SIG] PIL, Python and memory issues.... HELP! In-Reply-To: Message-ID: On Tue, 20 Apr 1999, Kevin Cazabon wrote: > Normally, images that would require being broken up into panels for my > application would be in the 300MB-1.5GB range (which is huge, but I'm > dealing with a continuous-tone photographic imagesetter at 305dpi which > prints up to 50"x100"). Wow. More usefully, I wonder if perhaps the format used by PIL internally isn't VM-friendly. I also wonder if maybe a hack to PIL which used mmap() would be a solution which would make it VM-friendly. If so, it might be easier than to recode it in C (and possible would speed up PIL for 'smaller' images as well. A useful paper on mmap is found at: http://www.zen-pharaohs.com/postscript/mmap.ps and the mmapfile module (not needed for this, but while I'm at it) is at ftp://starship.python.net/pub/crew/amk/new/ --david PS: In general, I think that integrating mmap into Python data structures would be a GoodThing (e.g. for NumPy). From fredrik@pythonware.com Wed Apr 21 11:15:59 1999 From: fredrik@pythonware.com (Fredrik Lundh) Date: Wed, 21 Apr 1999 12:15:59 +0200 Subject: [Image-SIG] PIL, Python and memory issues.... HELP! References: Message-ID: <008e01be8bdf$faf91bb0$f29b12c2@pythonware.com> Kevin wrote: > Where are the memory bottlenecks likely to be: in Python itself, > or in PIL? I'm finding that you basically need to be able to hold the > entire image in RAM, plus OS, etc. It doesn't seem to be effectively > using the virtual memory on my Win98 or NT test machines, or there's > an arbitrary memory limit somewhere in the code. PIL is copying all data to an RAM image memory, except under a few special circumstances (more on those later). it allocates one byte per pixel for "1", "L", and "P" images, and four bytes per pixel for all other formats. so I suspect the problem is on the operating system side (in my experience, most operating systems tend to give up when a single process attempts to grow much larger than the physical memory -- and to thrash heavily long before that...) > Anyone have suggestions for using Python/PIL with such large images, > short of parsing the files pixel for pixel (or line by line)? I'd hate to > have to start over again in C, because Python is so convenient for this > type of thing (if not amazingly fast). well, here's a trick that might work for you. try this: >>> import Image >>> i = Image.open() >>> i.size (512, 512) >>> i.tile [('raw', (0, 0, 512, 512), 128, ('RGB', 0, 1))] the tile attribute contains a list of "tile descriptors", which are used to load the image from file. -- the first descriptor item should be "raw" -- if it isn't, the file is compressed, and can most likely not be read in pieces. -- the second item is the tile extent (a rectangle) -- the third item is the offset from the start of the file to the data for that tile. -- the final item is a list of arguments to the decoder. the interesting thing is that you can change these parameters just after you've opened the file. for example, to read only the first 128 lines of this file, do as follows: >>> i.size = (512, 128) >>> i.tile = [('raw', (0, 0, 512, 128), 128, ('RGB', 0, 1))] >>> i.load() (the call to load explicitly reads the data from disk) to read the following 128 lines, you must open the file again, and modify also the offset argument. >>> i = Image.open(...) >>> i.size = (512, 128) >>> i.tile = [('raw', (0, 0, 512, 128), 128 + 128*(3*512), ('RGB', 0, 1))] and so on. writing a small loop to do this shouldn't be that difficult. ... David wrote: > I also wonder if maybe a hack to PIL which used mmap() would be a > solution which would make it VM-friendly. If so, it might be easier > than to recode it in C (and possible would speed up PIL for 'smaller' > images as well. PIL already contains such a hack, which is enabled under these circumstances: -- you're on win95 or winNT (haven't had time to finish the unix implementation yet, sorry). -- you're opening an image using the "raw" decoder. -- the image has an internal format which is compatible with PIL's internal pixel layout for that mode. or in other words, the image must be "L", "P", "RGBX", "RGBA", or "CMYK", and be stored in an uncompressed format. ... finally, I should mention that future versions of PIL (post 1.0) will include much better support for huge images, among other things. in that process, we're moving to a more Ghostscript-like licensing strategy. more on this later. Cheers /F From barry@scottb.demon.co.uk Mon Apr 26 09:31:04 1999 From: barry@scottb.demon.co.uk (Barry Scott) Date: Mon, 26 Apr 1999 09:31:04 +0100 Subject: [Image-SIG] When will the next PIL beta be released? Message-ID: <001a01be8fbf$1f9ab270$060110ac@private> Fredrik, Its nearly two months since I last inquired. What progress has been made to release another kit? What is are your current plans for PIL? Personally I'm looking for faster font handling in PIL. And I'm willing to work on the code to do this. Barry From ggonzalez@sysde.co.cr Wed Apr 28 18:13:09 1999 From: ggonzalez@sysde.co.cr (Gerardo Alberto =?iso-8859-1?Q?Gonz=E1lez?= Urtecho) Date: Wed, 28 Apr 1999 11:13:09 -0600 Subject: [Image-SIG] Hi... Message-ID: <372741A5.491DF5E5@sysde.co.cr> This is a multi-part message in MIME format. --------------678CF7E0A1E0EF8DA23BFCDB Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, I am newer in Python, and I am doing in a C module. I finished it. I need work with this module in Python, but I don't know how link it to Python. Someone that want teach me??... THANKS... --------------678CF7E0A1E0EF8DA23BFCDB Content-Type: text/x-vcard; charset=us-ascii; name="ggonzalez.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Gerardo Alberto González Urtecho Content-Disposition: attachment; filename="ggonzalez.vcf" begin:vcard n:González Urtecho;Gerardo Alberto tel;fax:(506) 2932812 tel;home:(506) 4423012 tel;work:(506) 2932864 x-mozilla-html:FALSE url:www.sysde.co.cr org:SYSDE, Financial Solutions;R&D Dept. version:2.1 email;internet:ggonzalez@sysde.co.cr title:Analista Consultor adr;quoted-printable:;;Zona Franca Metropolitana,=0D=0ABarreal de Heredia,=0D=0ASan Jos=E9=0D=0A12133-1000=0D=0ACosta Rica;;;;Costa Rica fn:Gerardo Alberto González Urtecho end:vcard --------------678CF7E0A1E0EF8DA23BFCDB-- From hannu@trust.ee Wed Apr 28 21:08:42 1999 From: hannu@trust.ee (Hannu Krosing) Date: Wed, 28 Apr 1999 23:08:42 +0300 Subject: [Image-SIG] Hi... References: <372741A5.491DF5E5@sysde.co.cr> Message-ID: <37276ACA.35790522@trust.ee> Gerardo Alberto González Urtecho wrote: > > Hi, I am newer in Python, and I am doing in a C module. I finished it. I > need work with this module in Python, but I don't know how link it to > Python. Someone that want teach me??... It's all in the "Extending and Embedding Python" manual: http://www.python.org/doc/ext/ext.html ------------------- Hannu From ggonzalez@sysde.co.cr Wed Apr 28 22:25:31 1999 From: ggonzalez@sysde.co.cr (Gerardo Alberto =?iso-8859-1?Q?Gonz=E1lez?= Urtecho) Date: Wed, 28 Apr 1999 15:25:31 -0600 Subject: [Image-SIG] Hi... References: <372741A5.491DF5E5@sysde.co.cr> <37276ACA.35790522@trust.ee> Message-ID: <37277CCB.8F002C4@sysde.co.cr> Hannu Krosing wrote: > Gerardo Alberto González Urtecho wrote: > > > > Hi, I am newer in Python, and I am doing in a C module. I finished it. I > > need work with this module in Python, but I don't know how link it to > > Python. Someone that want teach me??... > > It's all in the "Extending and Embedding Python" manual: > > http://www.python.org/doc/ext/ext.html > > ------------------- > Hannu Thanks... but I read this document and I could not do anything. Maybe, I don't understand, but the method that explain in the "Extending and Embedding Python" manual, I could not do because the diectories structure is not the same that say the manual. I am work with Windows NT and Python for Windows. I see that Python for Windows work different of Python for Unix. From Fred L. Drake, Jr." References: <372741A5.491DF5E5@sysde.co.cr> <37276ACA.35790522@trust.ee> <37277CCB.8F002C4@sysde.co.cr> Message-ID: <14119.32492.11350.761986@weyr.cnri.reston.va.us> Gerardo Alberto González Urtecho writes: > Thanks... but I read this document and I could not do anything. > Maybe, I don't understand, but the method that explain in the "Extending and > Embedding Python" manual, I could not do because the diectories structure is > not the same that say the manual. > > I am work with Windows NT and Python for Windows. I see that Python for > Windows work different of Python for Unix. Gerardo, I'd love to get a list of specific problems you've found in the Extending and Embedding manual so that I can make corrections. Specific items would also allow me to provide correct information for you. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From hannu@trust.ee Wed Apr 28 23:01:17 1999 From: hannu@trust.ee (Hannu Krosing) Date: Thu, 29 Apr 1999 01:01:17 +0300 Subject: [Image-SIG] Hi... References: <372741A5.491DF5E5@sysde.co.cr> <37276ACA.35790522@trust.ee> <37277CCB.8F002C4@sysde.co.cr> Message-ID: <3727852D.90EAB9E@trust.ee> Gerardo Alberto González Urtecho wrote: > > Hannu Krosing wrote: > > > Gerardo Alberto González Urtecho wrote: > > > > > > Hi, I am newer in Python, and I am doing in a C module. I finished it. I > > > need work with this module in Python, but I don't know how link it to > > > Python. Someone that want teach me??... > > > > It's all in the "Extending and Embedding Python" manual: > > > > http://www.python.org/doc/ext/ext.html > > > > ------------------- > > Hannu > > Thanks... but I read this document and I could not do anything. > Maybe, I don't understand, but the method that explain in the "Extending and > Embedding Python" manual, I could not do because the diectories structure is > not the same that say the manual. > > I am work with Windows NT and Python for Windows. I see that Python for > Windows work different of Python for Unix. > If your module source is ok, then the only thing that has to be done is putting jour sourcein Modules directory and adding a line to setup. I doubt it is any different in windows, but I have no experience doing this in windows, so maybe you are better served if you ask the question in newsgroup comp.lang.python (and explain that you have the problem in Windows) ---------- Hannu From ggonzalez@sysde.co.cr Wed Apr 28 22:57:55 1999 From: ggonzalez@sysde.co.cr (Gerardo Alberto =?iso-8859-1?Q?Gonz=E1lez?= Urtecho) Date: Wed, 28 Apr 1999 15:57:55 -0600 Subject: [Image-SIG] Hi... References: <372741A5.491DF5E5@sysde.co.cr> <37276ACA.35790522@trust.ee> <37277CCB.8F002C4@sysde.co.cr> <14119.32492.11350.761986@weyr.cnri.reston.va.us> Message-ID: <37278463.217EBC15@sysde.co.cr> "Fred L. Drake" wrote: > Gerardo Alberto González Urtecho writes: > > Thanks... but I read this document and I could not do anything. > > Maybe, I don't understand, but the method that explain in the "Extending and > > Embedding Python" manual, I could not do because the diectories structure is > > not the same that say the manual. > > > > I am work with Windows NT and Python for Windows. I see that Python for > > Windows work different of Python for Unix. > > Gerardo, > I'd love to get a list of specific problems you've found in the > Extending and Embedding manual so that I can make corrections. > Specific items would also allow me to provide correct information for > you. > > -Fred > > -- > Fred L. Drake, Jr. > Corporation for National Research Initiatives Thanks.. The problem that I have is that I try to link a C module with Python. I seached in the "Extending and Embedding Python" manual, and in this manual describe two ways. One is use ``Dynamic Loading'' and I did not find it. So, the other way is show in the section 1.5, that is put the sourse of the module in the "Modules" directory, and rebuilt. But I did not find that directory. I don't know if Python for windows is different to Python for Unix, and all Python documentation is to Python for Unix. From da@ski.org Wed Apr 28 23:13:28 1999 From: da@ski.org (David Ascher) Date: Wed, 28 Apr 1999 15:13:28 -0700 (Pacific Daylight Time) Subject: [Image-SIG] Hi... In-Reply-To: <37278463.217EBC15@sysde.co.cr> Message-ID: > The problem that I have is that I try to link a C module with Python. > I seached in the "Extending and Embedding Python" manual, and in this > manual describe two ways. One is use ``Dynamic Loading'' and I did not > find it. So, the other way is show in the section 1.5, that is put the > sourse of the module in the "Modules" directory, and rebuilt. But I > did not find that directory. I don't know if Python for windows is > different to Python for Unix, and all Python documentation is to > Python for Unix. It is indeed quite different. The simplest way I know to build a Python extension module on Windows is to take my "compile.py" program http://starship.python.net/crew/da/compile/ create a Setup file which has the two lines *shared* mymodule mymodule.c and run compile.py on that file. That will create files for Developer Studio (the microsoft compiler) which are then easy to build. Let me know if you have problems with it. --david From Fred L. Drake, Jr." References: <372741A5.491DF5E5@sysde.co.cr> <37276ACA.35790522@trust.ee> <37277CCB.8F002C4@sysde.co.cr> <14119.32492.11350.761986@weyr.cnri.reston.va.us> <37278463.217EBC15@sysde.co.cr> Message-ID: <14119.51024.185561.359597@weyr.cnri.reston.va.us> Gerardo Alberto González Urtecho writes: > The problem that I have is that I try to link a C module with > Python. I seached in the "Extending and Embedding Python" manual, > and in this manual describe two ways. One is use ``Dynamic > Loading'' and I did not find it. So, the other way is show in the > section 1.5, that is put the sourse of the module in the "Modules" > directory, and rebuilt. But I did not find that directory. I don't > know if Python for windows is different to Python for Unix, and all > Python documentation is to Python for Unix. Gerardo, The "Modules" directory is part of the Python source distribution. If you used the installer, you don't have it. I'll try to make that more clear in the extension manual. Instructions on building a DLL on Windows are included in the extension manual in the most recent releases. See the online version at http://www.python.org/doc/ext/building-on-windows.html for information on using the "compile.py" script David Ascher pointer created and mentioned earlier in this thread. If you need further help or find the instructions insufficient, please do not hesitate to ask or otherwise point out limitations to the documentation. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From aziz420@hotmail.com Thu Apr 29 06:38:57 1999 From: aziz420@hotmail.com (Syed Aziz) Date: Wed, 28 Apr 1999 22:38:57 PDT Subject: [Image-SIG] help Message-ID: <19990429053858.9081.qmail@hotmail.com> hi there, I've downloaded the Image file...but how to install it..? Did the unziiping part and copied in my c:\program files\python\ but how can I upload the module? or please tell me where to store the files. Thanks, aZiZ ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com From fredrik@pythonware.com Thu Apr 29 10:43:54 1999 From: fredrik@pythonware.com (Fredrik Lundh) Date: Thu, 29 Apr 1999 11:43:54 +0200 Subject: [Image-SIG] Hi... References: <372741A5.491DF5E5@sysde.co.cr> Message-ID: <00b501be9224$d2c49890$f29b12c2@pythonware.com> > Hi, I am newer in Python, and I am doing in a C module. I finished it. I > need work with this module in Python, but I don't know how link it to > Python. Someone that want teach me??... image-sig@python.org is not a general python help mailing list. see: http://www.python.org/Help.html for a list of valid resources. in this case, comp.lang.python would be your best bet. if you don't have direct access to news, you can access the newsgroup via the mail gateway or http://www.egroups.com/group/python-list/info.html Thanks /F (image-sig administrator) From ferradajj@ornl.gov Fri Apr 30 15:14:50 1999 From: ferradajj@ornl.gov (Juan Ferrada) Date: Fri, 30 Apr 1999 10:14:50 -0400 Subject: [Image-SIG] graphics for Python 1.2 Message-ID: <3.0.32.19990430101446.00698768@tin2.cad.ornl.gov> At Oak Ridge National Laboratory, we developed a chemical process simulation program using C++ that works in a DOS environment. It is a graphic interface and process diagrams are created by putting different icons that are dragged and dropped in the screen. It has worked very nicely for us for the last four years. Four years ago, we were after a scripting language that could simplify the model writing. Each icon (that represents a specif engineering process) can be model using an executable in any language. For example, we use executables written in Fortran, Pascal, Prolog, C, C++ etc and our program launches those executable when they are needed. By using an scripting language the modeling would be simplified. In fact, 4 years ago we downloaded the current version of Python and we integrate it with our code and produce the executable of our application. We called it FLOW. It has been very successful. Many students that do their internship with us have learned the basic principles of Python and some of the classes and objects that we created for our own purpose. After just two weeks of tutorials they are capable of producing their models and run them with the rest of the application. The only problem we have is that when we go from the FLOW graphic interface and want to interact with the user and ask them some question, for example what is the input pressure of your bomb? or what is the diameter of your tank? we go to the traditional black screen of the DOS environment. We would like to improve this by putting, for example, the figure of a pump and show the user the question directly on the graphic. We believe that we could use a graphic library like the one you developed and being able to develop the graphics we want. Is it possible to use your library in the DOS environment? So when we invoke the library, as we do with other libraries that we have developed earlier(from ourlyb import * at the beginning of the program), we can get the desired effects. We downloaded the Python version 1.2, April 1995 and we compiled with our C++ code. We are looking for a library that works with that version so we can invoke the library by simply writing: from graphiclibrary import *, so we don't have to recompiled everything again. Do you think this is possible and if it is how can we get to that library and where we need to put it to make it work. We currently put everything writting in Python in a directory like this: C:\flow\python and every fiel *.py goes there including the libraries. I would really appreciate your help. I have a couple of students working with me that really need this feature. thank you very much Juan J. Ferrada