Friday, September 5, 2025
HomeLanguagesPHP | Imagick setImagePage() Function

PHP | Imagick setImagePage() Function

The Imagick::setImagePage() function is an inbuilt function in PHP which is used to set the image page geometry.

Syntax:

bool Imagick::setImagePage(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 image page.
  • $height: It specifies the height of image page.
  • $x: It specifies the x-coordinate.
  • $y: It specifies the y-coordinate.

Return Value: This function returns TRUE on success.

Errors/Exceptions: This function throws ImagickException on error.

Below programs illustrate the Imagick::setImagePage() function in PHP:

Program 1:




<?php
  
// Create a new imagick object
$imagick = new Imagick(
  
// Set the Image Page
$imagick->setImagePage(100, 400, 0, 0);
  
// Get the Image Page
$geometry = $imagick->getImagePage();
  
print_r($geometry);
?>


Output:

Array ( [width] => 100 [height] => 400 [x] => 0 [y] => 0 )

Program 2:




<?php
  
// Create a new imagick object
$imagick = new Imagick(
  
// Set the Image Page
$imagick->setImagePage(300, 200, 20, 50);
  
// Get the Image Page
$geometry = $imagick->getImagePage();
  
print_r($geometry);
?>


Output:

Array ( [width] => 300 [height] => 200 [x] => 20 [y] => 50 )

Reference: https://www.php.net/manual/en/imagick.setimagepage.php

RELATED ARTICLES

Most Popular

Dominic
32269 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6636 POSTS0 COMMENTS
Nicole Veronica
11802 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11865 POSTS0 COMMENTS
Shaida Kate Naidoo
6752 POSTS0 COMMENTS
Ted Musemwa
7027 POSTS0 COMMENTS
Thapelo Manthata
6703 POSTS0 COMMENTS
Umr Jansen
6721 POSTS0 COMMENTS