Click to See Complete Forum and Search --> : Dimensions of image?
klamath
11-01-2000, 07:37 PM
I'm looking for a simple command-line app which will tell me the dimensions (height, width) of a GIF image (PNG support would be nice too). Does such a beast exist?
------------------
- Klamath
Get my GnuPG Key Here (http://klamath.dyndns.org/mykey.asc)
Looking for an open source project to contribute to? Check out the BBB (http://bbb.sourceforge.net)
treatment
11-03-2000, 01:25 PM
Haven't found one.
Strike
11-03-2000, 02:59 PM
I could have sworn there was one out there. I mean, it's almost a trivial program - I believe that that stuff is all embedded in a header and that you just have to use their library (or read up on the header format) to do a simple extraction of that data. You may save yourself some time just reading their specs and seeing if you can find a library (or Perl module or something) that will make it easy to hack together a program that would do it for you.
Sweede
11-03-2000, 03:25 PM
if you have php installed as a cgi-binary, its trivial to do it.
install php into the /usr directory
./configure --prefix=/usr
then use.
#!/usr/bin/php -q
<?
$val_arr = getimagesize($argv[1]);
echo $val_arr[3];
?>
the $argv variable contains an array of all arguments passed on the command line. the command itself is $argc[0]
the function, GetImageSize() returns an array with
$array[0] = width
$array[1] = height
$array[2] = image type (gif,jpg,png,swf)
$array[3] = correct "height=xxx width=yyy" string.
check out http://www.php.net/manual/function.getimagesize.php
for more info
i decided to test it to see if it worked, sweede@static-x:>$cat foo.ph
#!/usr/bin/php -q
<?
$val_arr = @getimagesize($argv[1]);
while(list($key,$val) = each($val_arr)){
echo $key." ".$val."\n";
}
?>
[Virtual-Support]-[~/public_html/images]
sweede@static-x:>$./foo.ph `pwd`/background.jpg
0 1024
1 11
2 2
3 width="1024" height="11"
bits 8
channels 3
[This message has been edited by Sweede (edited 04 November 2000).]