open videos on popup overlay
@@ -0,0 +1,14 @@
|
||||
name = Imagecache Canvas Actions
|
||||
description = Provides image effects for manipulating image canvases: define canvas, image mask, watermark, underlay background image, rounded corners, composite source to image and resize by percent effect. Also provides an aspect switcher (portrait/landscape).
|
||||
package = Media
|
||||
core = 7.x
|
||||
|
||||
dependencies[] = imagecache_actions
|
||||
dependencies[] = image
|
||||
|
||||
; Information added by Drupal.org packaging script on 2016-02-19
|
||||
version = "7.x-1.7"
|
||||
core = "7.x"
|
||||
project = "imagecache_actions"
|
||||
datestamp = "1455872655"
|
||||
|
||||
@@ -0,0 +1,221 @@
|
||||
<?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)
|
||||
* https://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: Implement imagecache_HOOK_form($formdata) to define the config form.
|
||||
*
|
||||
* 1a: Implement theme_imagecache_HOOK_form if needed - optional
|
||||
*
|
||||
* 2: Implement imagecache_HOOK_image($image, $data) to DO the process
|
||||
*
|
||||
* 3: Implement 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.
|
||||
*
|
||||
*/
|
||||
|
||||
if (! function_exists('imagecache_actions_calculate_relative_position') ) {
|
||||
module_load_include('inc', 'imagecache_actions', 'utility');
|
||||
}
|
||||
|
||||
// @todo There doesn't seem to be a way to specify a file in hook_image_effect_info
|
||||
// so placing this here for the time being.
|
||||
module_load_include('inc', 'imagecache_canvasactions', 'canvasactions');
|
||||
module_load_include('inc', 'imagecache_canvasactions', 'rounded_corners');
|
||||
|
||||
/**
|
||||
* Implements hook_image_effect_info().
|
||||
*
|
||||
* Defines information about the supported effects.
|
||||
*/
|
||||
function imagecache_canvasactions_image_effect_info() {
|
||||
$effects = array();
|
||||
|
||||
$effects['canvasactions_definecanvas'] = array(
|
||||
'label' => t('Define canvas'),
|
||||
'help' => t('Define the size of the working canvas and background color, this controls the dimensions of the output image.'),
|
||||
'effect callback' => 'canvasactions_definecanvas_effect',
|
||||
'dimensions callback' => 'canvasactions_definecanvas_dimensions',
|
||||
'form callback' => 'canvasactions_definecanvas_form',
|
||||
'summary theme' => 'canvasactions_definecanvas_summary',
|
||||
);
|
||||
|
||||
$effects['canvasactions_imagemask'] = array(
|
||||
'label' => t('Image mask'),
|
||||
'help' => t(' Choose the file image you wish to use as a mask, and apply it to the canvas.'),
|
||||
'dimensions passthrough' => TRUE,
|
||||
'effect callback' => 'canvasactions_imagemask_effect',
|
||||
'form callback' => 'canvasactions_imagemask_form',
|
||||
'summary theme' => 'canvasactions_imagemask_summary',
|
||||
);
|
||||
|
||||
$effects['canvasactions_file2canvas'] = array(
|
||||
'label' => t('Overlay (watermark)'),
|
||||
'help' => t('Choose the file image you wish to use as an overlay, and position it in a layer on top of the canvas.'),
|
||||
'dimensions passthrough' => TRUE,
|
||||
'effect callback' => 'canvasactions_file2canvas_effect',
|
||||
'form callback' => 'canvasactions_file2canvas_form',
|
||||
'summary theme' => 'canvasactions_file2canvas_summary',
|
||||
);
|
||||
|
||||
$effects['canvasactions_canvas2file'] = array(
|
||||
'label' => t('Underlay (background)'),
|
||||
'help' => t('Choose the file image you wish to use as an background, and position the processed image on it.'),
|
||||
'effect callback' => 'canvasactions_canvas2file_effect',
|
||||
'dimensions callback' => 'canvasactions_canvas2file_dimensions',
|
||||
'form callback' => 'canvasactions_canvas2file_form',
|
||||
'summary theme' => 'canvasactions_canvas2file_summary',
|
||||
);
|
||||
|
||||
$effects['canvasactions_source2canvas'] = array(
|
||||
'label' => t('Overlay: source image to canvas'),
|
||||
'help' => t('Places the source image onto the canvas for compositing.'),
|
||||
'dimensions passthrough' => TRUE,
|
||||
'effect callback' => 'canvasactions_source2canvas_effect',
|
||||
'form callback' => 'canvasactions_source2canvas_form',
|
||||
'summary theme' => 'canvasactions_source2canvas_summary',
|
||||
);
|
||||
|
||||
$effects['canvasactions_roundedcorners'] = array(
|
||||
'label' => t('Rounded Corners'),
|
||||
'help' => t('This is true cropping, not overlays, so the result <em>can</em> be transparent.'),
|
||||
'dimensions passthrough' => TRUE,
|
||||
'effect callback' => 'canvasactions_roundedcorners_effect',
|
||||
'form callback' => 'canvasactions_roundedcorners_form',
|
||||
'summary theme' => 'canvasactions_roundedcorners_summary',
|
||||
);
|
||||
|
||||
$effects['canvasactions_aspect'] = array(
|
||||
'label' => t('Aspect switcher'),
|
||||
'help' => 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.'),
|
||||
'effect callback' => 'canvasactions_aspect_effect',
|
||||
'dimensions callback' => 'canvasactions_aspect_dimensions',
|
||||
'form callback' => 'canvasactions_aspect_form',
|
||||
'summary theme' => 'canvasactions_aspect_summary',
|
||||
);
|
||||
|
||||
$effects['canvasactions_resizepercent'] = array(
|
||||
'label' => t('Resize (percent)'),
|
||||
'help' => t('Resize the image based on percent. If only a single dimension is specified, the other dimension will be calculated.'),
|
||||
'effect callback' => 'canvasactions_resizepercent_effect',
|
||||
'dimensions callback' => 'canvasactions_resizepercent_dimensions',
|
||||
'form callback' => 'canvasactions_resizepercent_form',
|
||||
'summary theme' => 'canvasactions_resizepercent_summary',
|
||||
);
|
||||
|
||||
$effects['canvasactions_blur'] = array(
|
||||
'label' => t('Blur'),
|
||||
'help' => t('Make the image become unclear.'),
|
||||
'effect callback' => 'canvasactions_blur_effect',
|
||||
'dimensions passthrough' => TRUE,
|
||||
'form callback' => 'canvasactions_blur_form',
|
||||
'summary theme' => 'canvasactions_blur_summary',
|
||||
);
|
||||
|
||||
$effects['canvasactions_interlace'] = array(
|
||||
'label' => t('Interlace / Progressive'),
|
||||
'help' => t('Create interlaced PNG/GIF or progressive JPG.'),
|
||||
'effect callback' => 'canvasactions_interlace_effect',
|
||||
'dimensions passthrough' => TRUE,
|
||||
'form callback' => 'canvasactions_interlace_form',
|
||||
);
|
||||
|
||||
return $effects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*
|
||||
* Registers theme functions for the effect summaries.
|
||||
*/
|
||||
function imagecache_canvasactions_theme() {
|
||||
return array(
|
||||
'canvasactions_definecanvas_summary' => array(
|
||||
'variables' => array('data' => NULL),
|
||||
'file' => 'canvasactions.inc',
|
||||
),
|
||||
'canvasactions_imagemask_summary' => array(
|
||||
'arguments' => array('element' => NULL),
|
||||
'file' => 'canvasactions.inc',
|
||||
),
|
||||
'canvasactions_file2canvas_summary' => array(
|
||||
'variables' => array('data' => NULL),
|
||||
'file' => 'canvasactions.inc',
|
||||
),
|
||||
'canvasactions_source2canvas_summary' => array(
|
||||
'variables' => array('data' => NULL),
|
||||
'file' => 'canvasactions.inc',
|
||||
),
|
||||
'canvasactions_canvas2file_summary' => array(
|
||||
'variables' => array('data' => NULL),
|
||||
'file' => 'canvasactions.inc',
|
||||
),
|
||||
'canvasactions_roundedcorners_summary' => array(
|
||||
'variables' => array('data' => NULL),
|
||||
'file' => 'canvasactions.inc',
|
||||
),
|
||||
'canvasactions_aspect_summary' => array(
|
||||
'variables' => array('data' => NULL),
|
||||
'file' => 'canvasactions.inc',
|
||||
),
|
||||
'canvasactions_resizepercent_summary' => array(
|
||||
'variables' => array('data' => NULL),
|
||||
'file' => 'canvasactions.inc',
|
||||
),
|
||||
'canvasactions_blur_summary' => array(
|
||||
'variables' => array('data' => NULL),
|
||||
'file' => 'canvasactions.inc',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_image_style_flush().
|
||||
*
|
||||
* This hook checks if the image style that is being flushed is used in an
|
||||
* aspect switcher effect. If so, the style that contains the aspect switcher
|
||||
* effect, should be flushed as well as the flushed style was probably changed.
|
||||
*
|
||||
* @param array $flushed_style
|
||||
* The image style that is being flushed.
|
||||
*/
|
||||
function imagecache_canvasactions_image_style_flush(/*array*/ $flushed_style) {
|
||||
$styles = image_styles();
|
||||
foreach ($styles as $style) {
|
||||
if ($style['name'] !== $flushed_style['name']) {
|
||||
foreach ($style['effects'] as $effect) {
|
||||
if ($effect['name'] === 'canvasactions_aspect') {
|
||||
if ( (isset($effect['data']['portrait']) && $effect['data']['portrait'] === $flushed_style['name'])
|
||||
|| (isset($effect['data']['landscape']) && $effect['data']['landscape'] === $flushed_style['name'])) {
|
||||
image_style_flush($style);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file Routines for rounded corners
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set radius for corner rounding
|
||||
*
|
||||
* Implementation of imagecache_hook_form()
|
||||
*
|
||||
* @param $action array of settings for this action
|
||||
* @return a form definition
|
||||
*/
|
||||
function canvasactions_roundedcorners_form($action) {
|
||||
if (image_get_toolkit() != 'gd') {
|
||||
drupal_set_message('Rounded corners are not currently supported on all versions of imagemagick. This effect works best with GD image toolkit only.', 'warning');
|
||||
}
|
||||
drupal_add_js(drupal_get_path('module', 'imagecache_actions') . '/imagecache_actions.jquery.js');
|
||||
$defaults = array(
|
||||
'radius' => '16',
|
||||
#'antialias' => TRUE,
|
||||
'independent_corners_set' => array(
|
||||
'independent_corners' => FALSE,
|
||||
'radii' => array(
|
||||
'tl' => 0,
|
||||
'tr' => 0,
|
||||
'bl' => 0,
|
||||
'br' => 0,
|
||||
),
|
||||
),
|
||||
);
|
||||
$action = array_merge($defaults, (array) $action);
|
||||
|
||||
$form['radius'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('radius'),
|
||||
'#default_value' => $action['radius'],
|
||||
'#size' => 2,
|
||||
);
|
||||
|
||||
$form['independent_corners_set'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Individual Corner Values'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => (! $action['independent_corners_set']['independent_corners']),
|
||||
);
|
||||
$form['independent_corners_set']['independent_corners'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Set Corners Independently'),
|
||||
'#default_value' => $action['independent_corners_set']['independent_corners'],
|
||||
);
|
||||
$corners = array(
|
||||
'tl' => t("Top Left Radius"),
|
||||
'tr' => t("Top Right Radius"),
|
||||
'bl' => t("Bottom Left Radius"),
|
||||
'br' => t("Bottom Right Radius"),
|
||||
);
|
||||
// Loop over the four corners and create field elements for them.
|
||||
$form['independent_corners_set']['radii'] = array(
|
||||
'#type' => 'item',
|
||||
'#id' => 'independent-corners-set',
|
||||
'#states' => array(
|
||||
'visible' => array(
|
||||
':input[name="data[independent_corners_set][independent_corners]"]' => array('checked' => TRUE),
|
||||
),
|
||||
),
|
||||
);
|
||||
foreach ($corners as $attribute => $label) {
|
||||
$form['independent_corners_set']['radii'][$attribute] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => $label,
|
||||
'#default_value' => 0 + $action['independent_corners_set']['radii'][$attribute],
|
||||
'#size' => 2,
|
||||
);
|
||||
}
|
||||
/*
|
||||
$form['antialias'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('antialias'),
|
||||
'#return_value' => TRUE,
|
||||
'#default_value' => $action['antialias'],
|
||||
'#description' => t('Attempt antialias smoothing when drawing the corners'),
|
||||
);
|
||||
*/
|
||||
$form['notes'] = array(
|
||||
'#markup' => t('
|
||||
Note: the rounded corners effect uses true alpha transparency masking.
|
||||
This means that this effect <b>will fail to be saved</b> on jpegs
|
||||
<em>unless</em> you either <ul>
|
||||
<li>convert the image to PNG (using the coloractions filter for that),</li>
|
||||
<li>define a canvas underneath it (using canvasactions-define-canvas) or</li>
|
||||
<li>underlay a solid color (using coloractions-alpha-flatten) or</li>
|
||||
<li>underlay a background image (canvasactions-underlay)</li>
|
||||
</ul>
|
||||
as a later part of this imagecache pipeline.
|
||||
<br/>
|
||||
'),
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
function canvasactions_roundedcorners_effect($image, $action) {
|
||||
$independent_corners = !empty($action['independent_corners_set']['independent_corners']);
|
||||
if (!$independent_corners) {
|
||||
// set the independant corners to all be the same.
|
||||
$corners = array('tl', 'tr', 'bl', 'br');
|
||||
foreach ($corners as $key) {
|
||||
// Use the all-the-same radius setting.
|
||||
$action['independent_corners_set']['radii'][$key] = $action['radius'];
|
||||
}
|
||||
}
|
||||
|
||||
return image_toolkit_invoke('roundedcorners', $image, array($action));
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim rounded corners off an image, using an anti-aliasing algorithm.
|
||||
*
|
||||
* Implementation of hook_image()
|
||||
*
|
||||
* Note, this is not image toolkit-agnostic yet! It just assumes GD.
|
||||
* We can abstract it out once we have something else to abstract to.
|
||||
* In the meantime just don't.
|
||||
*
|
||||
* 'handcoded' rounded corners logic contributed by donquixote 2009-08-31
|
||||
*
|
||||
* @param $image
|
||||
* @param $action
|
||||
*/
|
||||
function image_gd_roundedcorners($image, $action) {
|
||||
// Read settings.
|
||||
$width = $image->info['width'];
|
||||
$height = $image->info['height'];
|
||||
$radius = $action['radius'];
|
||||
$independent_corners = !empty($action['independent_corners_set']['independent_corners']);
|
||||
$corners = array('tl', 'tr', 'bl', 'br');
|
||||
|
||||
$im = &$image->resource;
|
||||
// Prepare drawing on the alpha channel.
|
||||
imagesavealpha($im, TRUE);
|
||||
imagealphablending($im, FALSE);
|
||||
|
||||
foreach ($corners as $key) {
|
||||
if ($independent_corners && isset($action['independent_corners_set']['radii'][$key])) {
|
||||
$r = $action['independent_corners_set']['radii'][$key];
|
||||
}
|
||||
else {
|
||||
// Use the all-the-same radius setting.
|
||||
$r = $radius;
|
||||
}
|
||||
|
||||
// key can be 'tl', 'tr', 'bl', 'br'.
|
||||
$is_bottom = ($key{0} == 'b');
|
||||
$is_right = ($key{1} == 'r');
|
||||
|
||||
// dx and dy are in "continuous coordinates",
|
||||
// and mark the distance of the pixel middle to the image border.
|
||||
for ($dx = .5; $dx < $r; ++$dx) {
|
||||
for ($dy = .5; $dy < $r; ++$dy) {
|
||||
|
||||
// ix and iy are in discrete pixel indices,
|
||||
// counting from the top left
|
||||
$ix = floor($is_right ? $width -$dx : $dx);
|
||||
$iy = floor($is_bottom ? $height -$dy : $dy);
|
||||
|
||||
// Color lookup at ($ix, $iy).
|
||||
$color_ix = imagecolorat($im, $ix, $iy);
|
||||
$color = imagecolorsforindex($im, $color_ix);
|
||||
|
||||
|
||||
// Do not process opacity if transparency is 100%. Just jump...
|
||||
// Opacity is always 0 on a transparent source pixel.
|
||||
if ($color['alpha'] != 127) {
|
||||
$opacity = _canvasactions_roundedcorners_pixel_opacity($dx, $dy, $r);
|
||||
if ($opacity >= 1) {
|
||||
// we can finish this row,
|
||||
// all following pixels will be fully opaque.
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (isset($color['alpha'])) {
|
||||
$color['alpha'] = 127 - round($opacity * (127 - $color['alpha']));
|
||||
}
|
||||
else {
|
||||
$color['alpha'] = 127 - round($opacity * 127);
|
||||
}
|
||||
// Value should not be more than 127, and not less than 0.
|
||||
$color['alpha'] = ($color['alpha'] > 127) ? 127 : (($color['alpha'] < 0) ? 0 : $color['alpha']);
|
||||
}
|
||||
|
||||
$color_ix = imagecolorallocatealpha($im, $color['red'], $color['green'], $color['blue'], $color['alpha']);
|
||||
imagesetpixel($im, $ix, $iy, $color_ix);
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the transparency value for a rounded corner pixel
|
||||
*
|
||||
* @param $x
|
||||
* distance from pixel center to image border (left or right)
|
||||
* should be an integer + 0.5
|
||||
*
|
||||
* @param $y
|
||||
* distance from pixel center to image border (top or bottom)
|
||||
* should be an integer + 0.5
|
||||
*
|
||||
* @param $r
|
||||
* radius of the rounded corner
|
||||
* should be an integer
|
||||
*
|
||||
* @return float
|
||||
* opacity value between 0 (fully transparent) and 1 (fully opaque).
|
||||
*
|
||||
* OPTIMIZE HERE! This is a really tight loop, potentially getting called
|
||||
* thousands of times
|
||||
*/
|
||||
function _canvasactions_roundedcorners_pixel_opacity($x, $y, $r) {
|
||||
if ($x < 0 || $y < 0) {
|
||||
return 0;
|
||||
}
|
||||
else if ($x > $r || $y > $r) {
|
||||
return 1;
|
||||
}
|
||||
$dist_2 = ($r -$x) * ($r -$x) + ($r -$y) * ($r -$y);
|
||||
$r_2 = $r * $r;
|
||||
if ($dist_2 > ($r + 0.8) * ($r + 0.8)) {
|
||||
return 0;
|
||||
}
|
||||
else if ($dist_2 < ($r -0.8) * ($r -0.8)) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
// this pixel needs special analysis.
|
||||
// thanks to a quite efficient algorithm, we can afford 10x antialiasing :)
|
||||
$opacity = 0.5;
|
||||
if ($x > $y) {
|
||||
// cut the pixel into 10 vertical "stripes"
|
||||
for ($dx = -0.45; $dx < 0.5; $dx += 0.1) {
|
||||
// find out where the rounded corner edge intersects with the stripe
|
||||
// this is plain triangle geometry.
|
||||
$dy = $r - $y - sqrt($r_2 - ($r -$x -$dx) * ($r -$x -$dx));
|
||||
$dy = ($dy > 0.5) ? 0.5 : (($dy < -0.5) ? -0.5 : $dy);
|
||||
// count the opaque part of the stripe.
|
||||
$opacity -= 0.1 * $dy;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// cut the pixel into 10 horizontal "stripes"
|
||||
for ($dy = -0.45; $dy < 0.5; $dy += 0.1) {
|
||||
// this is the math:
|
||||
// ($r-$x-$dx)^2 + ($r-$y-$dy)^2 = $r^2
|
||||
// $dx = $r - $x - sqrt($r^2 - ($r-$y-$dy)^2)
|
||||
$dx = $r - $x - sqrt($r_2 - ($r -$y -$dy) * ($r -$y -$dy));
|
||||
$dx = ($dx > 0.5) ? 0.5 : (($dx < -0.5) ? -0.5 : $dx);
|
||||
$opacity -= 0.1 * $dx;
|
||||
}
|
||||
}
|
||||
return ($opacity < 0) ? 0 : (($opacity > 1) ? 1 : $opacity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* imageapi_roundedcorners
|
||||
*/
|
||||
function image_imagemagick_roundedcorners($image, $action) {
|
||||
// Based on the imagemagick documentation.
|
||||
// http://www.imagemagick.org/Usage/thumbnails/#rounded
|
||||
// Create arc cut-outs, then mask them.
|
||||
// Draw black triangles and white circles.
|
||||
// draw circle is center: x,y, and a point on the perimeter
|
||||
$corners = array('tl', 'tr', 'bl', 'br');
|
||||
$radii = $action['independent_corners_set']['radii'];
|
||||
$width = $image->info['width'];
|
||||
$height = $image->info['height'];
|
||||
$tl = $radii['tl'];
|
||||
$tr = $radii['tr'];
|
||||
$bl = $radii['bl'];
|
||||
$br = $radii['br'];
|
||||
|
||||
$drawmask = '';
|
||||
if ($tl) {
|
||||
$drawmask .= " fill black polygon 0,0 0,{$tl} {$tl},0";
|
||||
$drawmask .= " fill white circle {$tl},{$tl} {$tl},0";
|
||||
}
|
||||
if ($tr) {
|
||||
$right = $width -$tr;
|
||||
$drawmask .= " fill black polygon {$right},0 {$width},0 {$width},{$tr}";
|
||||
$drawmask .= " fill white circle {$right},{$tr} {$right},0";
|
||||
}
|
||||
if ($bl) {
|
||||
$bottom = $height -$bl;
|
||||
$drawmask .= " fill black polygon 0,{$bottom} 0,{$height} {$bl},{$height}";
|
||||
$drawmask .= " fill white circle {$bl},{$bottom} 0,{$bottom}";
|
||||
}
|
||||
if ($br) {
|
||||
$bottom = $height -$br;
|
||||
$right = $width -$br;
|
||||
$drawmask .= " fill black polygon {$right},{$height} {$width},{$bottom} {$width},{$height}";
|
||||
$drawmask .= " fill white circle {$right},{$bottom} {$width},{$bottom}";
|
||||
}
|
||||
$draw = ' -draw ' . escapeshellarg($drawmask);
|
||||
|
||||
$compose = ' ' . escapeshellcmd('(') . " +clone -threshold -1 $draw " . escapeshellcmd(')') . ' +matte -compose CopyOpacity -composite ';
|
||||
$image->ops[] = $compose;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of theme_hook() for imagecache_ui.module
|
||||
*/
|
||||
function theme_canvasactions_roundedcorners($variables) {
|
||||
$element = $variables['element'];
|
||||
$data = $element['#value'];
|
||||
if (!empty($data['independent_corners_set']['independent_corners'])) {
|
||||
$dimens = join('px | ', $data['independent_corners_set']['radii']) . 'px';
|
||||
}
|
||||
else {
|
||||
$dimens = "Radius: {$data['radius']}px";
|
||||
}
|
||||
return $dimens;
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test imagecache preset.
|
||||
*
|
||||
* Created on Dec 29, 2009
|
||||
*
|
||||
* @author 'dman' Dan Morrison http://coders.co.nz/
|
||||
*/
|
||||
|
||||
$presets['cheap_dropshadow'] = array (
|
||||
'name' => 'cheap_dropshadow',
|
||||
'#weight' => '3.3',
|
||||
'effects' =>
|
||||
array (
|
||||
-1 => array (
|
||||
'weight' => '-1',
|
||||
'module' => 'imagecache_coloractions',
|
||||
'name' => 'coloractions_convert',
|
||||
'data' => array (
|
||||
'format' => 'image/png',
|
||||
'quality' => '95',
|
||||
),
|
||||
),
|
||||
0 =>
|
||||
array (
|
||||
'weight' => '0',
|
||||
'module' => 'imagecache_canvasactions',
|
||||
'name' => 'canvasactions_definecanvas',
|
||||
'data' =>
|
||||
array (
|
||||
'RGB' =>
|
||||
array (
|
||||
'HEX' => '999999',
|
||||
),
|
||||
'under' => 0,
|
||||
'exact' =>
|
||||
array (
|
||||
'width' => '',
|
||||
'height' => '',
|
||||
'xpos' => 'center',
|
||||
'ypos' => 'center',
|
||||
),
|
||||
'relative' =>
|
||||
array (
|
||||
'leftdiff' => '0',
|
||||
'rightdiff' => '0',
|
||||
'topdiff' => '0',
|
||||
'bottomdiff' => '0',
|
||||
),
|
||||
),
|
||||
),
|
||||
1 =>
|
||||
array (
|
||||
'weight' => '1',
|
||||
'module' => 'imagecache_canvasactions',
|
||||
'name' => 'canvasactions_definecanvas',
|
||||
'data' =>
|
||||
array (
|
||||
'RGB' =>
|
||||
array (
|
||||
'HEX' => '',
|
||||
),
|
||||
'under' => 1,
|
||||
'exact' =>
|
||||
array (
|
||||
'width' => '',
|
||||
'height' => '',
|
||||
'xpos' => 'center',
|
||||
'ypos' => 'center',
|
||||
),
|
||||
'relative' =>
|
||||
array (
|
||||
'leftdiff' => '20',
|
||||
'rightdiff' => '0',
|
||||
'topdiff' => '20',
|
||||
'bottomdiff' => '0',
|
||||
),
|
||||
),
|
||||
),
|
||||
2 =>
|
||||
array (
|
||||
'weight' => '2',
|
||||
'module' => 'imagecache_canvasactions',
|
||||
'name' => 'canvasactions_source2canvas',
|
||||
'data' =>
|
||||
array (
|
||||
'xpos' => 0,
|
||||
'ypos' => 0,
|
||||
'alpha' => '100',
|
||||
),
|
||||
),
|
||||
3 =>
|
||||
array (
|
||||
'weight' => '3',
|
||||
'module' => 'image',
|
||||
'name' => 'image_scale',
|
||||
'data' =>
|
||||
array (
|
||||
'width' => '200',
|
||||
'height' => '100%',
|
||||
'upscale' => 0,
|
||||
),
|
||||
),
|
||||
4 => array (
|
||||
'weight' => '10',
|
||||
'module' => 'imagecache_coloractions',
|
||||
'name' => 'coloractions_convert',
|
||||
'data' => array (
|
||||
'format' => 'image/png',
|
||||
'quality' => '95',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 24 KiB |
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test imagecache preset.
|
||||
*
|
||||
* Created on Dec 29, 2009
|
||||
*
|
||||
* @author 'dman' Dan Morrison http://coders.co.nz/
|
||||
*/
|
||||
|
||||
$presets['keyword_positioning'] = array (
|
||||
'name' => 'keyword_positioning',
|
||||
'#weight' => 4.2,
|
||||
'effects' => array (
|
||||
array (
|
||||
'weight' => '-1',
|
||||
'module' => 'imagecache_canvasactions',
|
||||
'name' => 'canvasactions_file2canvas',
|
||||
'data' => array (
|
||||
'xpos' => 'right',
|
||||
'ypos' => 'top',
|
||||
'alpha' => '100',
|
||||
'path' => drupal_get_path('module', 'imagecache_testsuite') . "/grid-240x160.png",
|
||||
),
|
||||
),
|
||||
|
||||
array (
|
||||
'weight' => '0',
|
||||
'module' => 'imagecache_canvasactions',
|
||||
'name' => 'canvasactions_file2canvas',
|
||||
'data' => array (
|
||||
'xpos' => '25%',
|
||||
'ypos' => 'bottom-10%',
|
||||
'path' => 'misc/druplicon.png',
|
||||
),
|
||||
),
|
||||
|
||||
array (
|
||||
'weight' => '0',
|
||||
'module' => 'imagecache_canvasactions',
|
||||
'name' => 'canvasactions_file2canvas',
|
||||
'data' => array (
|
||||
'xpos' => '0%',
|
||||
'ypos' => 'top+10%',
|
||||
'path' => 'misc/druplicon.png',
|
||||
),
|
||||
),
|
||||
|
||||
array (
|
||||
'weight' => '0',
|
||||
'module' => 'imagecache_canvasactions',
|
||||
'name' => 'canvasactions_file2canvas',
|
||||
'data' => array (
|
||||
'xpos' => 'right+50',
|
||||
'ypos' => '50%',
|
||||
'path' => 'misc/druplicon.png',
|
||||
),
|
||||
),
|
||||
|
||||
),
|
||||
);
|
||||
|
After Width: | Height: | Size: 9.8 KiB |
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test imagecache preset.
|
||||
*
|
||||
* Created on Dec 29, 2009
|
||||
*
|
||||
* @author 'dman' Dan Morrison http://coders.co.nz/
|
||||
*/
|
||||
|
||||
$presets['positioned_underlay'] = array (
|
||||
'name' => 'positioned_underlay',
|
||||
'#weight' => 4.4,
|
||||
'effects' => array (
|
||||
0 => array (
|
||||
'module' => 'image',
|
||||
'name' => 'image_scale',
|
||||
'weight' => '0',
|
||||
'data' => array (
|
||||
'width' => '200',
|
||||
'height' => '',
|
||||
'upscale' => 0,
|
||||
),
|
||||
),
|
||||
1 => array (
|
||||
'module' => 'imagecache_canvasactions',
|
||||
'name' => 'canvasactions_canvas2file',
|
||||
'weight' => '1',
|
||||
'data' => array (
|
||||
'xpos' => '50',
|
||||
'ypos' => 'bottom+50',
|
||||
'alpha' => '100',
|
||||
'path' => "$filepath/shiny-bg.png",
|
||||
'dimensions' => 'background',
|
||||
),
|
||||
),
|
||||
4 => array (
|
||||
'weight' => '10',
|
||||
'module' => 'imagecache_coloractions',
|
||||
'name' => 'coloractions_convert',
|
||||
'data' => array (
|
||||
'format' => 'image/png',
|
||||
'quality' => '95',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
After Width: | Height: | Size: 52 KiB |
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test imagecache preset.
|
||||
*
|
||||
* Created on Dec 29, 2009
|
||||
*
|
||||
* @author 'dman' Dan Morrison http://coders.co.nz/
|
||||
*/
|
||||
|
||||
$presets['rotate_alpha'] = array (
|
||||
'name' => 'rotate_alpha',
|
||||
'#weight' => 1.4,
|
||||
'effects' => array (
|
||||
1 => array (
|
||||
'weight' => '1',
|
||||
'module' => 'image',
|
||||
'name' => 'image_rotate',
|
||||
'data' => array (
|
||||
'degrees' => '15',
|
||||
'random' => 0,
|
||||
'bgcolor' => '',
|
||||
),
|
||||
),
|
||||
3 => array (
|
||||
'weight' => '3',
|
||||
'module' => 'imagecache_coloractions',
|
||||
'name' => 'coloractions_convert',
|
||||
'data' => array (
|
||||
'format' => 'image/png',
|
||||
'quality' => '95',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
After Width: | Height: | Size: 76 KiB |
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test imagecache preset.
|
||||
*
|
||||
* Created on Dec 29, 2009
|
||||
*
|
||||
* @author 'dman' Dan Morrison http://coders.co.nz/
|
||||
*/
|
||||
|
||||
$presets['rotate_alpha_gif'] = array (
|
||||
'name' => 'rotate_alpha_gif',
|
||||
'#weight' => 1.5,
|
||||
|
||||
'effects' => array (
|
||||
1 => array (
|
||||
'weight' => '1',
|
||||
'module' => 'image',
|
||||
'name' => 'image_rotate',
|
||||
'data' => array (
|
||||
'degrees' => '15',
|
||||
'random' => 0,
|
||||
'bgcolor' => '',
|
||||
),
|
||||
),
|
||||
3 => array (
|
||||
'weight' => '3',
|
||||
'module' => 'imagecache_coloractions',
|
||||
'name' => 'coloractions_convert',
|
||||
'data' => array (
|
||||
'format' => 'image/gif',
|
||||
'quality' => '75',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test imagecache preset.
|
||||
*
|
||||
* Created on Dec 29, 2009
|
||||
*
|
||||
* @author 'dman' Dan Morrison http://coders.co.nz/
|
||||
*/
|
||||
|
||||
$presets['rotate_scale'] = array (
|
||||
'name' => 'rotate_scale',
|
||||
'#weight' => 1.2,
|
||||
|
||||
'effects' => array (
|
||||
1 => array (
|
||||
'weight' => '1',
|
||||
'module' => 'image',
|
||||
'name' => 'image_rotate',
|
||||
'data' => array (
|
||||
'degrees' => '15',
|
||||
'random' => 0,
|
||||
'bgcolor' => '',
|
||||
),
|
||||
),
|
||||
2 => array (
|
||||
'weight' => '2',
|
||||
'module' => 'image',
|
||||
'name' => 'image_scale',
|
||||
'data' => array (
|
||||
'width' => '',
|
||||
'height' => '150',
|
||||
'upscale' => TRUE,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
After Width: | Height: | Size: 4.8 KiB |
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test imagecache preset.
|
||||
*
|
||||
* Created on Dec 29, 2009
|
||||
*
|
||||
* @author 'dman' Dan Morrison http://coders.co.nz/
|
||||
*/
|
||||
|
||||
$presets['rotate_scale_alpha'] = array (
|
||||
'name' => 'rotate_scale_alpha',
|
||||
'#weight' => 1.6,
|
||||
|
||||
'effects' => array (
|
||||
1 => array (
|
||||
'weight' => '1',
|
||||
'module' => 'image',
|
||||
'name' => 'image_rotate',
|
||||
'data' => array (
|
||||
'degrees' => '65',
|
||||
'random' => 0,
|
||||
'bgcolor' => '',
|
||||
),
|
||||
),
|
||||
/*
|
||||
* imageapi resize is NOT alpha-safe. This test case proves the bug.
|
||||
* A work-around is to change format before resizing.
|
||||
2 => array (
|
||||
'weight' => '2',
|
||||
'module' => 'imagecache_coloractions',
|
||||
'name' => 'coloractions_convert',
|
||||
'data' => array (
|
||||
'format' => 'image/png',
|
||||
'quality' => '95',
|
||||
),
|
||||
),
|
||||
*/
|
||||
3 => array (
|
||||
'weight' => '3',
|
||||
'module' => 'image',
|
||||
'name' => 'image_scale',
|
||||
'data' => array (
|
||||
'width' => '',
|
||||
'height' => '150',
|
||||
'upscale' => TRUE,
|
||||
),
|
||||
),
|
||||
4 => array (
|
||||
'weight' => '4',
|
||||
'module' => 'imagecache_coloractions',
|
||||
'name' => 'coloractions_convert',
|
||||
'data' => array (
|
||||
'format' => 'image/png',
|
||||
'quality' => '95',
|
||||
),
|
||||
),
|
||||
|
||||
),
|
||||
);
|
||||
|
After Width: | Height: | Size: 28 KiB |
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test imagecache preset.
|
||||
*
|
||||
* Created on Dec 29, 2009
|
||||
*
|
||||
* @author 'dman' Dan Morrison http://coders.co.nz/
|
||||
*/
|
||||
|
||||
$presets['rounded'] = array (
|
||||
'name' => 'rounded',
|
||||
'#weight' => 3.0,
|
||||
'effects' => array (
|
||||
1 => array (
|
||||
'weight' => '0',
|
||||
'module' => 'imagecache_canvasactions',
|
||||
'name' => 'canvasactions_roundedcorners',
|
||||
'data' => array (
|
||||
'radius' => '25',
|
||||
'antialias' => true,
|
||||
),
|
||||
),
|
||||
2 => array (
|
||||
'weight' => '3',
|
||||
'module' => 'imagecache_coloractions',
|
||||
'name' => 'coloractions_convert',
|
||||
'data' =>array (
|
||||
'format' => 'image/png',
|
||||
'quality' => '95',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
After Width: | Height: | Size: 69 KiB |
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test imagecache preset.
|
||||
*
|
||||
* Created on Dec 29, 2009
|
||||
*
|
||||
* @author 'dman' Dan Morrison http://coders.co.nz/
|
||||
*/
|
||||
|
||||
$presets['rounded_bl'] = array (
|
||||
'name' => 'rounded_bl',
|
||||
'#weight' => 3.1,
|
||||
'effects' => array (
|
||||
1 => array (
|
||||
'weight' => '0',
|
||||
'module' => 'imagecache_canvasactions',
|
||||
'name' => 'canvasactions_roundedcorners',
|
||||
'data' => array (
|
||||
'radius' => '50',
|
||||
'independent_corners_set' => array (
|
||||
'independent_corners' => 1,
|
||||
'radii' => array (
|
||||
'tl' => '10',
|
||||
'tr' => '0',
|
||||
'bl' => '50',
|
||||
'br' => '10',
|
||||
),
|
||||
),
|
||||
'antialias' => true,
|
||||
),
|
||||
),
|
||||
2 => array (
|
||||
'weight' => '3',
|
||||
'module' => 'imagecache_coloractions',
|
||||
'name' => 'coloractions_convert',
|
||||
'data' =>array (
|
||||
'format' => 'image/png',
|
||||
'quality' => '95',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
After Width: | Height: | Size: 69 KiB |
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test imagecache preset.
|
||||
*
|
||||
* Created on Dec 29, 2009
|
||||
*
|
||||
* @author 'dman' Dan Morrison http://coders.co.nz/
|
||||
*/
|
||||
|
||||
$presets['rounded_flattened'] = array (
|
||||
'name' => 'rounded_flattened',
|
||||
'#weight' => 3.3,
|
||||
|
||||
'effects' => array (
|
||||
1 => array (
|
||||
'weight' => '0',
|
||||
'module' => 'imagecache_canvasactions',
|
||||
'name' => 'canvasactions_roundedcorners',
|
||||
'data' => array (
|
||||
'radius' => '50',
|
||||
'independent_corners_set' => array (
|
||||
'independent_corners' => 1,
|
||||
'radii' => array (
|
||||
'tr' => '100',
|
||||
'br' => '0',
|
||||
'tl' => '0',
|
||||
'bl' => '0',
|
||||
),
|
||||
),
|
||||
'antialias' => true,
|
||||
),
|
||||
),
|
||||
2 => array (
|
||||
'weight' => '0',
|
||||
'module' => 'imagecache_canvasactions',
|
||||
'name' => 'canvasactions_definecanvas',
|
||||
'data' => array (
|
||||
'RGB' => array (
|
||||
'HEX' => '333333',
|
||||
),
|
||||
'under' => 1,
|
||||
'exact' => array (
|
||||
'width' => '',
|
||||
'height' => '',
|
||||
'xpos' => 'center',
|
||||
'ypos' => 'center',
|
||||
),
|
||||
'relative' => array (
|
||||
'leftdiff' => '2',
|
||||
'rightdiff' => '2',
|
||||
'topdiff' => '2',
|
||||
'bottomdiff' => '2',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
After Width: | Height: | Size: 69 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test imagecache preset.
|
||||
*
|
||||
* Created on Dec 29, 2009
|
||||
*
|
||||
* @author 'dman' Dan Morrison http://coders.co.nz/
|
||||
*/
|
||||
|
||||
$presets['watermark_100'] = array (
|
||||
'name' => 'watermark_100',
|
||||
'#weight' => 4.0,
|
||||
'effects' => array (
|
||||
0 => array (
|
||||
'weight' => '0',
|
||||
'module' => 'imagecache_canvasactions',
|
||||
'name' => 'canvasactions_file2canvas',
|
||||
'data' => array (
|
||||
'xpos' => '10',
|
||||
'ypos' => '5',
|
||||
'alpha' => '100',
|
||||
'path' => 'misc/druplicon.png',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
After Width: | Height: | Size: 8.0 KiB |
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Test imagecache preset.
|
||||
*
|
||||
* Created on Dec 29, 2009
|
||||
*
|
||||
* @author 'dman' Dan Morrison http://coders.co.nz/
|
||||
*/
|
||||
|
||||
$presets['watermark_50'] = array (
|
||||
'name' => 'watermark_50',
|
||||
'#weight' => 4.1,
|
||||
'effects' => array (
|
||||
0 => array (
|
||||
'weight' => '0',
|
||||
'module' => 'imagecache_canvasactions',
|
||||
'name' => 'canvasactions_file2canvas',
|
||||
'data' => array (
|
||||
'xpos' => 'right+20',
|
||||
'ypos' => 'bottom',
|
||||
'alpha' => '50',
|
||||
'path' => 'misc/druplicon.png',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
After Width: | Height: | Size: 8.0 KiB |