PHP | Gmagick setimageblueprimary()函数
Gmagick::setimageblueprimary()函数是PHP中的一个内置函数,用于设置特定图像通道的深度。
句法:
Gmagick Gmagick::setimageblueprimary( $x, $y )
参数:该函数接受上面提到的两个参数,如下所述:
- $x:它指定蓝色的主要 x 点。
- $y:它指定蓝色的主要 y 点。
返回值:此函数返回一个包含点的 x 和 y 坐标的数组。
下面的程序说明了PHP中的Gmagick::setimageblueprimary()函数:
方案一:
原图:
PHP
// Create new Gmagick object
$Gmagick = new Gmagick(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-15.png');
// Using getImageBluePrimary function
echo "Before Set Blue Primary: ";
$res = $Gmagick->getImageBluePrimary();
print_r($res);
// Set blue primary point
$Gmagick->setImageBluePrimary( 1.765, 2.5698 );
echo " After Set Blue Primary: ";
$res = $Gmagick->getImageBluePrimary();
print_r($res);
?>
PHP
setFillColor(new GmagickPixel('green'));
// Set the text font size
$draw->setFontSize(50);
$metrix = $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 getImageBluePrimary function
echo "Before Set Blue Primary: ";
$res = $im->getImageBluePrimary();
print_r($res);
// Set blue primary point
$im->setImageBluePrimary(20.765, 14.1698);
echo " After Set Blue Primary: ";
$res = $im->getImageBluePrimary();
print_r($res);
?>
输出:
Before Set Blue Primary: Array ( [x] => 0.15000000596046 [y] =>
0.059999998658895 )
After Set Blue Primary: Array ( [x] => 1.765 [y] => 2.5698 )
方案二:
原图:
PHP
setFillColor(new GmagickPixel('green'));
// Set the text font size
$draw->setFontSize(50);
$metrix = $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 getImageBluePrimary function
echo "Before Set Blue Primary: ";
$res = $im->getImageBluePrimary();
print_r($res);
// Set blue primary point
$im->setImageBluePrimary(20.765, 14.1698);
echo " After Set Blue Primary: ";
$res = $im->getImageBluePrimary();
print_r($res);
?>
输出:
Before Set Blue Primary: Array ( [x] => 0.15000000596046 [y] =>
0.059999998658895 )
After Set Blue Primary: Array ( [x] => 20.765 [y] => 14.1698 )
参考: http: PHP。 PHP