Open In App

PHP | Imagick getImagePage() Function

Last Updated : 26 Aug, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

The Imagick::getImagePage() function is an inbuilt function in PHP which is used to get the page geometry of a particular image.

Syntax:

array Imagick::getImagePage( void )

Parameters: This function does not accepts any parameter.

Return Value: This function returns an array associated with the page geometry contains the keys value width, height, x, and y.

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

Program 1:
Original Image:




<?php 
  
// require_once('path/vendor/autoload.php');
    
// Create an Imagick Object
$image = new Imagick(
    
// Use getImagePage function to find the page 
// of image
$res = $image->getImagePage();
  
// Display the result
print_r($res);
?>


Output:

Array ( [width] => 667 [height] => 184 [x] => 0 [y] => 0 ) 

Program 2:
https://media.geeksforgeeks.org/wp-content/uploads/Screenshot-from-2018-10-16-23-23-54-1.png




<?php 
$string = "Computer Science portal for Geeks!"
      
// creating new image of above String 
// and add color and background 
$im = new Imagick(); 
$draw = new ImagickDraw(); 
     
// Fill the color in image 
$draw->setFillColor(new ImagickPixel('green')); 
     
// Set the text font size 
$draw->setFontSize(50); 
     
$metrix = $im->queryFontMetrics($draw, $string); 
$draw->annotation(0, 40, $string); 
$im->newImage($metrix['textWidth'], $metrix['textHeight'], 
         new ImagickPixel('white')); 
              
// Draw the image          
$im->drawImage($draw); 
     
$im->setImageFormat('jpeg');
  
// getImagePage function to find the page 
// of image
$res = $im->getImagePage();
   
// display result
print_r($res);
?>


Output:

Array ( [width] => 0 [height] => 0 [x] => 0 [y] => 0 ) 

Reference: http://php.net/manual/en/imagick.getimagepage.php



Similar Reads

PHP | Imagick floodFillPaintImage() Function
The Imagick floodFillPaintImage() Function is an in-built function in PHP which is used to change the color value of any pixel that matches the target, along with its immediate neighbor pixels of the same color. Note: This method is a replacement for deprecated Imagick::paintFloodFillImage() Function and is available if Imagick has been compiled ag
4 min read
PHP | Imagick adaptiveSharpenImage() Function
The Imagick::adaptiveSharpenImage() function is an inbuilt function in PHP which provides an adaptive sharpen image feature to the image. The intensity of an adaptive sharpen image depends on dramatically decreased at the edge of the image. Syntax: bool Imagick::adaptiveSharpenImage ( $radius, $sigma, $channel ) Parameters: This function accepts th
1 min read
PHP | Imagick flopImage() Function
The Imagick::flopImage() function is an inbuilt function in PHP which is used to create a horizontal mirror image. Syntax: bool Imagick::flopImage( void ) Parameters: This function does not accept any parameter. Return Value: This function returns True on success. Below programs illustrate the Imagick::flopImage() function in PHP: Program 1: Origin
1 min read
PHP | Imagick setImageExtent() Function
The Imagick::setImageExtent() function is an inbuilt function in PHP which is used to set the image size. This function doesn't scales the image but crops the unwanted parts. Syntax: bool Imagick::setImageExtent( int $columns, int $rows ) Parameters: This function accepts two parameters as mentioned above and described below: $columns: It specifies
1 min read
PHP | Imagick getImageWhitePoint() Function
The Imagick::getImageWhitePoint() function is an inbuilt function in PHP which is used to get the chromaticity white point of an Imagick object. Syntax: bool Imagick::getImageWhitePoint( void) Parameters: This function does not accept any parameter. Return Value: This function returns the chromaticity white point as an associative array with the ke
1 min read
PHP | Imagick getCompressionQuality() Function
The Imagick::getCompressionQuality() function is an inbuilt function in PHP which is used to get the object compression quality. Syntax: int Imagick::getCompressionQuality( void ) Parameters: This function does not accept any parameters. Return Value: This function returns an integer value on success. Below programs illustrate the Imagick::getCompr
1 min read
PHP | Imagick clear() Function
The Imagick::clear() function is an inbuilt function in PHP which is used to clear all resource allocated to an Imagick object. Syntax: bool Imagick::clear( void ) Parameters: This function does not accept any parameter. It just clears off the resources of the Imagick object which is used to call the function. Return Value: This function returns tr
2 min read
PHP | Imagick annotateImage() Function
The Imagick::annotateImage() function is an inbuilt function in PHP which is used to annotates an image with text. This function returns True on success. Syntax: bool Imagick::annotateImage( $draw_settings, $x, $y, $angle, $text ) Parameters: This function accepts five parameters as mentioned above and described below: $draw_settings: This paramete
2 min read
PHP | Imagick adaptiveResizeImage() Function
The Imagick::adaptiveResizeImage() function is an inbuilt function in PHP which provides an adaptively resize image feature to the image. The intensity of an adaptive resize image depends on dramatically decreased at the edge of the image. This function is used to resize the image according to web sites. It is useful when it shrinks the images slig
1 min read
PHP | Imagick adaptiveBlurImage() Function
The Imagick::adaptiveBlurImage() function is an inbuilt function in PHP which is used to add adaptive blur filter in the given image. The intensity of an adaptive blur depends is dramatically decreased at the edge of the image, whereas a standard blur is a uniform across the image. This effect makes the image unclear or less distinct. Syntax: bool
2 min read