You are here

function feeds_imagegrabber_get_image_info in Feeds Image Grabber 7

Same name and namespace in other branches
  1. 6 feeds_imagegrabber.module \feeds_imagegrabber_get_image_info()

Get the file info for in image file.

Drupal only supports GIF, JPG and PNG file formats. This is similar to drupal's image_get_info() except the file need not be an uploaded one.

Return value

FALSE, if the file could not be found or is not an image. Otherwise, a keyed array containing information about the image: 'width' - Width in pixels. 'height' - Height in pixels. 'extension' - Commonly used file extension for the image. 'mime_type' - MIME type ('image/jpeg', 'image/gif', 'image/png').

1 call to feeds_imagegrabber_get_image_info()
feeds_imagegrabber_is_image in ./feeds_imagegrabber.module
Checks that a file is an image.

File

./feeds_imagegrabber.module, line 647
Grabs images for items imported using the feeds module.

Code

function feeds_imagegrabber_get_image_info($file) {
  if (!is_file($file)) {
    return FALSE;
  }
  $details = FALSE;
  $data = @getimagesize($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,
      'mime_type' => $data['mime'],
    );
  }
  return $details;
}