Plugin to modify zp-core/lib-Imagick.php file - function zp_imageOut

Hello,

Recently I installed Zen Photo and wanted to add Polaroid-like effect to thumbs and images (effect: http://gallery.sleeplessbeastie.eu/2004/16-december-2004/milo-in-black.jpg ). I modified zp-core/lib-Imagick.php file - function zp_imageOut by replacing line:
`

return $bg->writeImages($filename, true);

`
with code:
`

$im->borderImage("white", 5, 5);

$im->borderImage("grey60", 1,1);

$shadow=$im->clone();

$shadow->setImageBackgroundColor( new ImagickPixel( 'black' ) );

$shadow->shadowImage( 60, 4, 4, 4 );

$shadow->compositeImage( $im, Imagick::COMPOSITE_OVER, 0, 0 );

$bg = $shadow->clone();

$bg->colorFloodFillImage("white", 100, '#777777', 0, 0);

$bg->compositeImage($shadow, Imagick::COMPOSITE_OVER, 0, 0);

$bg->flattenImages();

// wrong place - should be for $im not $bg

$d = $bg->getImageGeometry();

$w = $d['width'];

$h = $d['height'];

$amplitude = $w * 0.01;

$wavelength = $h * (rand(5) + 5);

$bg->rotateImage("white",90);

$bg->waveImage($amplitude, $wavelength);

$bg->rotateImage("white",-90);

$rand_angle=rand(1,7); // get random angle

$rand_sign=rand(0,1); // - +

if ($rand_sign == 0) { $rand_angle = - $rand_angle; }

$bg->rotateImage("white",$rand_angle);

return $bg->writeImages($filename, true);

`

Could someone give me some directions for which hook should I use to move code to a plugin?

Thanks,
Milosz

Comments

  • I don't think this is possible to do in a plugin (yet), but I think this would be a candidate for a filter: one filter at the beginning of image processing and another one at the end. Then you could simply insert the extra code as a filter.
  • Have you looked at the effenberger effects plugin? It does not do "polaroid", but the film effect is a similar application. It does these things with CSS and javaScript, no mods to the zp core needed.
  • Huge thanks for all replies. I read ticket and understand answer.

    On mentioned website there is a http://www.netzgesta.de/instant/ instant.js script that can achieve such effect so I can move to it later.

    Happy evening!
  • FYI: It is pretty quick to try that effect and see how it looks for you. Download the instant.js script from the above web site and the effenberger plugin from http://www.zenphoto.org/2009/12/effenberger_effects/
  • I've implemented a plugin system for Imagick in changeset [6271]. Please read the ticket posted above for instructions on how to make a plugin for Imagick. Also, attached to that ticket is a sample plugin adapted from the code from the first post.
  • Please note that there is a disagreement on the validity of such an implementation. I believe that it is not necessary and adds overhead to a critical path. But more imprortant, it will not work in practice. When the image processor is executing the normal expected Zenphoto environment does not exist. For instance, very few support functions are available. (Only those critical for image processing.) There are no Objects instantiated, either, so all you have so far as information about the image being processed is its name and the name of its album. No theme context such as which theme or even which page of the theme are known.
Sign In or Register to comment.