Code: Select all
<?php
//red background
$im = array();
$im[0] = new Imagick();
$im[0]->newImage(780,30,new ImagickPixel('red'));
//button shading
$im[1] = new Imagick();
$im[1]->newPseudoImage(700, 22, 'gradient:#AAAAAA00-#00000060');
$im[1]->roundCorners(3,3);
//area to subtract from red background
$im[2] = new ImagickDraw();
$im[2]->setFillColor( new ImagickPixel('white') );
$im[2]->roundRectangle(0,0,698,20,6,6);
$im[3] = new Imagick();
$im[3]->newImage(705, 25, new ImagickPixel('transparent'));
$im[3]->drawImage($im[2]);
// shadow to place just under subtracted area
$im[4] = clone($im[3]);
$im[4]->setImageBackgroundColor('black');
$im[4]->shadowImage(50,1.5,2,2);
$canvas = new Imagick();
$canvas->newImage(705,26, new ImagickPixel('transparent'));
$canvas->compositeImage($im[0],Imagick::COMPOSITE_MULTIPLY, 0, 0); // background
$canvas->compositeImage($im[4],Imagick::COMPOSITE_MULTIPLY, 0, 0); // shadow
$canvas->compositeImage($im[3],Imagick::COMPOSITE_LIGHTEN, 0, 0, Imagick::CHANNEL_ALL); // cut out
$canvas->compositeImage($im[1],Imagick::COMPOSITE_MULTIPLY, 0, 0); // button shading
$canvas->setImageColorspace(imagick::COLORSPACE_RGB);
$canvas->setImageFormat('png');
$canvas->setCompressionQuality(90);
header('Content-type: image/' . $canvas->getImageFormat());
echo $canvas;
exit();
?>