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
32688 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7057 POSTS0 COMMENTS
Nicole Veronica
12198 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12293 POSTS0 COMMENTS
Shaida Kate Naidoo
7182 POSTS0 COMMENTS
Ted Musemwa
7447 POSTS0 COMMENTS
Thapelo Manthata
7160 POSTS0 COMMENTS
Umr Jansen
7150 POSTS0 COMMENTS