Friday, June 19, 2026
HomeLanguagesPHP | Imagick fxImage() Function

PHP | Imagick fxImage() Function

  • The Imagick::fxImage() function is an inbuilt function in PHP which evaluate expression for each pixel in the image.
  • The Imagick::fxImage() function allows you to perform image manipulation by processing set of FX expressions for each pixel with in the image.

Syntax:

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

Parameters:

  • $expression It is FX expressions for image Manipulation.
  • $channel Any channel constant can be fetched based on valid channel mode. If more channel constant need to add use bitwise operators to merge channeltype constants.
  • Imagick::fxImage function will returns TRUE if success or returns FALSE on failure.

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

php




<?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




<?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

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

2 COMMENTS

Most Popular

Dominic
32516 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6898 POSTS0 COMMENTS
Nicole Veronica
12014 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12110 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6965 POSTS0 COMMENTS