int (width), * [height] => int (height), * [type] => string (type), * [attr] => string (attributes formatted for IMG tags), * [bits] => int (bits), * [channels] => int (channels), * [mime] => string (mime-type) * * Returns false if $file is not a file, no arguments are supplied, $file is not an image, or otherwise fails. * **/ function image_info($file = null, $out = null) { // If $file is not supplied or is not a file, warn the user and return false. if (is_null($file) || !is_file($file)) { // echo '

Warning: image_info() => first argument must be a file.

'; return false; } // Defines the keys we want instead of 0, 1, 2, 3, 'bits', 'channels', and 'mime'. $redefine_keys = array( 'width', 'height', 'type', 'attr', 'bits', 'channels', 'mime', ); // If $out is supplied, but is not a valid key, nullify it. if (!is_null($out) && !in_array($out, $redefine_keys)) $out = null; // Assign usefull values for the third index. $types = array( 1 => 'GIF', 2 => 'JPG', 3 => 'PNG', 4 => 'SWF', 5 => 'PSD', 6 => 'BMP', 7 => 'TIFF(intel byte order)', 8 => 'TIFF(motorola byte order)', 9 => 'JPC', 10 => 'JP2', 11 => 'JPX', 12 => 'JB2', 13 => 'SWC', 14 => 'IFF', 15 => 'WBMP', 16 => 'XBM' ); $temp = array(); $data = array(); // Get the image info using getimagesize(). // If $temp fails to populate, warn the user and return false. if (!$temp = @getimagesize($file)) { //echo '

Warning: image_info() => first argument must be an image.

'; return false; } // Get the values returned by getimagesize() $temp = array_values($temp); // Make an array using values from $redefine_keys as keys and values from $temp as values. foreach ($temp AS $k => $v) { $data[$redefine_keys[$k]] = $v; } // Make 'type' usefull. $data['type'] = $types[$data['type']]; // Return the desired information. return !is_null($out) ? $data[$out] : $data; } function GetFileInfo($filename,$ext,$dir=false) { $result=""; if ($dir) { $result=" "; } else { switch (strtolower($ext)) { case "png" : case "gif" : case "jpg" : { $imginfo=image_info($filename); if ($imginfo) { $result=$imginfo["width"]."x".$imginfo["height"]."x".$imginfo["bits"]; } break; } default : $result=" "; } } return $result; } ?>