PHP | Imagick getPage() Function
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( 'https://media.w3wiki.net/wp-content/uploads/w3wiki-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 // Create a new imagick object $imagick = new Imagick( 'https://media.w3wiki.net/wp-content/uploads/w3wiki-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
Contact Us