You are here

function image_imagick_settings in Imagick 7

Retrieve settings for the Imagick toolkit.

File

./imagick.module, line 92
Imagick toolkit for image manipulation within Drupal.

Code

function image_imagick_settings() {
  if (image_imagick_check_settings()) {
    $form['status'] = array(
      '#markup' => t('The Imagick toolkit is installed and working properly.'),
    );
    $form['jpeg'] = array(
      '#type' => 'fieldset',
      '#title' => t('JPEG specific settings'),
      '#description' => t('<strong>Tip: </strong>Generated images can be converted to the JPEG format using the Convert effect.'),
    );
    $form['jpeg']['image_jpeg_quality'] = array(
      '#type' => 'textfield',
      '#title' => t('JPEG quality'),
      '#description' => t('Higher values mean better image quality but bigger files. Quality level below 80% is not advisable when using ImageMagick.'),
      '#size' => 10,
      '#maxlength' => 3,
      '#default_value' => variable_get('image_jpeg_quality', 80),
      '#field_suffix' => t('%'),
    );
    $form['jpeg']['imagick_image_optimize'] = array(
      '#type' => 'checkbox',
      '#title' => t('Use Google Pagespeed Insights image optimization.'),
      '#description' => t('See the <a href="@url" target="_blank">guidelines</a> for further information.', array(
        '@url' => 'https://developers.google.com/speed/docs/insights/OptimizeImages',
      )),
      '#default_value' => variable_get('imagick_image_optimize', TRUE),
    );
    $form['imagick_strip_metadata'] = array(
      '#type' => 'checkbox',
      '#title' => t('Strip images of all metadata.'),
      '#description' => t('Eg. profiles, comments, ...'),
      '#default_value' => variable_get('imagick_strip_metadata', FALSE),
    );
    $form['image_resize_filter'] = array(
      '#type' => 'select',
      '#title' => t('Imagic resize filter'),
      '#description' => t('Define the resize filter for image manipulations. If you\'re not sure what you should enter here, leave the default settings.'),
      '#options' => array(
        -1 => t('- None -'),
        imagick::FILTER_UNDEFINED => 'FILTER_UNDEFINED',
        imagick::FILTER_POINT => 'FILTER_POINT',
        imagick::FILTER_BOX => 'FILTER_BOX',
        imagick::FILTER_TRIANGLE => 'FILTER_TRIANGLE',
        imagick::FILTER_HERMITE => 'FILTER_HERMITE',
        imagick::FILTER_HANNING => 'FILTER_HANNING',
        imagick::FILTER_HAMMING => 'FILTER_HAMMING',
        imagick::FILTER_BLACKMAN => 'FILTER_BLACKMAN',
        imagick::FILTER_GAUSSIAN => 'FILTER_GAUSSIAN',
        imagick::FILTER_QUADRATIC => 'FILTER_QUADRATIC',
        imagick::FILTER_CUBIC => 'FILTER_CUBIC',
        imagick::FILTER_CATROM => 'FILTER_CATROM',
        imagick::FILTER_MITCHELL => 'FILTER_MITCHELL',
        imagick::FILTER_LANCZOS => 'FILTER_LANCZOS',
        imagick::FILTER_BESSEL => 'FILTER_BESSEL',
        imagick::FILTER_SINC => 'FILTER_SINC',
      ),
      '#default_value' => variable_get('image_resize_filter', imagick::FILTER_LANCZOS),
    );
    $form['#element_validate'] = array(
      'image_imagick_settings_validate',
    );
    return $form;
  }
  else {
    drupal_set_message(t('The Imagick image toolkit requires that the Imagick extension for PHP be installed and configured properly. For more information see <a href="@url">PHP\'s ImageMagick documentation</a>.', array(
      '@url' => 'http://php.net/manual/book.imagick.php',
    )), 'error');
    return FALSE;
  }
}