Friday, November 14, 2025
HomeLanguagesPHP | Gmagick getimageheight() Function

PHP | Gmagick getimageheight() Function

The Gmagick::getimageheight() function is an inbuilt function in PHP which is used to get the image height which is the vertical length of the image.

Syntax:

int Gmagick::getimageheight( void )

Parameters: This function doesn’t accept any parameters.

Return Value: This function returns an integer value containing the height of image.

Exceptions: This function throws GmagickException on error.

Below given programs illustrate the Gmagick::getimageheight() function in PHP:

Used Image:

Program 1:




<?php
  
// Create a new Gmagick object
$gmagick = new Gmagick('neveropen.png');
  
// Get the image height
$height = $gmagick->getimageheight();
echo $height;
?>


Output:

184

Program 2:




<?php
  
// Create a new Gmagick object
$gmagick = new Gmagick('neveropen.png');
  
// Set the image height
$gmagick->scaleimage(200, 200);
  
// Get the image height
$height = $gmagick->getimageheight();
echo $height;
?>


Output:

200

Reference: https://www.php.net/manual/en/gmagick.getimageheight.php

RELATED ARTICLES

Most Popular

Dominic
32399 POSTS0 COMMENTS
Milvus
95 POSTS0 COMMENTS
Nango Kala
6765 POSTS0 COMMENTS
Nicole Veronica
11917 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11984 POSTS0 COMMENTS
Shaida Kate Naidoo
6889 POSTS0 COMMENTS
Ted Musemwa
7142 POSTS0 COMMENTS
Thapelo Manthata
6837 POSTS0 COMMENTS
Umr Jansen
6840 POSTS0 COMMENTS