function image_gd_resize
image_gd_resize(stdClass $image, $width, $height)
Scale an image to the specified size using GD.
Parameters
$image: An image object. The $image->resource, $image->info['width'], and $image->info['height'] values will be modified by this call.
$width: The new width of the resized image, in pixels.
$height: The new height of the resized image, in pixels.
Return value
TRUE or FALSE, based on success.
See also
Related topics
File
- modules/system/image.gd.inc, line 78
- GD2 toolkit for image manipulation within Drupal.
Code
function image_gd_resize(stdClass $image, $width, $height) { $res = image_gd_create_tmp($image, $width, $height); if (!imagecopyresampled($res, $image->resource, 0, 0, 0, 0, $width, $height, $image->info['width'], $image->info['height'])) { return FALSE; } imagedestroy($image->resource); // Update image object. $image->resource = $res; $image->info['width'] = $width; $image->info['height'] = $height; return TRUE; }
© 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_resize/7.x