Open In App

PHP | Imagick getPage() Function

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

The Imagick::getPage() function is an inbuilt function in PHP which is used to return the geometry of page associated with Imagick object in associative array format.

Syntax:

array Imagick::getPage( void )

Parameters:This function does not accept any parameter.

Return Value: This function returns an associative array with the keys “width”, “height”, “x”, and “y”.

Errors/Exceptions: This function throws ImagickException on error.

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

Program 1:




<?php
  
// Create a new imagick object
$imagick = new Imagick(
  
// Get the Page Geometry
$geometry = $imagick->getPage();
  
print_r($geometry);
?>


Output:

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

Program 2:




<?php
  
// Create a new imagick object
$imagick = new Imagick(
  
// Set the Page Geometry
$imagick->setPage(200, 300, 0, 0);
  
// Get the Page Geometry
$geometry = $imagick->getPage();
  
print_r($geometry);
?>


Output:

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

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


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads