[Tutor] image sizes

Remco Gerlich scarblac@pino.selwerd.nl
Tue, 21 Aug 2001 08:25:02 +0200

On  0, fleet@teachout.org wrote:
> I'm really pushing the topic limits here; but I want to be able to obtain
> image sizes (height and width of .GIF files) from within a Python script.
> I know about PIL; but is this necessary to accomplish what I want?  And
> will it accomplish what I want?
> (I haven't a clue how to go about this outside of Python either!)
> And if it's needed - RH 7.1 and Python 1.5.2.

Yes, I'd use PIL. With PIL, it is *very* simple:

import Image

pic = Image.open("mypicture.gif")
width, height = pic.size

This code immediately works for almost all other types of image as well.
PIL is just so extremely neat, I wish everything had an interface as simple
as that :)

[consider the code for converting a .gif to .jpg:
Remco Gerlich