You are here

function image_im_advanced_form_alter in Image 5.2

Same name and namespace in other branches
  1. 5 contrib/image_im_advanced/image_im_advanced.module \image_im_advanced_form_alter()
  2. 6 contrib/image_im_advanced/image_im_advanced.module \image_im_advanced_form_alter()
  3. 7 contrib/image_im_advanced/image_im_advanced.module \image_im_advanced_form_alter()

Implementation of hook_form_alter().

Add options to the Image toolkit settings form.

File

contrib/image_im_advanced/image_im_advanced.module, line 26

Code

function image_im_advanced_form_alter($form_id, &$form) {
  if ($form_id == 'system_image_toolkit_settings' && 'imagemagick' == image_get_toolkit()) {
    $options = image_im_advanced_options();
    $form['image_im_advanced_options'] = array(
      '#type' => 'fieldset',
      '#title' => t('ImageMagick Advanced Options'),
      '#collapsible' => FALSE,
      '#description' => t("These settings let you control some of ImageMagick's more advanced options."),
      '#validate' => array(
        'image_im_advanced_settings_validate' => array(),
      ),
      '#tree' => TRUE,
    );
    $form['image_im_advanced_options']['jpeg_quality'] = array(
      '#type' => 'textfield',
      '#title' => t('JPEG quality'),
      '#size' => 10,
      '#maxlength' => 3,
      '#default_value' => $options['jpeg_quality'],
      '#field_suffix' => t('%'),
      '#description' => t('Define the image quality for JPEG manipulations. Ranges from 0 to 100. Higher values mean better image quality but bigger files. <a href="!link">More information on -quality</a>', array(
        '!link' => url('http://www.imagemagick.org/script/command-line-options.php#quality'),
      )),
    );
    $form['image_im_advanced_options']['strip'] = array(
      '#type' => 'textfield',
      '#title' => t('Strip metadata from images at this size and below'),
      '#default_value' => $options['strip'],
      '#description' => t('You may choose to strip all metadata, such as camera information and color profiles, from the processed images in order to reduce their file size. Please choose at what maximum size you want images to be stripped of their metadata. Example: "150x150". Enter "0x0" to disable this feature. This option requires ImageMagick 6.0.0 or higher. <a href="!link">More information on -strip</a>', array(
        '!link' => url('http://www.imagemagick.org/script/command-line-options.php#strip'),
      )),
    );
    $form['image_im_advanced_options']['colorspace'] = array(
      '#type' => 'select',
      '#title' => t('Convert colorspace'),
      '#default_value' => $options['colorspace'],
      '#options' => array(
        0 => t('<None>'),
        'RGB' => t('RGB'),
        'GRAY' => t('Gray'),
      ),
      '#description' => t('This option lets you convert images to the specified colorspace. This will be overridden by the Color profile option, if used. <a href="!link">More information on -colorspace</a>', array(
        '!link' => url('http://www.imagemagick.org/script/command-line-options.php#colorspace'),
      )),
    );
    $form['image_im_advanced_options']['density'] = array(
      '#type' => 'checkbox',
      '#title' => t('Change image resolution to 72 ppi'),
      '#default_value' => $options['density'],
      '#description' => t('If checked, this option will set the print resolution of the image to 72 pixels per inch, which is suitable for web use. This does not affect the pixel size or quality of the image.  <a href="!link">More information on -density</a>', array(
        '!link' => url('http://www.imagemagick.org/script/command-line-options.php#density'),
      )),
    );
    $form['image_im_advanced_options']['unsharp'] = array(
      '#type' => 'fieldset',
      '#title' => t('Sharpening filter'),
      '#collapsible' => TRUE,
      '#collapsed' => $options['unsharp']['amount'] == 0,
      '#description' => t('The sharpness filter is used to regain some of the sharpness that is always lost when a digital photograph is scaled down. This is equivalent to the commonly used "Unsharp Mask" filter. It is important that these values are not set too high as it can easily make the images look artificial. <a href="!link">More information on -unsharp</a>', array(
        '!link' => url('http://www.imagemagick.org/script/command-line-options.php#unsharp'),
      )),
    );
    $form['image_im_advanced_options']['unsharp']['amount'] = array(
      '#type' => 'textfield',
      '#title' => t('Sharpness filter strength'),
      '#size' => 4,
      '#maxlength' => 3,
      '#default_value' => $options['unsharp']['amount'],
      '#field_suffix' => t('%'),
      '#description' => t('Apply this percentage of sharpness when scaling. 90 is recommended, although values higher than 100 are also valid. Set to 0 to disable this feature.'),
    );
    $form['image_im_advanced_options']['unsharp']['radius'] = array(
      '#type' => 'textfield',
      '#title' => t('Sharpness filter radius'),
      '#default_value' => $options['unsharp']['radius'],
      '#size' => 4,
      '#maxlength' => 4,
      '#description' => t('Use this pixel radius for the sharpness filter. 0.9 is recommended.'),
    );
    $form['image_im_advanced_options']['profile'] = array(
      '#type' => 'fieldset',
      '#title' => t('Color profile'),
      '#collapsible' => TRUE,
      '#collapsed' => empty($options['profile']['path']),
      '#description' => t('Processed images may be converted to a color profile specified here. This is especially important when working with images that use a wide-gamut color profile such as ColorMatch or Adobe RGB, which is often the case with professional photography. sRGB (which may be downloaded from <a href="http://www.color.org/profiles.html">ICC</a>) is recommended since it is likely to look good on most displays.<br />Note that this conversion is still useful even if you choose to strip all metadata from your images (see above). This is because the conversion happens first and changes the actual image data before the profile is stripped.'),
    );
    $form['image_im_advanced_options']['profile']['path'] = array(
      '#type' => 'textfield',
      '#title' => t('Path to color profile'),
      '#default_value' => $options['profile']['path'],
      '#description' => t('The path to a color profile file that all scaled down images will be converted to. Leave empty to disable.'),
    );

    // Move the buttons below our additions.
    $form['buttons']['#weight'] = 10;
  }
}