From friedric@rose.rsoc.rockwell.com Mon Jun 10 17:25:45 1996 From: friedric@rose.rsoc.rockwell.com (Robin Friedrich) Date: Mon, 10 Jun 1996 11:25:45 -0500 Subject: [PYTHON IMAGE-SIG] width height of gif/jpeg files? Message-ID: <199606101625.LAA00648@darwin.rsoc.rockwell.com> What's the quickest way to read the width and height of image files? I want to write a little function to return this info for a bunch of image files. I don't have PIL (yet, I suppose that'll have the answer.) TIA -RObin ================= IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org ================= From da@maigret.cog.brown.edu Mon Jun 10 18:16:26 1996 From: da@maigret.cog.brown.edu (David Ascher) Date: Mon, 10 Jun 1996 13:16:26 -0400 (EDT) Subject: [PYTHON IMAGE-SIG] width height of gif/jpeg files? In-Reply-To: <199606101625.LAA00648@darwin.rsoc.rockwell.com> from "Robin Friedrich" at Jun 10, 96 11:25:45 am Message-ID: <199606101716.NAA13026@maigret> > What's the quickest way to read the width and height of image files? > I want to write a little function to return this info for a bunch of > image files. I don't have PIL (yet, I suppose that'll have the answer.) Definitely the easiest way is to get PIL -- it depends completely on the image format, and if PIL has already worried about that for most image formats you'll encounter. Once you have PIL: >>> import Image >>> i = Image.open('image.gif') >>> i.size (125, 123) --david ================= IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org ================= From fredrik_lundh@ivab.se Mon Jun 10 18:28:01 1996 From: fredrik_lundh@ivab.se (Fredrik Lundh) Date: Mon, 10 Jun 1996 19:28:01 +0200 Subject: [PYTHON IMAGE-SIG] width height of gif/jpeg files? In-Reply-To: <199606101625.LAA00648@darwin.rsoc.rockwell.com> (friedric@rose.rsoc.rockwell.com) Message-ID: <9606101728.AA20358@arnold.image.ivab.se> > What's the quickest way to read the width and height of image files? > I want to write a little function to return this info for a bunch of > image files. I don't have PIL (yet, I suppose that'll have the answer.) Here's the minimal PIL version: import sys, Image for f in sys.argv[1:]: print f, Image.open(f).size When you open a file in PIL, it only parses the file header. The raster data is not read until you try to do something with it, so the above is quite fast, independent of the image size. See the pilfile.py script for a somewhat more polished variant. BTW, you don't have to link with the PIL C extension to use the above feature... /F ================= IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org ================= From friedric@rose.rsoc.rockwell.com Mon Jun 10 19:57:10 1996 From: friedric@rose.rsoc.rockwell.com (Robin Friedrich) Date: Mon, 10 Jun 1996 13:57:10 -0500 Subject: [PYTHON IMAGE-SIG] width height of gif/jpeg files? Message-ID: <199606101857.NAA00795@darwin.rsoc.rockwell.com> |> From Fredrik_Lundh@ivab.se Mon Jun 10 12:31 CDT 1996 |> Date: Mon, 10 Jun 1996 19:28:01 +0200 |> From: Fredrik Lundh |> To: friedric@rose.rsoc.rockwell.com |> Cc: image-sig@python.org |> Subject: Re: [PYTHON IMAGE-SIG] width height of gif/jpeg files? |> Reply-To: fredrik_lundh@ivab.se |> Mime-Version: 1.0 |> |> |> > What's the quickest way to read the width and height of image files? |> > I want to write a little function to return this info for a bunch of |> > image files. I don't have PIL (yet, I suppose that'll have the answer.) |> |> Here's the minimal PIL version: Thanks. I'm new to the Image list so I'm just now dl'ing it. I just needed this needed this for GIF and JPEG as I'm working on web page generation code. ================= IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org ================= From da@maigret.cog.brown.edu Mon Jun 10 20:00:54 1996 From: da@maigret.cog.brown.edu (David Ascher) Date: Mon, 10 Jun 1996 15:00:54 -0400 (EDT) Subject: [PYTHON IMAGE-SIG] width height of gif/jpeg files? In-Reply-To: <199606101857.NAA00795@darwin.rsoc.rockwell.com> from "Robin Friedrich" at Jun 10, 96 01:57:10 pm Message-ID: <199606101900.PAA13368@maigret> > Thanks. I'm new to the Image list so I'm just now dl'ing it. > I just needed this needed this for GIF and JPEG as I'm working on > web page generation code. What you'll want to look at as well is the font stuff, which isn't really there yet, but which I certainly will use for webpage generation stuff. --david ================= IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org ================= From fredrik_lundh@ivab.se Thu Jun 13 09:30:41 1996 From: fredrik_lundh@ivab.se (Fredrik Lundh) Date: Thu, 13 Jun 1996 10:30:41 +0200 Subject: [PYTHON IMAGE-SIG] PIL on Mac, anyone? Message-ID: <9606130830.AA05505@arnold.image.ivab.se> Have anyone compiled PIL on the Mac? If not, are there any volunteers out there with access to a Mac, a decent compiler and some spare time? Thanks /F ================= IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org ================= From zack@lems.brown.edu Fri Jun 14 22:04:30 1996 From: zack@lems.brown.edu (Zack Roadhouse) Date: Fri, 14 Jun 1996 17:04:30 -0400 Subject: [PYTHON IMAGE-SIG] Reading, displaying, and manipulating sun-rasters Message-ID: <199606142104.RAA06807@lems61.lems.brown.edu> My group is trying to load in a raster file to manipulate it as an object in a canvas. We are using this hack to convert the ras to a gif for easy display using convert (part of the ImageMagick 3.7.3 distribution): if self.filename[-3:]=='ras': root_filename=self.filename[:-4] os.system('convert'+' '+self.filename+' '+root_filename+'.gif') self.filename=root_filename+'.gif' self.img=Image.open(self.filename) self.tkim=ImageTk.PhotoImage(self.img.mode,self.img.size) self.tkim.paste(self.img) self.photo=Label(self,image=self.tkim.image) self.photo.pack({'side':'top'}) Unfortunately, when the image shows up it is strangly distorted. Several duplicates appear in the same frame, although they appear squished to something like 1/2,1/4,1/8 size. Four appear. Have any ideas for us? Our problem is that ImageTk won't accept a ras file read in by Image. Is there another way to do this? Please reply to everyone. --Zack /--------------------------------------------------------------------- Zachary F. Roadhouse Home: (847)869-5146 Box 220, Brown University, Providence, RI 02912 Work: (401)863-2177 E-MAIL: Zachary_Roadhouse@brown.edu WWW: http://www.netspace.org/~zack ================= IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org ================= From fredrik_lundh@ivab.se Mon Jun 17 09:00:02 1996 From: fredrik_lundh@ivab.se (Fredrik Lundh) Date: Mon, 17 Jun 1996 10:00:02 +0200 Subject: [PYTHON IMAGE-SIG] Reading, displaying, and manipulating sun-rasters In-Reply-To: <199606142104.RAA06807@lems61.lems.brown.edu> (zack@lems.brown.edu) Message-ID: <9606170800.AA19015@arnold.image.ivab.se> > My group is trying to load in a raster file to manipulate it as an object > in a canvas. Seems as you've stumbled upon two problems with PIL at the same time: 1. Interlaced GIFs are not properly read, as I noticed myself a few days ago (found a "NYI" comment in the sources :-(. This is why the image looks so strange. I'll fix this for the next release. 2. A (possible) problem with the type of Sun raster files you're using. To help me track down this problem, could you mail me the output from pilfile.py? $ python pilfile.py -i And yes, what happens if you try to do "show" on that image. Image.open(file).show() If that fails, does this work? Image.open(file).convert("RGB").show() Anyway, a quick workaround is to use PPM instead of GIF as the intermediate format (or determine how to switch off interlacing in ImageMagick). Regards /F ================= IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org ================= From sac@lems.brown.edu Mon Jun 17 14:45:09 1996 From: sac@lems.brown.edu (Seth A. Coe) Date: Mon, 17 Jun 1996 09:45:09 -0400 Subject: [PYTHON IMAGE-SIG] Reading, displaying, and manipulating sun-rasters In-Reply-To: <9606170800.AA19015@arnold.image.ivab.se> References: <199606142104.RAA06807@lems61.lems.brown.edu> <9606170800.AA19015@arnold.image.ivab.se> Message-ID: <199606171345.JAA08629@lems61.lems.brown.edu> Fredrik Lundh writes: > > > My group is trying to load in a raster file to manipulate it as an object > > in a canvas. > > Seems as you've stumbled upon two problems with PIL at the same time: > > 1. Interlaced GIFs are not properly read, as I noticed myself > a few days ago (found a "NYI" comment in the sources :-(. > This is why the image looks so strange. I'll fix this for > the next release. > > 2. A (possible) problem with the type of Sun raster files you're > using. To help me track down this problem, could you mail me the > output from pilfile.py? > > $ python pilfile.py -i > > And yes, what happens if you try to do "show" on that image. > > Image.open(file).show() > > If that fails, does this work? > > Image.open(file).convert("RGB").show() > > Anyway, a quick workaround is to use PPM instead of GIF as the > intermediate format (or determine how to switch off interlacing in > ImageMagick). > > Regards /F > Thanks for your help, using ppm as an intermediate instead of gif seems to be working just fine. Here is the output of pilfile.py when I try to shoe a sun image. Hope it helps you out some. sac@lems61 251 > python -i pilfile.py ~/raphael/rabbit.ras /home/sac/raphael/rabbit.ras: SUN 128x128 L >>> Image.open(file).show() Traceback (innermost last): File "", line 1, in ? File "/lems/vision/tools/Python/1.3/lib/python/Imaging/Image.py", line 241, in show file = self._dump() File "/lems/vision/tools/Python/1.3/lib/python/Imaging/Image.py", line 105, in _dump self.load() File "/lems/vision/tools/Python/1.3/lib/python/Imaging/ImageFile.py", line 120, in load d = _getdecoder(d, self, e, a) File "/lems/vision/tools/Python/1.3/lib/python/Imaging/ImageFile.py", line 47, in _getdecoder raise IOError, "decoder %s not available" % d IOError: decoder sun_rle not available >>> Image.open(file).convert("RGB").show() Traceback (innermost last): File "", line 1, in ? File "/lems/vision/tools/Python/1.3/lib/python/Imaging/Image.py", line 130, in convert self.load() File "/lems/vision/tools/Python/1.3/lib/python/Imaging/ImageFile.py", line 120, in load d = _getdecoder(d, self, e, a) File "/lems/vision/tools/Python/1.3/lib/python/Imaging/ImageFile.py", line 47, in _getdecoder raise IOError, "decoder %s not available" % d IOError: decoder sun_rle not available ================= IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org ================= From fredrik_lundh@ivab.se Thu Jun 20 09:11:24 1996 From: fredrik_lundh@ivab.se (Fredrik Lundh) Date: Thu, 20 Jun 1996 10:11:24 +0200 Subject: [PYTHON IMAGE-SIG] BUGFIX: Postscript Printing Problem Message-ID: <9606200811.AA22450@arnold.image.ivab.se> I finally got around to sort out that Postscript printing/EPS problem in 0.1b1. Haven't got any time right now to prepare a new release (there's too many things being "almost ready" :-), so I thought I'd just post the necessary changes instead. Regards /F -------------------------------------------------------------------- In Lib/PSDraw.py: dx = (xmax - x) / 2 + box[0] dy = (ymax - y) / 2 + box[1] + self.fp.write("matrix currentmatrix\n") self.fp.write("%f %f translate\n" % (dx, dy)) if (x, y) != im.size: # EpsImagePlugin._save prints the image at (0,0,xsize,ysize) sx = x / im.size[0] sy = y / im.size[1] self.fp.write("%f %f scale\n" % (sx, sy)) EpsImagePlugin._save(im, self.fp, None, 0) ! self.fp.write("\nsetmatrix\n") In libImaging/EpsEncode.c: if (++state->y >= state->ysize) { state->errcode = IMAGING_CODEC_END; ! return ptr - buf; } in = (UINT8*) im->image[state->y]; } ================= IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org ================= From davem@magnet.com Sun Jun 23 22:28:32 1996 From: davem@magnet.com (Dave Mitchell) Date: Sun, 23 Jun 1996 17:28:32 -0400 (EDT) Subject: [PYTHON IMAGE-SIG] Imaging Message-ID: <199606232128.RAA13465@waxmaster.magnet.com> So, I finally got back to working on my live Indycam stuff (working towards a page with real-time image grabbing from the camera, with images never getting saved to disk, as opposed to a cron job which consumes resources all the time). The camera can handle upwards of 30 fps. no problem, but the realtime raw to (some format) conversion is a pain! For my quickcam solution on my Linux PC, I was able to hack up something without much hassle because I hardcoded myself a 64-greyscale palette and hacked the hell out of someone else's code (giflib-2.2) to the point where I couldn't reproduce it even if I wanted to.. For the Indycam, I got the python module to the point at which I could GET the raw image, and left it there. Now that I have PIL, I have a chance of getting this thing where I want it! Today I got a page going which snaps the image and does the conversion to jpeg, and spits it out. You can give it a try (until the server dies or I kill it) at: http://waxmaster.magnet.com:6969/snoop/vlsnap.py Compare it with the (faster, but black&white) original Dave-cam at: http://roach.magnet.com/snoop/snoop.py This whole process of taking one image and converting it to a jpeg takes a bit over 2 seconds which leaves plenty to be desired as far as "real-time"! Converting to gif is even slower (about 4 seconds) because it uses the pbm stuff to do it with... My question is, is there going to be native gif-writing support anytime soon, or do I have to^H^H^H^H^H^H^Hget to write it myself? Dave ================= IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org ================= From zack@lems.brown.edu Mon Jun 24 20:06:55 1996 From: zack@lems.brown.edu (Zack Roadhouse) Date: Mon, 24 Jun 1996 15:06:55 -0400 Subject: [PYTHON IMAGE-SIG] ImageMagick interface to PIL Message-ID: <199606241906.PAA00498@lems61.lems.brown.edu> Hello all. Our group at LEMS is thinking about wrapping ImageMagick using SWIG so that we can read and write more formats and access the image processing capabilities of ImageMagick. Has anyone done this? We will probably end up creating a method to convert ImageMagick's internal structure to the one used by PIL. We are not teribly familiar with the internal structures of ImageMagick or PIL so any pointers would be of great help. We will make this work available if and when we finish it. Thanks! --Zack /--------------------------------------------------------------------- Zachary F. Roadhouse Home: (847)869-5146 Box 220, Brown University, Providence, RI 02912 Work: (401)421-0751 E-MAIL: Zachary_Roadhouse@brown.edu WWW: http://www.netspace.org/~zack ================= IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org ================= From zack@lems.brown.edu Tue Jun 25 01:38:21 1996 From: zack@lems.brown.edu (Zack Roadhouse) Date: Mon, 24 Jun 1996 20:38:21 -0400 Subject: [PYTHON IMAGE-SIG] Have swigged ImageMagick Message-ID: <199606250038.UAA05155@lems61.lems.brown.edu> Despite predictions about the apparent challange of swiging ImageMagick, it was done this afternoon. :) As soon as we can figure out an intermediary format between ImageMagick and PIL, we will upload the package for general public consumption. Everything appears to work fine. Where can I find detailed information regarding the internal formats of PIL? One downside to using ImageMagick is that is will not compile on a machine without X. Our group is hoping to use ImageMagick in the mean time while work progresses on PIL. Thanks, --Zack /--------------------------------------------------------------------- Zachary F. Roadhouse Home: (401)421-0751 Box 220, Brown University, Providence, RI 02912 Work: (401)863-2760 E-MAIL: Zachary_Roadhouse@brown.edu WWW: http://www.netspace.org/~zack ================= IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org ================= From fredrik_lundh@ivab.se Thu Jun 27 10:04:18 1996 From: fredrik_lundh@ivab.se (Fredrik Lundh) Date: Thu, 27 Jun 1996 11:04:18 +0200 Subject: [PYTHON IMAGE-SIG] Have swigged ImageMagick In-Reply-To: <199606250038.UAA05155@lems61.lems.brown.edu> (zack@lems.brown.edu) Message-ID: <9606270904.AA26055@arnold.image.ivab.se> > Where can I find detailed information regarding the internal formats > of PIL? There's not much written. Maybe the description and structs in Imaging.h may give you the clues you need? /F PS. I'll be off-line most of the time during the next few weeks, but will try to check my mail once or twice each week. We do apologise for the inconvenience :-) ================= IMAGE-SIG - SIG on Image Processing with Python send messages to: image-sig@python.org administrivia to: image-sig-request@python.org =================