PHP | Gmagick setimageunits() Function Last Updated : 23 Jul, 2021 Comments Improve Suggest changes Like Article Like Report The Gmagick::setimageunits() function is an inbuilt function in PHP which is used to set the units of resolution of a particular image. This function has no visual impact on the image but just changes the units of resolution which can be one of Undefinedresolution, PixelsPerInchResolution, or PixelsPerCentimeterResolution. Syntax: Gmagick Gmagick::setimageunits( int $resolution ) Parameters: This function accepts a single parameter $resolution which holds an integer corresponding to one of the RESOLUTION constants. List of all RESOLUTION constants are given below: Gmagick::RESOLUTION_UNDEFINED (0) Gmagick::RESOLUTION_PIXELSPERINCH (1) Gmagick::RESOLUTION_PIXELSPERCENTIMETER (2) Return Value: This function returns a Gmagick object on success. Exceptions: This function throws GmagickException on error. Below given programs illustrate the Gmagick::setimageunits() function in PHP: Used Image: Program 1: php <?php // Create a new Gmagick object $gmagick = new Gmagick('geeksforgeeks.png'); // Set the image units $gmagick->setImageUnits(Gmagick::RESOLUTION_PIXELSPERCENTIMETER); // Get the image units $units = $gmagick->getimageunits(); echo $units; ?> Output: 2 // Which corresponds to Gmagick::RESOLUTION_PIXELSPERCENTIMETER Program 2: php <?php // Create a new Gmagick object $gmagick = new Gmagick('geeksforgeeks.png'); // Set the image units $gmagick->setImageUnits(Gmagick::RESOLUTION_PIXELSPERINCH); // Display the image using new units header("Content-Type: image/png"); echo $gmagick; ?> Output: Reference: https://www.php.net/manual/en/gmagick.setimageunits.php Comment More infoAdvertise with us Next Article PHP | Gmagick setimageunits() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Gmagick Similar Reads PHP | Imagick setImageUnits() Function The Imagick::setImageUnits() function is an inbuilt function in PHP which is used to set the units of resolution of a particular image.Syntax:  bool Imagick::setImageUnits( $units ) Parameters: This function accepts single parameter $units which is used to specify the units to be set for image. Res 2 min read PHP | Gmagick setimagetype() Function The Gmagick::setimagetype() function is an inbuilt function in PHP which is used to set the image type. Syntax: Gmagick Gmagick::setimagetype( int $imgType ) Parameters: This function accepts a single parameter $imgType which holds an integer value corresponding to one of the IMGTYPE constants. All 2 min read PHP | Gmagick setImageDispose() Function The Gmagick::setImageDispose() function is an inbuilt function in PHP which is used to sets the image disposal method. Syntax: Gmagick Gmagick::setimagedispose( $disposeType ) Parameters: This function accepts a single parameter $disposeType which specifies the image disposal type. Return Value: Thi 2 min read PHP | Gmagick setimagedepth() function The Gmagick::setimagedepth() function is an inbuilt function in PHP which is used to set the depth of a particular image. Syntax: Gmagick Gmagick::setimagedepth( $depth ) Parameters: This function accepts a single parameter $depth which is an integer value and used to set the depth of image. Return 2 min read PHP | Gmagick setimageformat() Function The Gmagick::setimageformat() function is an inbuilt function in PHP which is used to set the image format. Syntax: Gmagick Gmagick::setimageformat( string $imageFormat ) Parameters: This function accepts a single parameter $imageFormat which holds the image format. Return Value: This function retur 1 min read Like