Open In App

PHP | Imagick getImageVirtualPixelMethod() Function

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

Syntax:



int Imagick::getImageVirtualPixelMethod( void )

Parameters: This function doesn’t accepts any parameter.

Return Value: This function returns an integer value corresponding to one of VIRTUALPIXELMETHOD constants.



All VIRTUALPIXELMETHOD constants are given below:

Exceptions: This function throws ImagickException on error.

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

Program 1:




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

Output:

 0 // Which corresponds to imagick::VIRTUALPIXELMETHOD_UNDEFINED.

Program 2:




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

Output:

 8 // Which corresponds to imagick::VIRTUALPIXELMETHOD_TRANSPARENT.

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


Article Tags :