Accept a keyword (center, top, left, etc) and return it as a pixel offset.
$value:
$current_pixels:
$new_pixels:
function image_filter_keyword($value, $current_pixels, $new_pixels) {
switch ($value) {
case 'top':
case 'left':
return 0;
case 'bottom':
case 'right':
return $current_pixels - $new_pixels;
case 'center':
return $current_pixels / 2 - $new_pixels / 2;
}
return $value;
}