function imagecache_rotate_image in ImageCache 6.2
Same name and namespace in other branches
- 5.2 imagecache_actions.inc \imagecache_rotate_image()
File
- ./
imagecache_actions.inc, line 256
Code
function imagecache_rotate_image(&$image, $data) {
// Merge in default values.
$data += array(
'degrees' => '0',
'random' => FALSE,
'bgcolor' => '',
);
// Set sane default values.
if (strlen(trim($data['bgcolor']))) {
$data['bgcolor'] = hexdec(str_replace('#', '', $data['bgcolor']));
}
else {
$data['bgcolor'] = NULL;
}
if ($data['random']) {
$degrees = abs((double) $data['degrees']);
$data['degrees'] = rand(-1 * $degrees, $degrees);
}
if (!imageapi_image_rotate($image, $data['degrees'], $data['bgcolor'])) {
watchdog('imagecache', 'imagecache_rotate_image failed. image: %image, data: %data.', array(
'%image' => $image->source,
'%data' => print_r($data, TRUE),
), WATCHDOG_ERROR);
return FALSE;
}
return TRUE;
}