OK, here's a total re-write of the plugins I developed a few months ago.
Now we have a hook system that makes sense, I can do the lot as a stand-alone module

BUT...
I don't want to branch these off into a new project. I'd rather submit them to live as optionals inside this package - so as to avoid them going too strangely out of synch.

I think a TODO is to split these funcs off into their own include - to lighten the server load, but that looks easy.

here's the readme and a few recipes.

Imagecache actions
-------------------
  Additional actions for imagecache processing.
 
  Exposes some of the simpler PHP 'imagefilter' actions (colorshift,
  brightness, negative) 
  -  A transparency masker for merging with backgrounds. 
  -  A pseudo - file conversion feature.
 
   Compatible with the 2008 revision (imagecache 2)

Comments

dman’s picture


eaton’s picture

dman, this is pretty spectacular stuff. I just ran it through its paces and it seems to work pretty well, though I was getting quite a few errors thrown with complaints about how imagefilter() requires certain numbers of parameters. The following changed version of imagecache_gd_imagefilter() seems to fix it, ensuring that only the proper number of params is ever passed in for each filter. Not sure if this is just masking the problem, but all the options are now working like a charm on my setup. I'd love to see these make it into the base imagecache setup.

function imagecache_gd_imagefilter($image, $filter, $arg1, $arg2 = NULL, $arg3 = NULL) {
  // some distros that allegedly include PHP5 GD2 are faulty.
  // thankyou http://www.weberdev.com/get_example-4601.html
  if (!function_exists('imagefilter')) {
    include_once('imagefilter.inc');
  }
  $info = $image->info;
  if (!$info) {
    return FALSE;
  }
  #dpm("run imagefilter imagefilter($image->res, $filter, $arg1, $arg2, $arg3)");

  imagesavealpha($image->res, TRUE);
  if (!is_null($arg2) && !is_null($arg3)) {
    return imagefilter($image->res, $filter, $arg1, $arg2, $arg3);
  }
  else if (!is_null($arg2) && is_null($arg3)) {
    return imagefilter($image->res, $filter, $arg1, $arg2);
  }
  else if (is_null($arg2) && is_null($arg3)) {
    return imagefilter($image->res, $filter, $arg1);
  }
}
dman’s picture

Thanks for finding that. I've never known PHP functions to complain about getting too many parameters before, when the spec has them with a variable number or args. It has a point though...
Actually, I wasn't even testing the true PHP imagefilter - I thought it would just work, but I hadn't installed it myself. I supplied an optional library that will do the jobs even if the extension isn't enabled, because deployment issues are important..

If that's the case, then that stub function I'm using in the middle there isn't as much of a lazy short-cut as I thought it was.

Anyway, if this is moving in the right direction, I also have, waiting in the wings, an SVG process (!) which can do rounded corners, drop shadows, ornamental frames and watermarks (!) ... once you learn and install SVG ;-)

Still, no hurry. I think that someone else may have inspiration for an easier way to do watermarks...

I miss the old all-in-one settings interface. Testing and tweaking this was a bore with all the pageloads.
Oh yeah, back last time I did this, I had a demo 'preview' image for each filter on the page. Maybe I'll see if I can bring that back.

dman’s picture

ping!
Is there any possibility of getting this added under contrib? I don't want to fork it.

dopry’s picture

Status: Needs review » Patch (to be ported)

No, totally gonna get committed next time I have an imagefield work slot.

eaton’s picture

dopry, dman, I'm currently chugging through the D6 ports for image related stuff. If you'd like I can take a stab at a D6 version of this while I'm at it. Any interest?

dman’s picture

No objection. :)
As it's mostly hanging off the imagecache api, I don't know what, if any change there will be to D6, but more eyes on code is cool.

...Just thinking the above patch may need a hook_install to flush the imagecache actions cache on install, against the 'current' code.

dman’s picture

Oh. This add-on may be a renamed into 'imagecache_color_actions' if you feel.
... now that we have imagecache canvas actions also waiting to go. (or shall we call that 'layer' actions)?

dopry’s picture

note... I did add imagefilter and imagerotate to imageapi_gd.... so those functions should be consistantly available now...

dopry’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new129.66 KB

Here is an updated and untested version for changes I made in imageapi if anyone wants to give it a go.. mainly stealing imagefilter.

dman’s picture

This is now released as http://drupal.org/project/imagecache_actions
Closing

dman’s picture

Status: Needs review » Closed (fixed)

CLOSING! :-B