Using PHP ImageMagick with ImageCache Custom actions - Returning image
Someone might find this useful as Documentation is very sparse for this (this took me over a day to figure out). The problem was I was writing to a seperate file - Works, but ImageCache will delete it, also defeats the point of using ImageCache.

The solution is as follows, to use $image->ops[] and ImageMagick CMD's. (This is entered in the custom actions of imagecache. Distort image, apply mask, and apply overlay. This is used for creating product images for a Shop with just normal images supplied. I'll probably make a blog post in more depth at some point.

$image-&gt;ops[] = "-distort Barrel '0.0 0.0 0.16 1.0'";
$image-&gt;ops[] = "-resize 1600x1600";
$image-&gt;ops[] = "-crop 1500x1500+60+50";
$image-&gt;ops[] = "'sites/default/files/coushin-bg.png' -compose Dst_In  -gravity center -alpha Set -composite -format png -quality 90 ";
$image-&gt;ops[] = "'sites/default/files/Blank-Cushion.png' -compose Multiply  -composite -format png -quality 90 ";
return $image;