image_gd_load
function image_gd_load
image_gd_load(stdClass $image)
GD helper function to create an image resource from a file.
Parameters
$image: An image object. The $image->resource value will populated by this call.
Return value
TRUE or FALSE, based on success.
See also
Related topics
File
- modules/system/image.gd.inc, line 253
- GD2 toolkit for image manipulation within Drupal.
Code
function image_gd_load(stdClass $image) { $extension = str_replace('jpg', 'jpeg', $image->info['extension']); $function = 'imagecreatefrom' . $extension; if (function_exists($function) && $image->resource = $function($image->source)) { if (imageistruecolor($image->resource)) { return TRUE; } else { // Convert indexed images to truecolor, copying the image to a new // truecolor resource, so that filters work correctly and don't result // in unnecessary dither. $resource = image_gd_create_tmp($image, $image->info['width'], $image->info['height']); if ($resource) { imagecopy($resource, $image->resource, 0, 0, 0, 0, imagesx($resource), imagesy($resource)); imagedestroy($image->resource); $image->resource = $resource; } } return (bool) $image->resource; } 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/modules!system!image.gd.inc/function/image_gd_load/7.x