| 5 image.inc | image_scale($source, $destination, $width, $height) |
| 6 image.inc | image_scale( |
| 7 image.inc | image_scale(stdClass $image, $width = NULL, $height = NULL, $upscale = FALSE) |
| 8 image.inc | image_scale(stdClass $image, $width = NULL, $height = NULL, $upscale = FALSE) |
Scales an image while maintaining aspect ratio.
The resulting image can be smaller for one or both target dimensions.
Parameters
$image: An image object returned by image_load().
$width: The target width, in pixels. This value is omitted then the scaling will based only on the height value.
$height: The target height, in pixels. This value is omitted then the scaling will based only on the width value.
$upscale: Boolean indicating that files smaller than the dimensions will be scaled up. This generally results in a low quality image.
Return value
TRUE on success, FALSE on failure.
See also
Related topics
3 calls to image_scale()
4 string references to 'image_scale'
File
- core/
includes/ image.inc, line 252 - API for manipulating images.
Code
function image_scale(stdClass $image, $width = NULL, $height = NULL, $upscale = FALSE) {
$dimensions = $image->info;
// Scale the dimensions - if they don't change then just return success.
if (!image_dimensions_scale($dimensions, $width, $height, $upscale)) {
return TRUE;
}
return image_resize($image, $dimensions['width'], $dimensions['height']);
}
Login or register to post comments