473,406 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Image width, height.

Hello,

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

-Premshree

=====
-Premshree
[http://www.qiksearch.com/]

__________________________________________________ ______________________
Yahoo! India Insurance Special: Be informed on the best policies, services, tools and more.
Go to: http://in.insurance.yahoo.com/licspecial/index.html

Jul 18 '05 #1
7 4040
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

Jul 18 '05 #2
On 2004-03-01 06:38:11 -0500, Premshree Pillai
<pr**************@yahoo.co.in> 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

Jul 18 '05 #3
Premshree Pillai <pr**************@yahoo.co.in> 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.
Jul 18 '05 #4
In article <cp*************@cabernet.nelson.monkey.org>,
Nelson Minar <ne****@monkey.org> wrote:
Premshree Pillai <pr**************@yahoo.co.in> 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
Jul 18 '05 #5
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

Jul 18 '05 #6
Premshree Pillai <pr**************@yahoo.co.in> 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


Jul 18 '05 #7
Just <ju**@xs4all.nl> 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.
Jul 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Tjerk | last post by:
Hello all, I have the script below to change an image depending on the date upto january it worked fine but then it just stopped working does anybody have an idea how I can make it work again or...
9
by: Karl Burrows | last post by:
I am working on a Website for a non-profit group and for some reason I have one link that doesn't want to cooperate. All the image links work fine with the onmouseover and onmouseout script except...
5
by: Csaba Gabor | last post by:
Is there any way to determine the pixel height and width of an original image? Specifically, If I have <IMG id=myImg src="pic.jpg" height=200 width=300> can I figure out what the original size...
15
by: Anand Ganesh | last post by:
HI All, I have an Image. I want to clip a portion of it and copy to another image. How to do this? I know the bounding rectangle to clip. Any suggestions please. Thanks for your time and...
6
by: abdullah1983 | last post by:
Hi Guys, I need some clarification regarding the problem with safari browser. Please find my code below. I'm setting the image src, mouseover and mouseout using javascript. The mouseover and...
4
by: tshad | last post by:
I am trying to set up an Image authorization where you type in the value that is in a picture to log on to our site. I found a program that is supposed to do it, but it doesn't seem to work. ...
7
by: finecur | last post by:
I have a <img scr="mypic.jpg"in my html. I would like to display the image by width=200 if the image width is larger than 200. I also would like to display the image by its real width if the image...
1
by: sravani1 | last post by:
This code runs like when i submit the form it takes the image and displayed and top of the image a map will displayed. But actually i want that when i give the image it checks the location in the map...
3
by: premprakashbhati | last post by:
hi, good evening.. i am going to upload an image in a web form .....for that iam using HTML input(file) control and one web control button i.e., Upload_Button() here is the code ...its work fine...
2
by: studentofknowledge | last post by:
For some unknown reason ie is placing images I have in a div in a weird way. One image is overlapping another but this problem is not occuring in mozilla. I have looked at my code over and over again...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.