Image width, height.

  • Thread starter =?iso-8859-1?q?Premshree=20Pillai?=
  • Start date
T

Thomas Guettler

Am Mon, 01 Mar 2004 11:38:11 +0000 schrieb Premshree Pillai:
Hello,

Is there a Py module available using which I can find
the width and height of any image format?

Hello,

try 'identify -format "%w %h"' with popen.

identify is part of imagemagick.

Sorry, that's no python module, but maybe it
helps you, too.

HTH,
Thomas
 
B

Bob Ippolito

Hello,

Is there a Py module available using which I can find
the width and height of any image format?

ANY image format is a tall order, however PIL is pretty good at it, and
supports a large number of image formats.
(227, 149)

Note that even if you don't have a JPEG decoder available, PIL bakes in
enough support for the format to let you get the image dimensions out
of the header. I'd imagine that this is generally true with the rest
of PIL, too.

-bob
 
N

Nelson Minar

Premshree Pillai said:
Is there a Py module available using which I can find
the width and height of any image format?

I'm not aware of one short of loading the whole image or shelling out
to another tool.

There's a nifty Perl module though:
http://www.blackperl.com/Image::Size/
The nice thing about it is it doesn't have to load the whole image in
most cases. The actual size determining code is about 500 lines of
fairly simple Perl to handle about 10 image formats. It might not be
too bad to port it. It's under the Perl Artistic License.
 
J

Just

Nelson Minar said:
I'm not aware of one short of loading the whole image or shelling out
to another tool.

PIL is such a Python package. It doesn't load the entire image if all
you want to know are the dimensions.

Just
 
S

Skip Montanaro

Nelson> I'm not aware of one short of loading the whole image or
Nelson> shelling out to another tool.

Can't PIL do this?

Skip
 
?

=?iso-8859-1?Q?Afonso_Fern=E1ndez_Nogueira?=

I'm not aware of one short of loading the whole image or shelling out
to another tool.

There's a nifty Perl module though:
http://www.blackperl.com/Image::Size/
The nice thing about it is it doesn't have to load the whole image in
most cases. The actual size determining code is about 500 lines of
fairly simple Perl to handle about 10 image formats. It might not be
too bad to port it. It's under the Perl Artistic License.

The PIL does this, too.
http://www.pythonware.com/products/pil/


cheers,
Fonso
 
N

Nelson Minar

Just said:
PIL is such a Python package. It doesn't load the entire image if all
you want to know are the dimensions.

Just goes to show you - if you want the right answer on the net, post
a wrong answer and then everyone will correct you :) Sorry for the
misinformation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top