| 1 |
<?php |
<?php |
| 2 |
// $Id: imagecache_actions.inc,v 1.12.2.2 2009/04/17 03:03:22 drewish Exp $ |
// $Id: imagecache_actions.inc,v 1.12.2.3 2009/08/19 18:15:54 drewish Exp $ |
| 3 |
|
|
| 4 |
|
/** |
| 5 |
|
* ImageCache Resize |
| 6 |
|
*/ |
| 7 |
|
function imagecache_resize_image(&$image, $data) { |
| 8 |
|
if (!imageapi_image_resize($image, $data['width'], $data['height'])) { |
| 9 |
|
watchdog('imagecache', t('imagecache_resize_image failed. image: %image, data: %data.', array('%path' => $image, '%data' => print_r($data, true))), WATCHDOG_ERROR); |
| 10 |
|
return false; |
| 11 |
|
} |
| 12 |
|
return true; |
| 13 |
|
} |
| 14 |
|
|
| 15 |
|
function imagecache_resize_form($action) { |
| 16 |
|
$form['width'] = array( |
| 17 |
|
'#type' => 'textfield', |
| 18 |
|
'#title' => t('Width'), |
| 19 |
|
'#default_value' => $action['width'], |
| 20 |
|
'#description' => t('Enter a width in pixels or as a percentage. i.e. 500 or 80%.'), |
| 21 |
|
); |
| 22 |
|
$form['height'] = array( |
| 23 |
|
'#type' => 'textfield', |
| 24 |
|
'#title' => t('Height'), |
| 25 |
|
'#default_value' => $action['height'], |
| 26 |
|
'#description' => t('Enter a height in pixels or as a percentage. i.e. 500 or 80%.'), |
| 27 |
|
); |
| 28 |
|
return $form; |
| 29 |
|
} |
| 30 |
|
|
| 31 |
|
function theme_imagecache_resize($element) { |
| 32 |
|
$data = $element['#value']; |
| 33 |
|
if ($data['width'] && $data['height']) { |
| 34 |
|
return check_plain($data['width']) . 'x' . check_plain($data['height']); |
| 35 |
|
} |
| 36 |
|
return ($data['width']) ? t('width @width', array('@width' => $data['width'])) : t('height @height', array('@height' => $data['height'])); |
| 37 |
|
} |
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
/** |
/** |
| 42 |
* Imagecache Scale |
* Imagecache Scale |
| 53 |
} |
} |
| 54 |
|
|
| 55 |
function theme_imagecache_scale($element) { |
function theme_imagecache_scale($element) { |
| 56 |
$output = theme_imagecache_resize($element) . ', upscale: '. |
return theme_imagecache_resize($element) . ' ' . ($element['#value']['upscale'] ? '(' . t('upscaling allowed') . ')' : ''); |
|
$output .= ($element['#value']['upscale']) ? t('Yes') : t('No'); |
|
|
return $output; |
|
| 57 |
} |
} |
| 58 |
|
|
| 59 |
function imagecache_scale_image(&$image, $data) { |
function imagecache_scale_image(&$image, $data) { |
| 125 |
|
|
| 126 |
function theme_imagecache_deprecated_scale($element) { |
function theme_imagecache_deprecated_scale($element) { |
| 127 |
$data = $element['#value']; |
$data = $element['#value']; |
| 128 |
$options = array('inside' => t('Inside dimensions'), 'outside' => t('Outside dimensions')); |
$fits = array('inside' => t('Inside dimensions'), 'outside' => t('Outside dimensions')); |
| 129 |
return 'width: '. $data['width'] .', height: '. $data['height'] .', fit: '. $options[$data['fit']]; |
return t('width: @width, height: @height, fit: @fit', array('@width' => $data['width'], '@height' => $data['height'], '@fit' => $fits[$data['fit']])); |
| 130 |
} |
} |
| 131 |
|
|
| 132 |
function imagecache_deprecated_scale_image(&$image, $data) { |
function imagecache_deprecated_scale_image(&$image, $data) { |
| 181 |
|
|
| 182 |
function theme_imagecache_crop($element) { |
function theme_imagecache_crop($element) { |
| 183 |
$data = $element['#value']; |
$data = $element['#value']; |
| 184 |
return 'width: '. $data['width'] .', height: '. $data['height'] .', xoffset: '. $data['xoffset'] .', yoffset: '. $data['yoffset']; |
return t('width: @width, height: @height, xoffset: @xoffset, yoffset: @yoffset', array( |
| 185 |
|
'@width' => $data['width'], |
| 186 |
|
'@height' => $data['height'], |
| 187 |
|
'@xoffset' => $data['xoffset'], |
| 188 |
|
'@yoffset' => $data['yoffset'], |
| 189 |
|
)); |
| 190 |
} |
} |
| 191 |
|
|
| 192 |
function imagecache_crop_image(&$image, $data) { |
function imagecache_crop_image(&$image, $data) { |
| 246 |
} |
} |
| 247 |
|
|
| 248 |
function theme_imagecache_rotate($element) { |
function theme_imagecache_rotate($element) { |
| 249 |
$output = t('degrees:') .' '. $element['#value']['degrees'] .', '; |
$data = $element['#value']; |
| 250 |
$output .= t('randomize:') .' '. (($element['#value']['random']) ? t('Yes') : t('No')) .', '; |
if ($data['random']) { |
| 251 |
$output .= t('background:') .' '. strlen(trim($element['#value']['bgcolor'])) ? $element['#value']['bgcolor'] : t('Transparent/white'); |
return t('random between -@degrees° and @degrees°', array('@degrees' => $data['degrees'])); |
| 252 |
return $output; |
} |
| 253 |
|
return t('@degrees°', array('@degrees' => $data['degrees'])); |
| 254 |
} |
} |
| 255 |
|
|
| 256 |
function imagecache_rotate_image(&$image, $data) { |
function imagecache_rotate_image(&$image, $data) { |
| 315 |
} |
} |
| 316 |
|
|
| 317 |
function theme_imagecache_sharpen($element) { |
function theme_imagecache_sharpen($element) { |
| 318 |
$output = t('radius: ') . $element['#value']['radius'] .', '; |
$data = $element['#value']; |
| 319 |
$output .= t('sigma: ') . $element['#value']['sigma'] .', '; |
return t('radius: @radius, sigma: @sigma, amount: @amount, threshold: @threshold', array( |
| 320 |
$output .= t('amount: ') . $element['#value']['amount'] .', '; |
'@radius' => $data['radius'], |
| 321 |
$output .= t('threshold: ') . $element['#value']['threshold'] ; |
'@sigma' => $data['sigma'], |
| 322 |
return $output; |
'@amount' => $data['amount'], |
| 323 |
|
'@threshold' => $data['threshold'], |
| 324 |
|
)); |
| 325 |
} |
} |
| 326 |
|
|
| 327 |
function imagecache_sharpen_image(&$image, $data) { |
function imagecache_sharpen_image(&$image, $data) { |