image_load
function image_load
image_load($file, $toolkit = FALSE)
Loads an image file and returns an image object.
Any changes to the file are not saved until image_save() is called.
Parameters
$file: Path to an image file.
$toolkit: An optional, image toolkit name to override the default.
Return value
An image object or FALSE if there was a problem loading the file. The image object has the following properties:
- 'source' - The original file path.
- 'info' - The array of information returned by image_get_info()
- 'toolkit' - The name of the image toolkit requested when the image was loaded.
Image toolkits may add additional properties. The caller is advised not to monkey about with them.
See also
image_get_available_toolkits()
Related topics
File
- includes/image.inc, line 383
- API for manipulating images.
Code
function image_load($file, $toolkit = FALSE) { if (!$toolkit) { $toolkit = image_get_toolkit(); } if ($toolkit) { $image = new stdClass(); $image->source = $file; $image->info = image_get_info($file, $toolkit); if (isset($image->info) && is_array($image->info)) { $image->toolkit = $toolkit; if (image_toolkit_invoke('load', $image)) { return $image; } } } return FALSE; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!image.inc/function/image_load/7.x