PHP | Imagick setImageCompression() Function Last Updated : 10 Jun, 2022 Comments Improve Suggest changes 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 setImageCompression() Function 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 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 PHP | Imagick setImagePage() Function The Imagick::setImagePage() function is an inbuilt function in PHP which is used to set the image page geometry. Syntax: bool Imagick::setImagePage(int $width, int $height, int $x, int $y ) Parameters: This function accepts four parameters as mentioned above and described below: $width: It specifies 1 min read PHP | Imagick setImageProfile() Function The Imagick::setImageProfile() function is an inbuilt function in PHP which is used to set the named profile to the Imagick object. Syntax: bool Imagick::setImageProfile( string $name, string $profile ) Parameters:This function accepts two parameters as mentioned above and described below: $name: It 1 min read PHP | Imagick setImageOpacity() Function The Imagick::setImageOpacity() function is an inbuilt function in PHP which is used to set the opacity level of an Imagick object. This method is available in ImageMagick 6.3.1 or newer versions. Syntax: bool Imagick::setImageOpacity( $opct ) Parameters: This function accepts single parameter $opct 1 min read PHP | Imagick setImageMatte() Function The Imagick::setImageMatte() function is an inbuilt function in PHP which is used to set the matte channel of an Imagick object. Syntax: bool Imagick::setImageMatte( $matte ) Parameters: This function accepts single parameter $matte. If the parameter set to True then it activate the matte channel an 2 min read PHP | Imagick setImageFormat() Function The Imagick::setImageFormat() function is an inbuilt function in PHP which is used to set the format of a particular image in a sequence.Syntax:Â Â bool Imagick::setImageFormat( string $format ) Parameters: This function accepts a single parameter $format which holds a string value of the image forma 1 min read Like