Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

PHP | Imagick getImageVirtualPixelMethod() Function

  • Last Updated : 30 Nov, 2019

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:

  • 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)

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


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!