Open In App

PHP | Imagick fxImage() Function

Syntax:

Imagick::fxImage ( string $expression [, int $channel = Imagick::CHANNEL_DEFAULT ] )

Parameters:



Example 1: To illustrate image manipulation by FX expression using Imagick::fxImage() function. 




<?php
// Imagick-fxImage
$imagick = new \Imagick();
    //new pseudo image
    $imagick->newPseudoImage(200, 200, "gradient:white-black");
 
    //$fx value applied
    $fx = 'floor(s*10+0.5)/10';
    $fxImage = $imagick->fxImage($fx);
//Display Image
    header("Content-Type: image/png");
    $fxImage->setimageformat('png');
    echo $fxImage->getImageBlob();
?>

Output: Example 2: To illustrate image manipulation by FX expression using Imagick::fxImage() function. 






<?php
// Imagick-fxImage
$imagick = new \Imagick();
 
// New pseudo image
    $imagick->newPseudoImage(200, 200, "plasma:fractal");
 
    // $fx value applied
    $fx = '(u.g+v.g)/2';
    $fxImage = $imagick->fxImage($fx);
 
    // Display Image
    header("Content-Type: image/png");
    $fxImage->setimageformat('png');
    echo $fxImage->getImageBlob();
    $fxImage->WriteImage('Imagick-fxImageex02.png');
?>

Output: Reference: https://www.php.net/manual/en/imagick.fximage.php


Article Tags :