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:

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