Open In App

PHP | Imagick setPage() Function

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:

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


Article Tags :