Open In App

PHP | Imagick getSize() Function

Last Updated : 28 Nov, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
The Imagick::getSize() function is an inbuilt function in PHP which is used to get the size associated with the imagick object. Syntax:
array Imagick::getSize( void )
Parameters: This function doesn’t accepts any parameter. Return Value: This function returns an array with the keys "columns" and "rows". Exceptions: This function throws ImagickException on error. Below given programs illustrate the Imagick::getSize() function in PHP: Program 1: php
<?php

// Create a new imagick object
$imagick = new Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png');

// Get the size
$size = $imagick->getSize();
print("<pre>".print_r($size, true)."</pre>");
?>
Output:
Array
(
    [columns] => 0
    [rows] => 0
)
Program 2: php
<?php

// Create a new imagick object
$imagick = new Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png');

// Set the size
$imagick->setSize('200', '400');

// Get the size
$size = $imagick->getSize();
print("<pre>".print_r($size, true)."</pre>");
?>
Output:
Array
(
    [columns] => 200
    [rows] => 400
)
Reference: https://www.php.net/manual/en/imagick.getsize.php

Next Article

Similar Reads