Zen Photo - Polaroid-like effect

Fortunately, it is the last time I try to achieve such effect as I am switching gallery to the Zen Photo so lets see result at first:

ZenPhoto Polaroid-like effect

Open zp-core/lib-Imagick.php file and search for zp_imageOutput function.

It should end with line:

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

Replace it with the following code:

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

$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);

// 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->waveImage($amplitude, $wavelength);

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

$rand_sign=rand(0,1); // - +
if ($rand_sign == 0) { $rand_angle = - $rand_angle; }

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

I read a couple of interesting articles to achieve this effect in ZenPhoto: Mikko's blog and Imagick: Maintain (fake) transparency when saving as JPEG.

About Milosz Galazka

Milosz is a Linux Foundation Certified Engineer working for a successful Polish company as a system administrator and a long time supporter of Free Software Foundation and Debian operating system. He is also open for new opportunities and challenges.