PHP | Imagick setImageVirtualPixelMethod() Function

The Imagick::setImageVirtualPixelMethod() function is an inbuilt function in PHP which is used to set the image virtual pixel method.

Syntax:

bool Imagick::setImageVirtualPixelMethod( int $method )

Parameters:This function accepts a single parameter $method which contains an integer value corresponding to one of the VIRTUALPIXELMETHOD constants. We can also pass the constant directly like setImageVirtualPixelMethod(imagick::VIRTUALPIXELMETHOD_BLACK);.



All VIRTUALPIXELMETHOD constants are given below:

  • imagick::VIRTUALPIXELMETHOD_UNDEFINED (0)
  • imagick::VIRTUALPIXELMETHOD_BACKGROUND (1)
  • imagick::VIRTUALPIXELMETHOD_CONSTANT (2)
  • imagick::VIRTUALPIXELMETHOD_EDGE (4)
  • imagick::VIRTUALPIXELMETHOD_MIRROR (5)
  • imagick::VIRTUALPIXELMETHOD_TILE (7)
  • imagick::VIRTUALPIXELMETHOD_TRANSPARENT (8)
  • imagick::VIRTUALPIXELMETHOD_MASK (9)
  • imagick::VIRTUALPIXELMETHOD_BLACK (10)
  • imagick::VIRTUALPIXELMETHOD_GRAY (11)
  • imagick::VIRTUALPIXELMETHOD_WHITE (12)
  • imagick::VIRTUALPIXELMETHOD_HORIZONTALTILE (13)
  • imagick::VIRTUALPIXELMETHOD_VERTICALTILE (14)

Return Value: This function returns TRUE on success.

Below programs illustrate the Imagick::setImageVirtualPixelMethod() function in PHP:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create a new imagick object
$imagick = new Imagick(
  
// Set the Virtual Pixel Method
$imagick->setImageVirtualPixelMethod(imagick::VIRTUALPIXELMETHOD_BLACK);
  
// Get the Virtual Pixel Method
$virtualPixelMethod = $imagick->getImageVirtualPixelMethod();
echo $virtualPixelMethod;
?>

chevron_right


Output:

 10 // Which corresponds to imagick::VIRTUALPIXELMETHOD_BLACK.

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create a new Imagick object
$imagick = new Imagick(
  
// Set the Virtual Pixel Method
$imagick->setImageVirtualPixelMethod(imagick::VIRTUALPIXELMETHOD_TILE);
  
// Get the Virtual Pixel Method
$virtualPixelMethod = $imagick->getImageVirtualPixelMethod();
echo $virtualPixelMethod;
?>

chevron_right


Output:

 7 // Which corresponds to imagick::VIRTUALPIXELMETHOD_TILE.

Reference: https://www.php.net/manual/en/imagick.setimagevirtualpixelmethod.php




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.