Imagick::functionImage

(PECL imagick 2 >= 2.3.0, PECL imagick 3)

Imagick::functionImageApplies a function on the image

Description

public Imagick::functionImage(int $function, array $arguments, int $channel = Imagick::CHANNEL_DEFAULT): bool

Applies an arithmetic, relational, or logical expression to a pseudo image.

See also » ImageMagick v6 Examples - Image Transformations — Function, Multi-Argument Evaluate

This method is available if Imagick has been compiled against ImageMagick version 6.4.9 or newer.

Parameters

function

Refer to this list of function constants

arguments

Array of arguments to pass to this function.

Return Values

Returns true on success.

Errors/Exceptions

Throws ImagickException on error.

Examples

Example #1 Create a sinusoidal gradient

<?php
$imagick 
= new Imagick();
$imagick->newPseudoImage(200200'gradient:black-white');
$arguments = array(3, -90);
$imagick->functionImage(Imagick::FUNCTION_SINUSOID$arguments);

header("Content-Type: image/png");
$imagick->setImageFormat("png");
echo 
$imagick->getImageBlob();
?>

The above example will output something similar to:

Output of create a sinusoidal gradient

Example #2 Create a gradient from the polynomial (4x^2 - 4x + 1)

<?php
$imagick 
= new Imagick();
$imagick->newPseudoImage(200200'gradient:black-white');
$arguments = array(4, -41);
$imagick->functionImage(Imagick::FUNCTION_POLYNOMIAL$arguments);

header("Content-Type: image/png");
$imagick->setimageformat("png");
echo 
$imagick->getImageBlob();
?>

The above example will output something similar to:

Output of create a polynomial gradient

Example #3 Create a complex gradient from the polynomial (4x^2 - 4x^2 + 1) modulated by a sinusoidal gradient

<?php
$imagick1 
= new Imagick();
$imagick1->newPseudoImage(200200'gradient:black-white');
$arguments = array(9, -90);
$imagick1->functionImage(Imagick::FUNCTION_SINUSOID$arguments);

$imagick2 = new Imagick();
$imagick2->newPseudoImage(200200'gradient:black-white');
$arguments = array(0.50);
$imagick2->functionImage(Imagick::FUNCTION_SINUSOID$arguments);
$imagick1->compositeimage($imagick2Imagick::COMPOSITE_MULTIPLY00);

header("Content-Type: image/png");
$imagick1->setImageFormat("png");
echo 
$imagick1->getImageBlob();
?>

The above example will output something similar to:

Output of create complex gradient

Here you can write a comment


Please enter at least 10 characters.
Loading... Please wait.
* Pflichtangabe
There are no comments available yet.

PHP cURL Tutorial: Using cURL to Make HTTP Requests

cURL is a powerful PHP extension that allows you to communicate with different servers using various protocols, including HTTP, HTTPS, FTP, and more. ...

TheMax

Autor : TheMax
Category: PHP-Tutorials

Midjourney Tutorial - Instructions for beginners

There is an informative video about Midjourney, the tool for creating digital images using artificial intelligence, entitled "Midjourney tutorial in German - instructions for beginners" ...

Mike94

Autor : Mike94
Category: KI Tutorials

Basics of views in MySQL

Views in a MySQL database offer the option of creating a virtual table based on the result of an SQL query. This virtual table can be queried like a normal table without changing the underlying data. ...

admin

Autor : admin
Category: mySQL-Tutorials

Publish a tutorial

Share your knowledge with other developers worldwide

Share your knowledge with other developers worldwide

You are a professional in your field and want to share your knowledge, then sign up now and share it with our PHP community

learn more

Publish a tutorial