略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Imagick::shadowImage

2024-11-13

Imagick::shadowImage

(PECL imagick 2, PECL imagick 3)

Imagick::shadowImageSimulates an image shadow

说明

public Imagick::shadowImage(
    float $opacity,
    float $sigma,
    int $x,
    int $y
): bool

Simulates an image shadow.

参数

opacity

sigma

x

y

返回值

成功时返回 true

范例

示例 #1 Imagick::shadowImage()

<?php
function shadowImage($imagePath) {
    
$imagick = new \Imagick(realpath($imagePath));
    
$imagick->shadowImage(0.410505);
    
header("Content-Type: image/jpg");
    echo 
$imagick->getImageBlob();
}

?>
add a noteadd a note

User Contributed Notes 1 note

up
1
nilayanand at gmail dot com
12 years ago
<?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;
?>

官方地址:https://www.php.net/manual/en/imagick.shadowimage.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3