Image width, height.

Discussion in 'Python' started by =?iso-8859-1?q?Premshree=20Pillai?=, Mar 1, 2004.

  1. =?iso-8859-1?q?Premshree=20Pillai?=, Mar 1, 2004
    #1
    1. Advertising

  2. 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
    Thomas Guettler, Mar 1, 2004
    #2
    1. Advertising

  3. =?iso-8859-1?q?Premshree=20Pillai?=

    Bob Ippolito Guest

    On 2004-03-01 06:38:11 -0500, Premshree Pillai
    <> said:

    > 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.

    >>> import Image
    >>> Image.open('testorig.jpg').size

    (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
    Bob Ippolito, Mar 1, 2004
    #3
  4. =?iso-8859-1?q?Premshree=20Pillai?=

    Nelson Minar Guest

    Premshree Pillai <> writes:
    > 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.
    Nelson Minar, Mar 1, 2004
    #4
  5. =?iso-8859-1?q?Premshree=20Pillai?=

    Just Guest

    In article <>,
    Nelson Minar <> wrote:

    > Premshree Pillai <> writes:
    > > 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.


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

    Just
    Just, Mar 1, 2004
    #5

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


    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
    Skip Montanaro, Mar 1, 2004
    #6

  7. > Premshree Pillai <> writes:
    > > 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.


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


    cheers,
    Fonso
    =?iso-8859-1?Q?Afonso_Fern=E1ndez_Nogueira?=, Mar 1, 2004
    #7
  8. =?iso-8859-1?q?Premshree=20Pillai?=

    Nelson Minar Guest

    Just <> writes:
    > 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.
    Nelson Minar, Mar 1, 2004
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AndrewF
    Replies:
    1
    Views:
    741
    Bruce Barker
    Oct 10, 2005
  2. Sean Jorden
    Replies:
    1
    Views:
    584
    laurie
    Aug 19, 2003
  3. Lois
    Replies:
    1
    Views:
    3,188
    Ryan Stewart
    Dec 27, 2004
  4. cera
    Replies:
    1
    Views:
    1,246
    Neredbojias
    Aug 18, 2007
  5. Bernd Meier
    Replies:
    6
    Views:
    500
    GTalbot
    Jan 14, 2008
Loading...

Share This Page