PHP | Imagick setImageCompression() Function Last Updated : 10 Jun, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report The Imagick::setImageCompression() function is an inbuilt function in PHP which is used to set the image compression type. Syntax: bool Imagick::setImageCompression( int $compression ) Parameters: This function accepts a single parameter $compression which holds an integer matching to one of Imagick::COMPRESSION_* constants. Additionally, you can pass the constant directly like $imagick->setImageCompression(imagick::COMPRESSION_DXT1);. List of Compression constants are given below: imagick::COMPRESSION_UNDEFINED (0)imagick::COMPRESSION_NO (1)imagick::COMPRESSION_BZIP (2)imagick::COMPRESSION_FAX (6)imagick::COMPRESSION_GROUP4 (7)imagick::COMPRESSION_JPEG (8)imagick::COMPRESSION_JPEG2000 (9)imagick::COMPRESSION_LOSSLESSJPEG (10)imagick::COMPRESSION_LZW (11)imagick::COMPRESSION_RLE (12)imagick::COMPRESSION_ZIP (13)imagick::COMPRESSION_DXT1 (3)imagick::COMPRESSION_DXT3 (4)imagick::COMPRESSION_DXT5 (5) Return Value: This function returns TRUE on success. Exceptions: This function throws ImagickException on error. Below programs illustrate the Imagick::setImageCompression() function in PHP: Program 1: php <?php // Create new Imagick Object $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Set the Compression to COMPRESSION_RLE $imagick->setImageCompression(imagick::COMPRESSION_RLE); // Get the Compression $compression = $imagick->getImageCompression(); echo $compression; ?> Output: 12 Program 2: php <?php // Create new Imagick Object $imagick = new Imagick( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Set the Compression to COMPRESSION_JPEG $imagick->setImageCompression(imagick::COMPRESSION_JPEG); // Set the Compression quality // This is where that compression method imagick::COMPRESSION_JPEG is // used in the program. $imagick->setImageCompressionQuality(5); // Show the output $imagick->setformat('jpg'); header("Content-Type: image/jpg"); echo $imagick->getImageBlob(); ?> Output: Reference: https://www.php.net/manual/en/imagick.setimagecompression.php Comment More infoAdvertise with us Next Article PHP | Imagick setImageResolution() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-Imagick Similar Reads PHP | Imagick setImageCompressionQuality() Function The Imagick::setImageCompressionQuality() function is an inbuilt function in PHP which is used to set the image compression quality. Syntax: bool Imagick::setCompressionQuality( int $quality ) Parameters: This function accepts single parameter $quality which holds an integer value representing image 1 min read PHP | Imagick setImageCompose() Function The Imagick::setImageCompose() function is an inbuilt function in PHP which is used to set the composite operator associated with the image. This function is used to specify how to composite the image thumbnail when using the Imagick::montageImage() method. Syntax: bool Imagick::setImageCompose( int 1 min read PHP | Imagick setImageResolution() Function The Imagick::setImageResolution() function is an inbuilt function in PHP which is used to set the resolution of an image object.Syntax:Â Â bool Imagick::setImageResolution($x_resolution, $y_resolution) Parameters: This function accept two parameters as mentioned above and described below:Â Â $x_resolu 2 min read PHP | Imagick setImageResolution() Function The Imagick::setImageResolution() function is an inbuilt function in PHP which is used to set the resolution of an image object.Syntax:Â Â bool Imagick::setImageResolution($x_resolution, $y_resolution) Parameters: This function accept two parameters as mentioned above and described below:Â Â $x_resolu 2 min read PHP | Imagick setImageScene() Function The Imagick::setImageScene() function is an inbuilt function in PHP which is used to set the image scene. The value of scene contains an integer value. Syntax: bool Imagick::setImageScene( int $scene ) Parameters: This function accepts a single parameter $scene which holds the scene. Return Value: T 1 min read PHP | Imagick setImageType() Function The Imagick::setImageType() function is an inbuilt function in PHP which is used to set the image type.Syntax:Â Â bool Imagick::setImageType( int $image_type ) Parameters: This function accepts a single parameter $image_type which contains an integer value corresponding to one of IMGTYPE constants. W 1 min read Like