📜  PHP | Gmagick magnifyimage()函数

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

PHP | Gmagick magnifyimage()函数

Gmagick::magnifyimage()函数是PHP中的一个内置函数,用于将图像按比例缩放到 2 倍。此函数将图像缩放为其原始大小的两倍。
句法:

public Gmagick::magnifyimage( void )

参数:此函数不接受任何参数。
返回值:此函数返回放大的 Gmagick 对象。
错误/异常:此函数在错误时抛出 GmagickException。
下面的程序说明了PHP中的Gmagick::magnifyimage()函数:
方案一:
输入图像:

php
magnifyimage();
 
header('Content-type: image/png');
   
// Output the image
echo $gmagick;
?>


php
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 magnifyimage function
$gmagick->magnifyimage();
 
// Display the output image
header("Content-Type: image/png");
echo $gmagick->getImageBlob();
?>


输出:

方案二:

PHP

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 magnifyimage function
$gmagick->magnifyimage();
 
// Display the output image
header("Content-Type: image/png");
echo $gmagick->getImageBlob();
?>

输出:

参考: http: PHP。 PHP