function canvasactions_canvas2file_dimensions in ImageCache Actions 7
Same name and namespace in other branches
- 8 canvasactions/canvasactions.inc \canvasactions_canvas2file_dimensions()
Image dimensions callback for the underlay (background) effect.
Parameters
array $dimensions: Dimensions to be modified - an associative array containing the items 'width' and 'height' (in pixels).
array $data: An associative array containing the effect data.
1 string reference to 'canvasactions_canvas2file_dimensions'
- imagecache_canvasactions_image_effect_info in canvasactions/
imagecache_canvasactions.module - Implements hook_image_effect_info().
File
- canvasactions/
canvasactions.inc, line 615
Code
function canvasactions_canvas2file_dimensions(array &$dimensions, array $data) {
if ($data['dimensions'] !== 'original') {
$underlay = imagecache_actions_image_load($data['path']);
if ($underlay) {
// If the new dimensions are taken from the background, we don't need to
// know the original dimensions, we can just set the new dimensions to the
// dimensions of the background. Otherwise, we need to know the old
// dimensions. If unknown we have to leave them unknown.
switch ($data['dimensions']) {
case 'background':
$dimensions['width'] = $underlay->info['width'];
$dimensions['height'] = $underlay->info['height'];
break;
case 'minimum':
if ($dimensions['width'] !== NULL) {
$dimensions['width'] = min($underlay->info['width'], $dimensions['width']);
}
if ($dimensions['height'] !== NULL) {
$dimensions['height'] = min($underlay->info['height'], $dimensions['height']);
}
break;
case 'maximum':
if ($dimensions['width'] !== NULL) {
$dimensions['width'] = max($underlay->info['width'], $dimensions['width']);
}
if ($dimensions['height'] !== NULL) {
$dimensions['height'] = max($underlay->info['height'], $dimensions['height']);
}
break;
}
}
}
}