Tuesday, October 7, 2025
HomeLanguagesPHP | Imagick getSize() Function

PHP | Imagick getSize() Function

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
  
// Create a new imagick object
$imagick = new Imagick(
  
// Get the size
$size = $imagick->getSize();
print("<pre>".print_r($size, true)."</pre>");
?>


Output:

Array
(
    [columns] => 0
    [rows] => 0
)

Program 2:




<?php
  
// Create a new imagick object
$imagick = new Imagick(
  
// 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

RELATED ARTICLES

Most Popular

Dominic
32340 POSTS0 COMMENTS
Milvus
86 POSTS0 COMMENTS
Nango Kala
6708 POSTS0 COMMENTS
Nicole Veronica
11872 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11936 POSTS0 COMMENTS
Shaida Kate Naidoo
6829 POSTS0 COMMENTS
Ted Musemwa
7090 POSTS0 COMMENTS
Thapelo Manthata
6780 POSTS0 COMMENTS
Umr Jansen
6784 POSTS0 COMMENTS