The Imagick::setPage() function is an inbuilt function in PHP which is used to set the page geometry of the Imagick object.
Syntax:
bool Imagick::setPage( int $width, int $height, int $x, int $y )
Parameters:This function accepts four parameters as mentioned above and described below:
- $width: It specifies the width of the page.
- $height: It specifies the height of the page.
- $x: It specifies the x-coordinate of the page.
- $y: It specifies the y-coordinate of the page.
Return Value: This function returns TRUE on success.
Errors/Exceptions: This function throws ImagickException on error.
Below programs illustrate the Imagick::setPage() function in PHP:
Program 1:
<?php // Create a new imagick object $imagick = new Imagick( // Set the Page Geometry $imagick ->setPage(220, 350, 0, 5); // Get the Page Geometry $geometry = $imagick ->getPage(); print_r( $geometry ); ?> |
Output:
Array ( [width] => 220 [height] => 350 [x] => 0 [y] => 5 )
Program 2:
<?php // Create a new imagick object $imagick = new Imagick( // Set the Page Geometry $imagick ->setPage(200, 100, 8, 16); // Get the Page Geometry $geometry = $imagick ->getPage(); print_r( $geometry ); ?> |
Output:
Array ( [width] => 200 [height] => 100 [x] => 8 [y] => 16 )
Reference: https://www.php.net/manual/en/imagick.setpage.php