'textfield', '#title' => t('Compression Quality'), '#description' => t('Ranges from 1 to 100. Higher values mean better image quality, but bigger files.'), '#size' => 10, '#maxlength' => 3, '#default_value' => variable_get('imageapi_imagick_quality', 75), '#field_suffix' => '%', '#validate' => array('imageapi_imagick_quality_element_validate' => array()), ); return system_settings_form($form); } function imageapi_imagick_quality_element_validate($element) { if ($element['#value'] < 0 || $element['#value'] > 100) { form_set_error($element['#name'], t('Compression Quality must be a value between 1 and 100.')); } } function imageapi_imagick_image_open($image) { try { $image->res = new Imagick($image->source); $image->res->setCompressionQuality(variable_get('imageapi_imagick_quality', 75)); return $image; } catch(Exception $e) { //print_r($e); return FALSE; } } function imageapi_imagick_image_close($image, $destination) { try { $image->res->writeImage($destination); } catch(Exception $e) { //print_r($e); return FALSE; } } function imageapi_imagick_image_crop(&$image, $x, $y, $width, $height) { try { $image->res->cropImage($width, $height, $x, $y); $image->info['width'] = $width; $image->info['height'] = $height; return TRUE; } catch (Exception $e) { //drupal_set_messge(print_r($e,1)); return FALSE; } } function imageapi_imagick_image_resize(&$image, $width, $height) { $image->res->resizeImage($width, $height, Imagick::FILTER_LANCZOS, 1); $image->info['width'] = $width; $image->info['height'] = $width; return TRUE; } function imageapi_imagick_image_rotate(&$image, $degrees, $bgcolor) { $image->res->imageRotate(new ImagickPixel($bgcolor), $degree); return TRUE; } function imageapi_imagick_image_desaturate(&$image) { $image->res->setImageType(Imagick::IMGTYPE_GRAYSCALE); return TRUE; }