View source
<?php
function image_imagick_frame(stdClass $image, $matte_color, $width, $height, $inner_bevel, $outer_bevel) {
$res = $image->resource;
$color = empty($matte_color) ? 'none' : $matte_color;
$res
->frameImage(new ImagickPixel($color), $width, $height, $inner_bevel, $outer_bevel);
$dimensions = $res
->getImageGeometry();
$res
->setImagePage($dimensions['width'], $dimensions['height'], 0, 0);
$image->info['width'] = $dimensions['width'];
$image->info['height'] = $dimensions['height'];
return $res;
}
function imagick_frame_dimensions(array &$dimensions, array $data) {
if (!empty($dimensions['width']) && !empty($dimensions['height'])) {
$dimensions['width'] += $data['width'] * 2;
$dimensions['height'] += $data['height'] * 2;
}
}
function imagick_frame($image, $data = array()) {
image_toolkit_invoke('frame', $image, $data);
}
function imagick_frame_form($data) {
$data = array_merge(imagick_frame_defaults(), (array) $data);
$form['matte_color'] = array(
'#type' => 'textfield',
'#title' => t('Color of the shadow'),
'#default_value' => $data['matte_color'],
'#size' => 7,
'#colorpicker' => TRUE,
);
$form['width'] = array(
'#type' => 'textfield',
'#title' => t('Width'),
'#description' => t('The width of the frame'),
'#default_value' => $data['width'],
'#size' => 3,
);
$form['height'] = array(
'#type' => 'textfield',
'#title' => t('Height'),
'#description' => t('The height of the frame'),
'#default_value' => $data['height'],
'#size' => 3,
);
$form['inner_bevel'] = array(
'#type' => 'textfield',
'#title' => t('Inner bevel'),
'#description' => t('The inner bevel of the frame'),
'#default_value' => $data['inner_bevel'],
'#size' => 3,
);
$form['outer_bevel'] = array(
'#type' => 'textfield',
'#title' => t('Outer bevel'),
'#description' => t('The outer bevel of the frame'),
'#default_value' => $data['outer_bevel'],
'#size' => 3,
);
return $form;
}
function imagick_frame_defaults() {
return array(
'matte_color' => '#707070',
'width' => '20',
'height' => '20',
'inner_bevel' => '5',
'outer_bevel' => '5',
);
}