📜  PHP | Gmagick setimagerenderingintent()函数

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

PHP | Gmagick setimagerenderingintent()函数

Gmagick::setimagerenderingintent()函数是PHP中的一个内置函数,用于设置图像渲染意图。
句法:

Gmagick Gmagick::setimagerenderingintent( $rend_intent )

参数:此函数接受单个参数$rend_intent指定图像的渲染意图。
返回值:此函数在成功时返回 Gmagick 对象。
下面的程序说明了PHP中的Gmagick::setimagerenderingintent()函数:
方案一:
原图:

https://media.geeksforgeeks.org/wp-content/uploads/geeks-21.png

php
getImageRenderingIntent();
echo "Before: " . $res ."
";   // setimagerenderingintent function $im->setimagerenderingintent(17);   // using getImageRenderingIntent function $res = $im->getImageRenderingIntent();   // Display result echo "After: " . $res; ?>


php
setFillColor(new GmagickPixel('green'));
 
// Set the text font size
$draw->setFontSize(50);
 
$matrix = $im->queryFontMetrics($draw, $string);
$draw->annotation(0, 40, $string);
$im->newImage($matrix['textWidth'], $matrix['textHeight'],
        new GmagickPixel('white'));
// Draw the image        
$im->drawImage($draw);
$im->setImageFormat('jpeg');
 
// using getImageRenderingIntent function
$res = $im->getImageRenderingIntent();
echo "Before: " . $res ."
";   // setimagerenderingintent function $im->setimagerenderingintent(10);   // using getImageRenderingIntent function $res = $im->getImageRenderingIntent();   // Display result echo "After: " . $res; ?>


输出:

Before: 2
After: 17

方案二:
原图:

https://media.geeksforgeeks.org/wp-content/uploads/Screenshot-from-2018-10-16-23-23-54.png

PHP

setFillColor(new GmagickPixel('green'));
 
// Set the text font size
$draw->setFontSize(50);
 
$matrix = $im->queryFontMetrics($draw, $string);
$draw->annotation(0, 40, $string);
$im->newImage($matrix['textWidth'], $matrix['textHeight'],
        new GmagickPixel('white'));
// Draw the image        
$im->drawImage($draw);
$im->setImageFormat('jpeg');
 
// using getImageRenderingIntent function
$res = $im->getImageRenderingIntent();
echo "Before: " . $res ."
";   // setimagerenderingintent function $im->setimagerenderingintent(10);   // using getImageRenderingIntent function $res = $im->getImageRenderingIntent();   // Display result echo "After: " . $res; ?>

输出:

Before: 2
After: 10 

参考: http: PHP。 PHP