image_get_info

5 image.inc image_get_info($file)
6 image.inc image_get_info($file)
7 image.inc image_get_info($filepath, $toolkit = FALSE)
8 image.inc image_get_info($filepath, $toolkit = FALSE)

Get details about an image.

Return value

array containing information about the image 'width': image's width in pixels 'height': image's height in pixels 'extension': commonly used extension for the image 'mime_type': image's MIME type ('image/jpeg', 'image/gif', etc.) 'file_size': image's physical size (in bytes)

9 calls to image_get_info()

File

includes/image.inc, line 91

Code

function image_get_info($file) {
  if (!is_file($file)) {
    return false;
  }

  $details = false;
  $data = @getimagesize($file);
  $file_size = @filesize($file);

  if (isset($data) && is_array($data)) {
    $extensions = array(
      '1' => 'gif',
      '2' => 'jpg',
      '3' => 'png',
    );
    $extension = array_key_exists($data[2], $extensions) ?  $extensions[$data[2]] : '';
    $details = array(
      'width' => $data[0], 
      'height' => $data[1], 
      'extension' => $extension, 
      'file_size' => $file_size, 
      'mime_type' => $data['mime'],
    );
  }

  return $details;
}
Login or register to post comments