source as the filename, * * $image->info array * * $image->res 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); require_once('utility.inc'); /** * 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() { $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_source2canvas' => array( 'name' => t('Overlay: source image to canvas'), 'description' => t('Places the source image onto the canvas for compositing.'), 'file' => 'canvasactions.inc', ), 'canvasactions_file2canvas' => array( 'name' => t('Overlay: file image to canvas (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: place a file image under the current image (background)'), 'description' => t(' Choose the file image you wish to use as an background, and position the processed image on it.'), 'file' => 'canvasactions.inc', ), ); return $actions; } /** * Need to flush the cache when this module is enabled */ function imagecache_canvasactions_install() { imagecache_action_definitions(TRUE); cache_clear_all('imagecache_actions', 'cache'); drupal_set_message(t('Additional imagecache actions should now be available in the presets !settings_link', array('!settings_link' => l(t('settings'), 'admin/build/imagecache')))); } ////////////////////// // imageapi extensions // Maybe shift into there one day /** * Place one image over another * * @param $overlay may be a filename or an imageAPI object * @return bool success * @ingroup imageapi */ function imageapi_image_overlay(&$image, $overlay, $x, $y, $alpha) { return call_user_func_array($image->toolkit .'_image_overlay', array(&$image, $overlay, $x, $y, $alpha)); } /** * Place one image over another * This modifies the passed image by reference * * @ingroup imageapi * @param $overlay may be a filename or an imageAPI object * @param alpha from 0-100. * @return bool success */ function imageapi_gd_image_overlay(&$image, $overlay, $x, $y, $alpha) { if (is_string($overlay) ) { if (! file_exists($overlay)) { watchdog('imagecache', 'Image file does not exist. Attempted to overlay $overlay'); } $overlay = imageapi_image_open($overlay); } $x_ins = _imagecache_keyword_filter($x, $image->info['width'], $overlay->info['width']); $y_ins = _imagecache_keyword_filter($y, $image->info['height'], $overlay->info['height']); // imagecopymerge doesn't do alpha transparency right? //imagealphablending($image->res, false); //imagesavealpha($image->res, TRUE); //imagealphablending($overlay->res, false); //imagesavealpha($overlay->res, TRUE); // imagecopymerge($image->res, $overlay->res, $x_ins, $y_ins, 0, 0, $overlay->info['width'], $overlay->info['height'], $alpha); // Silly thing, it's easy. Use the attached library below instead require_once('watermark.inc'); $watermark = new watermark(); $image->res = $watermark->create_watermark($image->res, $overlay->res, $x_ins, $y_ins, $alpha); imagedestroy($overlay->res); return TRUE; }