📜  PHP | Gmagick blurimage()函数

📅  最后修改于: 2022-05-13 01:56:30.761000             🧑  作者: Mango

PHP | Gmagick blurimage()函数

Gmagick::blurimage()函数是PHP中的一个内置函数,用于为图像添加模糊滤镜。

句法:

Gmagick Gmagick::blurimage( $radius, $sigma, $channel )


参数:此函数接受三个参数,如上所述,如下所述:

  • $radius:此参数用于设置图像中的模糊半径。
  • $sigma:设置标准差。
  • $channel:此参数设置通道类型常量。如果未提供,则所有通道都将模糊。

返回值:此函数在成功时返回 True。

错误/异常:此函数在错误时抛出 GmagickException。

下面的程序说明了PHP中的Gmagick::blurimage()函数:

原图:

方案一:

blurimage(7, 8);
  
header('Content-type: image/png'); 
    
// Ouput the image 
echo $gmagick; 
?> 

输出:

方案二:

setStrokeOpacity(1); 
$draw->setStrokeColor('Red'); 
$draw->setFillColor('Green'); 
    
// Set the width and height of image 
$draw->setStrokeWidth(7); 
$draw->setFontSize(72); 
     
// Function to draw circle  
$draw->circle(250, 250, 100, 150); 
   
$gmagick = new Gmagick(); 
$gmagick->newImage(500, 500, 'White'); 
$gmagick->setImageFormat("png"); 
$gmagick->drawImage($draw); 
  
// Use blurimage() function 
$gmagick->blurimage(7, 5);
  
// Display the output image 
header("Content-Type: image/png"); 
echo $gmagick->getImageBlob(); 
?> 

输出:

参考: http: PHP。 PHP