Wednesday, June 17, 2026
HomeLanguagesPHP | Imagick setPage() Function

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:

  • $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

RELATED ARTICLES

Most Popular

Dominic
32516 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12014 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6964 POSTS0 COMMENTS