我想为图像模仿 ImageMagick 中的 box-shadow CSS 属性。我希望它的行为完全相同。是否有任何功能或等效映射?
问问题
1320 次
2 回答
3
<?php
/* Read the image into the object */
$im = new Imagick( 'a.jpg' );
$im->setImageFormat("png");
/* Make the image a little smaller, maintain aspect ratio */
$im->thumbnailImage( 200, null );
/* 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, 3, 5, 5 );
/* Imagick::shadowImage only creates the shadow. That is why the original image is composited over it */
$shadow->compositeImage( $im, Imagick::COMPOSITE_OVER, 0, 0 );
/* Display the image */
header( "Content-Type: image/jpeg" );
echo $shadow;
?>
于 2012-07-25T15:14:34.380 回答
1
我认为您正在寻找的是Imagick::shadowImage(CLI 的-shadow 开关)
于 2012-07-25T15:13:05.753 回答