PHP | imageresolution() Function Last Updated : 28 Apr, 2025 Comments Improve Suggest changes Like Article Like Report The imageresolution() function is an inbuilt function in PHP which is used to set and return the resolution of an image in DPI (dots per inch). If none of the optional parameters is given, the current resolution is returned as an indexed array. If one of the optional parameters is given it will set both width and height to that parameter. The resolution is only used as meta information when images are read from and written to formats supporting this kind of information (currently PNG and JPEG). It does not affect how the image looks. The default resolution for new images is 96 DPI.Syntax: mixed imageresolution( resource $image, int $res_x, int $res_y ) Parameters: This function accepts three parameters as mentioned above and described below: $image: It specifies the image resource to work on.$res_x (Optional): It specifies the horizontal resolution in DPI.$res_y (Optional): It specifies the vertical resolution in DPI. Return Value: This function returns the indexed array when used as getter and when used as setter returns TRUE on success or FALSE on failure.Below examples illustrate the imageresolution() function in PHP:Example 1: In this example we will get the resolution of the image. php <?php // Load the png image $image = imagecreatefrompng( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Get the image resolution $imageresolution = imageresolution($image); print("<pre>".print_r($imageresolution, true)."</pre>"); ?> Output: Array ( [0] => 96 [1] => 96 ) Example 2: In this example we will set the resolution of the image, php <?php // Load the png image $image = imagecreatefrompng( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Set the resolution imageresolution($image, 400, 200); // Get the image resolution $imageresolution = imageresolution($image); print("<pre>".print_r($imageresolution, true)."</pre>"); ?> Output: Array ( [0] => 400 [1] => 200 ) Reference: https://www.php.net/manual/en/function.imageresolution.php Comment More infoAdvertise with us Next Article PHP | imageresolution() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-image-functions Similar Reads PHP | imageconvolution() Function The imageconvolution() function is an inbuilt function in PHP which is used to modify the image content. It applies a 3 x 3 convolution matrix in the image, using the given coefficient and offset. This function returns true on success or false on failure. Syntax: bool imageconvolution ( $image, $mat 2 min read PHP | imagecropauto() Function The imagecropauto() function is an inbuilt function in PHP which is used to crop an image automatically using one of the available modes. Syntax: resource imagecropauto( resource $image, int $mode, float $threshold, int $color ) Parameters: This function accepts four parameters as mentioned above an 2 min read PHP | Imagick getImageResolution() Function The Imagick::getImageResolution() function is an inbuilt function in PHP which is used to get the resolution of an image object. Syntax: bool Imagick::getImageResolution( void) Parameters: This function does not accept any parameter. Return Value: This function returns the resolution as an array. Be 2 min read PHP | Gmagick getimageresolution() Function The Gmagick::getimageresolution() function is an inbuilt function in PHP which is used to get the resolution of an image object. Syntax: array Gmagick::getimageresolution( void ) Parameters: This function does not accept any parameter. Return Value: This function returns the resolution as an array. 2 min read PHP | imagesetinterpolation() Function The imagesetinterpolation() function is an inbuilt function in PHP which is used to set the interpolation method, setting an interpolation method affects the rendering of various functions such as the imagerotate() function.Syntax:Â Â bool imagesetinterpolation( resource $image, int $method )Parameter 2 min read Like