Same name and namespace in other branches
  1. 4.6.x includes/image.inc \image_get_info()
  2. 4.7.x includes/image.inc \image_get_info()
  3. 6.x includes/image.inc \image_get_info()
  4. 7.x includes/image.inc \image_get_info()

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)

7 calls to image_get_info()
image_gd_crop in includes/image.inc
Crop an image using the GD toolkit.
image_gd_resize in includes/image.inc
Scale an image to the specified size using GD.
image_gd_rotate in includes/image.inc
Rotate an image the given number of degrees.
image_scale in includes/image.inc
Scales an image to the given width and height while maintaining aspect ratio.
user_file_download in modules/user/user.module
Implementation of hook_file_download().

... See full list

File

includes/image.inc, line 82

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;
}