You are here

imagecache_canvasactions.module in ImageCache Actions 6.2

A collection of canvas (layer) type manipulations for imagecache - including "Watermark"

Based on first draft of the code by Dimm (imagecache.module 5--1) http://drupal.org/node/184816

Rewritten and ported to Imagecache actions API (imagecache.module 5--2) by dman http://coders.co.nz/

Notes about imagecache action extensions. For each action:

1: Impliment imagecache_HOOK_form($formdata) to define the config form.

1a: Impliment theme_imagecache_HOOK_form if needed - optional

2: Impliment imagecache_HOOK_image(&$image, $data) to DO the process

3: Impliment theme_imagecache_HOOK($element) to return a text description of the setting

4: Declare the action in HOOK_imagecache_actions()

API ref for hook_image()

File

canvasactions/imagecache_canvasactions.module
View source
<?php

/**
 * @file A collection of canvas (layer) type manipulations for imagecache -
 * including "Watermark"
 *
 * Based on first draft of the code by Dimm (imagecache.module 5--1)
 * http://drupal.org/node/184816
 *
 * Rewritten and ported to Imagecache actions API (imagecache.module 5--2) by
 * dman http://coders.co.nz/
 *
 *
 * Notes about imagecache action extensions. For each action:
 *
 * 1: Impliment imagecache_HOOK_form($formdata) to define the config form.
 *
 * 1a: Impliment theme_imagecache_HOOK_form if needed - optional
 *
 * 2: Impliment imagecache_HOOK_image(&$image, $data) to DO the process
 *
 * 3: Impliment theme_imagecache_HOOK($element) to return a text description of
 * the setting
 *
 * 4: Declare the action in HOOK_imagecache_actions()
 *
 *
 * API ref for hook_image()
 *
 * @param $image array defining an image file, including  :
 *
 *   $image- >source as the filename,
 *
 *   $image->info array
 *
 *   $image->resource handle on the image object
 *
 * @param $action array of settings as defined in your form.
 *
 */

// During devel, caching is pointless. Flush it
// imagecache_action_definitions(TRUE);
if (!function_exists('imagecache_actions_calculate_relative_position')) {
  module_load_include('inc', 'imagecache_canvasactions', 'utility');
}

/**
* Implementation of hook_imagecache_actions().
*
* Declare available actions, return help text about this filter.
*
* These funcs are all in their respective include libraries - as configured below
*/
function imagecache_canvasactions_imagecache_actions() {
  $util_dir = drupal_get_path('module', 'imagecache_actions');
  $actions = array(
    'canvasactions_definecanvas' => array(
      'name' => t('Define Canvas'),
      'description' => t('Define the size of the working canvas and background color, this controls the dimensions of the output image..'),
      'file' => 'canvasactions.inc',
    ),
    'canvasactions_imagemask' => array(
      'name' => t('Image mask'),
      'description' => t(' Choose the file image you wish to use as a mask, and apply it to the canvas.'),
      'file' => 'canvasactions.inc',
    ),
    'canvasactions_file2canvas' => array(
      'name' => t('Overlay (watermark)'),
      'description' => t(' Choose the file image you wish to use as an overlay, and position it in a layer on top of the canvas.'),
      'file' => 'canvasactions.inc',
    ),
    'canvasactions_canvas2file' => array(
      'name' => t('Underlay (background)'),
      'description' => t(' Choose the file image you wish to use as an background, and position the processed image on it.'),
      'file' => 'canvasactions.inc',
    ),
    'canvasactions_source2canvas' => array(
      'name' => t('Overlay: source image to canvas'),
      'description' => t('Places the source image onto the canvas for compositing.'),
      'file' => 'canvasactions.inc',
    ),
    'canvasactions_roundedcorners' => array(
      'name' => t('Rounded Corners'),
      'description' => t(' This is true cropping, not overlays, so the result <em>can</em> be transparent.'),
      'file' => 'rounded_corners.inc',
    ),
    'canvasactions_aspect' => array(
      'name' => t('Aspect switcher: Switch between portrait and landscape.'),
      'description' => t(' Use different effects depending on whether the image is landscape of portrait shaped. This re-uses other preset definitions, and just chooses between them based on the rule.'),
      'file' => 'canvasactions.inc',
    ),
  );
  return $actions;
}

//////////////////////

// imageapi extensions
module_load_include('inc', 'imagecache_actions', 'imageapi_image_overlay.inc');

/**
 * Need to register the theme functions we expect to use
 */
function imagecache_canvasactions_theme() {
  $util_dir = drupal_get_path('module', 'imagecache_actions');
  return array(
    'canvasactions_definecanvas' => array(
      'file' => 'canvasactions.inc',
      'arguments' => array(
        'element' => NULL,
      ),
    ),
    'canvasactions_imagemask' => array(
      'file' => 'canvasactions.inc',
      'arguments' => array(
        'element' => NULL,
      ),
    ),
    'canvasactions_file2canvas' => array(
      'file' => 'canvasactions.inc',
      'arguments' => array(
        'element' => NULL,
      ),
    ),
    'canvasactions_source2canvas' => array(
      'file' => 'canvasactions.inc',
      'arguments' => array(
        'element' => NULL,
      ),
    ),
    'canvasactions_canvas2file' => array(
      'file' => 'canvasactions.inc',
      'arguments' => array(
        'element' => NULL,
      ),
    ),
    'canvasactions_roundedcorners' => array(
      'file' => 'rounded_corners.inc',
      'arguments' => array(
        'element' => NULL,
      ),
    ),
    'canvasactions_aspect' => array(
      'file' => 'canvasactions.inc',
      'arguments' => array(
        'element' => NULL,
      ),
    ),
  );
}

Functions

Namesort descending Description
imagecache_canvasactions_imagecache_actions Implementation of hook_imagecache_actions().
imagecache_canvasactions_theme Need to register the theme functions we expect to use