You are here

function imagick_definecanvas_form in Imagick 7

Settings form for the imagick definecanvas effect.

Parameters

$action: The saved action form parameters.

1 string reference to 'imagick_definecanvas_form'
imagick_image_effect_info in ./imagick.module
Implements hook_image_effect_info()

File

effects/imagick.definecanvas.inc, line 90

Code

function imagick_definecanvas_form($data) {
  $data = array_merge(imagick_definecanvas_defaults(), (array) $data);
  $form['HEX'] = array(
    '#type' => 'textfield',
    '#title' => t('HEX'),
    '#default_value' => $data['HEX'],
    '#size' => 7,
    '#colorpicker' => TRUE,
  );
  $form['under'] = array(
    '#type' => 'checkbox',
    '#title' => t('Resize canvas <em>under</em> image (possibly cropping)'),
    '#default_value' => $data['under'],
    '#description' => t('If <em>not</em> set, this will create a solid flat layer, probably totally obscuring the source image'),
  );
  $form['info'] = array(
    '#value' => t('Enter values in ONLY ONE of the below options. Either exact or relative. Most values are optional - you can adjust only one dimension as needed. If no useful values are set, the current base image size will be used.'),
  );
  $form['exact_measurements'] = array(
    '#type' => 'checkbox',
    '#title' => t('Exact measurements'),
    '#default_value' => $data['exact_measurements'],
  );
  $form['exact'] = array(
    '#type' => 'fieldset',
    '#collapsible' => FALSE,
    '#title' => 'Exact size',
    'help' => array(
      '#markup' => t('Set the canvas to a precise size, possibly cropping the image. Use to start with a known size.'),
      '#prefix' => '<p>',
      '#suffix' => '</p>',
    ),
    'width' => array(
      '#type' => 'textfield',
      '#title' => t('Width'),
      '#default_value' => $data['exact']['width'],
      '#description' => t('Enter a value in pixels or percent'),
      '#size' => 5,
    ),
    'height' => array(
      '#type' => 'textfield',
      '#title' => t('Height'),
      '#default_value' => $data['exact']['height'],
      '#description' => t('Enter a value in pixels or percent'),
      '#size' => 5,
    ),
    'anchor' => array(
      '#type' => 'radios',
      '#title' => t('Anchor'),
      '#options' => array(
        'left-top' => t('Top left'),
        'center-top' => t('Top center'),
        'right-top' => t('Top right'),
        'left-center' => t('Center left'),
        'center-center' => t('Center'),
        'right-center' => t('Center right'),
        'left-bottom' => t('Bottom left'),
        'center-bottom' => t('Bottom center'),
        'right-bottom' => t('Bottom right'),
      ),
      '#theme' => 'image_anchor',
      '#default_value' => $data['exact']['anchor'],
    ),
    '#states' => array(
      'visible' => array(
        ':input[name="data[exact_measurements]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['relative'] = array(
    '#type' => 'fieldset',
    '#collapsible' => FALSE,
    '#title' => t('Relative size'),
    'help' => array(
      '#markup' => t('Set the canvas to a relative size, based on the current image dimensions. Use to add simple borders or expand by a fixed amount. Negative values may crop the image.'),
      '#prefix' => '<p>',
      '#suffix' => '</p>',
    ),
    'leftdiff' => array(
      '#type' => 'textfield',
      '#title' => t('left difference'),
      '#default_value' => $data['relative']['leftdiff'],
      '#size' => 6,
      '#description' => t('Enter an offset in pixels.'),
    ),
    'rightdiff' => array(
      '#type' => 'textfield',
      '#title' => t('right difference'),
      '#default_value' => $data['relative']['rightdiff'],
      '#size' => 6,
      '#description' => t('Enter an offset in pixels.'),
    ),
    'topdiff' => array(
      '#type' => 'textfield',
      '#title' => t('top difference'),
      '#default_value' => $data['relative']['topdiff'],
      '#size' => 6,
      '#description' => t('Enter an offset in pixels.'),
    ),
    'bottomdiff' => array(
      '#type' => 'textfield',
      '#title' => t('bottom difference'),
      '#default_value' => $data['relative']['bottomdiff'],
      '#size' => 6,
      '#description' => t('Enter an offset in pixels.'),
    ),
    '#states' => array(
      'visible' => array(
        ':input[name="data[exact_measurements]"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  return $form;
}