Slide image with shadow using distortImage
<?php
$slideValue = 150;
// Create new object
$im = new Imagick("grnhrs.jpg");
// Resize
$im->thumbnailImage(500,400);
// Set the image format to png
$im->setImageFormat('png');
//Clone the current object
$shadow = $im->clone();
//Set image background color to black (this is the color of the shadow)
$shadow->setImageBackgroundColor( new ImagickPixel( 'black' ) );
//Create the shadow
$shadow->shadowImage( 80, 10, 5, 5 );
// Fill background area with transparent for image
//VIRTUALPIXELMETHOD_TRANSPARENT
$im->setImageVirtualPixelMethod(Imagick::VIRTUALPIXELMETHOD_ TRANSPARENT);
// Activate matte
$im->setImageMatte(true);
//Control points for the distortion
$controlPoints = array( 0, 0,
$slideValue, 0,
0, $im->getImageHeight(),
0, $im->getImageHeight(),
$im->getImageWidth(), 0,
$im->getImageWidth(), 0,
$im->getImageWidth(), $im->getImageHeight(),
$im->getImageWidth()-$slideValue, $im->getImageHeight());
// Perform the distortion
$im->distortImage(Imagick::DISTORTION_PERSPECTIVEPROJECTION, $controlPoints, true);
// Perform the distortion in shadow image
$shadow->distortImage(Imagick::DISTORTION_PERSPECTIVEPROJECTION, $controlPoints, true);
// Imagick::shadowImage only creates the shadow.
// That is why the original image is composited over it
$shadow->compositeImage( $im, Imagick::COMPOSITE_OVER, 0, 0 );
/* Ouput the image */
header("Content-Type: image/png");
echo $shadow;
?>
----
Server IP: 69.147.83.197
Probable Submitter: 125.17.19.5
----
Manual Page -- http://www.php.net/manual/en/function.imagick-distortimage.php
Edit -- https://master.php.net/note/edit/102255
Del: integrated -- https://master.php.net/note/delete/102255/integrated
Del: useless -- https://master.php.net/note/delete/102255/useless
Del: bad code -- https://master.php.net/note/delete/102255/bad+code
Del: spam -- https://master.php.net/note/delete/102255/spam
Del: non-english -- https://master.php.net/note/delete/102255/non-english
Del: in docs -- https://master.php.net/note/delete/102255/in+docs
Del: other reasons-- https://master.php.net/note/delete/102255
Reject -- https://master.php.net/note/reject/102255
Search -- https://master.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.