You are here

function imagecache_convert_form in ImageCache Actions 6.2

Same name and namespace in other branches
  1. 5.3 imagecache_coloractions.module \imagecache_convert_form()
  2. 5.2 imagecache_coloractions.module \imagecache_convert_form()
  3. 6 imagecache_coloractions.module \imagecache_convert_form()

Implementation of imagecache_hook_form()

Parameters

$action array of settings for this action:

Return value

a form definition

File

coloractions/imagecache_coloractions.module, line 354
Additional actions for imagecache processing.

Code

function imagecache_convert_form($action) {
  if (image_get_toolkit() === 'imageapi_imagemagick') {
    drupal_set_message('When using imagemagick, convert format must be the last effect. If not, results will be unpredictable.', 'warning');
  }
  $form = array(
    'help' => array(
      '#type' => 'markup',
      '#value' => t("If you've been using transparencies in the process, the result may get saved as a PNG (as the image was treated as a one in in-between processes). If this is not desired (file sizes may get too big) you should use this process to force a flatten action before saving. "),
    ),
    'help2' => array(
      '#type' => 'markup',
      '#value' => t("For technical reasons, changing the file format within imagecache does <em>not</em> change the filename suffix. A png may be saved as a *.jpg or vice versa. This may confuse some browsers and image software, but most of them have no trouble. "),
    ),
    'format' => array(
      '#title' => t("File format"),
      '#type' => 'select',
      '#default_value' => isset($action['format']) ? $action['format'] : 'image/png',
      '#options' => imagecache_file_formats(),
    ),
    'quality' => array(
      '#type' => 'textfield',
      '#title' => t('JPEG quality'),
      '#description' => t('Define the image quality for JPEG manipulations only. Ranges from 0 to 100. Higher values mean better image quality, but bigger files.<br /><strong>Has no effect if jpg is not selected.</strong>'),
      '#size' => 10,
      '#maxlength' => 3,
      '#default_value' => isset($action['quality']) ? $action['quality'] : '75',
      '#field_suffix' => '%',
    ),
  );
  return $form;
}