Can we list here what actions have imagemagick support and which ones need to be coded?

Comments

dman’s picture

I guess...
From my side of the fence in imagecache_actions it's pretty much everything
imageapi.module provides:
- {toolkit}_image_crop
- {toolkit}_image_resize
- {toolkit}_image_sharpen
- {toolkit}_image_rotate
- {toolkit}_image_desaturate

Imagecache actions here needs extensions for :

- {toolkit}_image_overlay
- define_canvas (currently not abstracted to a toolkit callback, gd-native only)

- colorshift_image
- brightness_image
- inverse_image
... these all are grouped into in a toolkit abstraction called {toolkit}_image_imagefilter which provides a call to the toolkit or an algorithmic implimentation if the right libraries are not available.
This is only for terse coding reasons optimized for gd as it's just the same function call there, dunno if it makes things more difficult for imagemagick.

- {toolkit}_image_overlaytext_alpha

Any or all of them can be tackled by anyone who needs them.
The imagefilters are probably the easiest (I started with them also), and the image_overlay is most in demand.
Not sure about how tricky text is.

/**
 * Place text on an image.
 *
 * @ingroup imageapi
 */
function imageapi_image_overlaytext_alpha(&$image, $text, $size = 12, $x = 0, $y = 0, $RGB = 0, $fontfile = 'MgOpenModernaBold', $angle = 0) {
  return call_user_func($image->toolkit .'_image_overlaytext_alpha', $image, $text, $size, $x, $y, $RGB, $fontfile, $angle);
}
mikeytown2’s picture

I took a peak at imageapi_imagemagick.module and the code is fairly straight forward. Sharpen is the most complicated function in the module and it's quite simple

function imageapi_imagemagick_image_sharpen(&$image, $radius, $sigma, $amount, $threshold) {
  $unsharp_arg = $radius .'x'. $sigma .'+'. $amount/100 .'+'. $threshold;
  $image->ops[] = '-unsharp '. $unsharp_arg;
  return true;
}





Since you brought up text, lets try to get this done...
The user docs for imagemagick are quite good so i'll use this one as a template.
http://www.imagemagick.org/Usage/annotating/#wmark_text

something like this?

function imageapi_imagemagick_image_overlaytext(&$image, $text, $size = 14, $gravity, $x = 0, $y = 0, $RGB_HEX, $fontfile = 'Courier', $angle = 0) {
	// set font color
	// http://www.imagemagick.org/script/command-line-options.php#fill 
	// -fill "#ddddff" ...
	$fill_arg = '"#' . $RGB_HEX . '"';
	// -fill "rgb(255,255,255)" ...
	$fill_arg = '"rgb(' . $red . ',' . $green . ',' . $blue ')';

	// set font
	// http://www.imagemagick.org/script/command-line-options.php#font 
	// http://www.imagemagick.org/script/command-line-options.php#text-font 
	$font_arg = $fontfile;

	// set font size
	// http://www.imagemagick.org/script/command-line-options.php#pointsize 
	$pointsize_arg = $size;

	// set global text position
	// http://www.imagemagick.org/script/command-line-options.php#gravity 
	$gravity_arg = $gravity;

	// set local text postion
	// http://www.imagemagick.org/script/command-line-options.php#geometry 
	$text_offset_arg = $x .','. $y;

	// set text angle
	// http://www.imagemagick.org/script/command-line-options.php#rotate 
	$rotate_arg = $angle;

	// draw it
	// http://www.imagemagick.org/script/command-line-options.php#draw 
	$image->ops[] = '-font '. $font_arg . '-pointsize ' . $pointsize_arg . '-draw "rotate ' . $rotate_arg . 'gravity ' . $gravity_arg . 'fill ' . $fill_arg . 'text ' . $text_offset_arg . "'" . $text . "'". '"';
	return true;
}
mikeytown2’s picture

Found a library...
http://www.francodacosta.com/phmagick

I might get around to doing this, but its quite low on my priority list.

francodacosta’s picture

hi mikeytown2

If you need help implementing phMagick or with ImageMagick, just drop me a note I will do my best to help

sven _AT_ francodacosta _DOT_ com

cheers

wqmeng’s picture

Which thread I should scrib ?

http://articlesforge.com/

dman’s picture

Status: Active » Closed (won't fix)

The text rendering method is entirely rewritten in 6.x-2.x-dev
Best not to go further down this path right now.
The successor to this library will be called imageapi_text, and be funky

asb’s picture

Version: 6.x-1.1 » 6.x-2.x-dev
Status: Closed (won't fix) » Active

The project page still states: "Many imagecache actions just do not work with the ImageMagick Toolkit", and I still don't know how to figure out what is supported without GD.

Could we please get an updated list, as mikeytown2 originally asked for on December 3, 2008?

Thanks!

dman’s picture

Distributed with the 6.x-2.x package is the optional module "Imagecache Test Suite"
That provides a page that lists a demo of uses of a large number of actions, with gd and imagemagick versions and results side by side.

asb’s picture

Status: Active » Closed (fixed)

OK, then I have simply to install the module and the sub-module to figure that out ;)

dman’s picture

It's contextual help and always sure to be up-to-date with the version you chose :-}.
Making a list somewhere else would get outdated