I'm trying to composite some images using ImageMagick - I know imagemagick via PHP, i'm trying to return the image via PHP but it seems to overwrite the original source file - not ideal as it can apply the filter over and over.
Ideally, I'd like to write the original file with _thumb after it, then call this file via Drupal for display, where it would copy to the appropriate imagecache directory and display from there. Anyone with ImageMagick experience, would be appreciated if you can help.
$location = $image->source;
$newImage = new Imagick($_SERVER['DOCUMENT_ROOT'].'/'.$image->source);
$distort = array( 0.0, 0.0, 0.16, 1.0 );
$newImage->distortImage( Imagick::DISTORTION_BARREL, $distort, TRUE );
$newImage->resizeImage(1600, 1600, Imagick::FILTER_CATROM, 1);
$newImage->cropImage(1500, 1500,60, 50);
$extension_pos = strrpos($fileName, '.'); // find position of the last dot, so where the extension starts
$thumb = substr($fileName, 0, $extension_pos) . '_thumb' . substr($fileName, $extension_pos);
$newImage->writeImage($thumb);
return $thumb;