Definition

image_gd_open($file, $extension)
drupal/modules/system/image.gd.inc, line 183

Description

GD helper function to create an image resource from a file.

Parameters

$file A string file path where the image should be saved.

$extension A string containing one of the following extensions: gif, jpg, jpeg, png.

Return value

An image resource, or FALSE on error.

Related topics

Namesort iconDescription
Image toolkitsDrupal's image toolkits provide an abstraction layer for common image file manipulations like scaling, cropping, and rotating. The abstraction frees module authors from the need to support multiple image libraries, and it allows site...

Code

function image_gd_open($file, $extension) {
  $extension = str_replace('jpg', 'jpeg', $extension);
  $open_func = 'imageCreateFrom' . $extension;
  if (!function_exists($open_func)) {
    return FALSE;
  }
  return $open_func($file);
}