Open In App

PHP | Imagick getPage() Function

Last Updated : 26 Nov, 2019
Comments
Improve
Suggest changes
Like Article
Like
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
<?php

// Create a new imagick object
$imagick = new Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png');

// Get the Page Geometry
$geometry = $imagick->getPage();

print_r($geometry);
?>
Output:
Array ( [width] => 0 [height] => 0 [x] => 0 [y] => 0 )
Program 2: php
<?php

// Create a new imagick object
$imagick = new Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png');

// 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

Next Article

Similar Reads