Version: 0.9
Type: Full Script
Category: Graphics
License: GNU General Public License
Description: A command line php script to return size & type of given image file(s). Works with file globbing. NOTE: NOT tested on Windows. GD is NOT needed. 1. copy the source into a file (i call it "fs") 2. make it executable 3. move it into your ~/bin directory I have found this script useful for getting sizes of a group of images when doin g web stuff.
#!/usr/bin/php -q
<?php
$image_types=array(
'',
'GIF','JPG','PNG','SWF','PSD',
'BMP','TIFF(intel byte order)',
'TIFF(motorola byte order)',
'JPC','JP2','JPX','JB2','SWC',
'IFF'
);
$PHP_SELF=basename($argv[0]);
for($i=1;$i<count($argv);$i++){
if(substr($argv[$i],0,1)=='/'){
$f=$argv[$i];
}else{
$f=$_ENV["PWD"].'/'.$argv[$i];
}
$name=$argv[$i];
if( !$f || in_array($f, array('--help', '-help', '-h', '-?')) ){
// show help msg
echo "Get size of image\n";
echo "Usage: $PHP_SELF [image]\n\n";
}elseif(!is_file($f)){
//dont process if not a file
echo "\"$f\" not a file\n";
}else{
$dim=getimagesize($f);
if(!$dim){
echo "$name not handled";
}else{
echo "$name {$dim[0]}x{$dim[1]} {$image_types[$dim[2]]}";
}
echo"\n";
}
}
?>