Open In App

PHP | Imagick setImageCompressionQuality() Function

Last Updated : 19 Nov, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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 compression quality.

Return Value: This function returns TRUE on success.

Exceptions: This function throws ImagickException on error.

Below programs illustrate the Imagick::setImageCompressionQuality() function in PHP:

Program 1:




<?php
  
// Create a new imagick object
$imagick = new Imagick(
  
// Set the Compression quality
$imagick->setImageCompressionQuality(26);
  
// Get the Compression quality
$compressionQuality = $imagick->getImageCompressionQuality();
echo $compressionQuality;
?>


Output:

26

Program 2:




<?php
  
// Create a new imagick object
$imagick = new Imagick(
  
// Set the Compression quality
$imagick->setImageCompressionQuality(1);
  
// Show the output
$imagick->setformat('jpg');
header("Content-Type: image/jpg");
echo $imagick->getImageBlob();
?>


Output:

Reference: https://www.php.net/manual/en/imagick.setimagecompressionquality.php



Similar Reads

PHP | Imagick floodFillPaintImage() Function
The Imagick floodFillPaintImage() Function is an in-built function in PHP which is used to change the color value of any pixel that matches the target, along with its immediate neighbor pixels of the same color. Note: This method is a replacement for deprecated Imagick::paintFloodFillImage() Function and is available if Imagick has been compiled ag
4 min read
PHP | Imagick adaptiveSharpenImage() Function
The Imagick::adaptiveSharpenImage() function is an inbuilt function in PHP which provides an adaptive sharpen image feature to the image. The intensity of an adaptive sharpen image depends on dramatically decreased at the edge of the image. Syntax: bool Imagick::adaptiveSharpenImage ( $radius, $sigma, $channel ) Parameters: This function accepts th
1 min read
PHP | Imagick flopImage() Function
The Imagick::flopImage() function is an inbuilt function in PHP which is used to create a horizontal mirror image. Syntax: bool Imagick::flopImage( void ) Parameters: This function does not accept any parameter. Return Value: This function returns True on success. Below programs illustrate the Imagick::flopImage() function in PHP: Program 1: Origin
1 min read
PHP | Imagick setImageExtent() Function
The Imagick::setImageExtent() function is an inbuilt function in PHP which is used to set the image size. This function doesn't scales the image but crops the unwanted parts. Syntax: bool Imagick::setImageExtent( int $columns, int $rows ) Parameters: This function accepts two parameters as mentioned above and described below: $columns: It specifies
1 min read
PHP | Imagick getImageWhitePoint() Function
The Imagick::getImageWhitePoint() function is an inbuilt function in PHP which is used to get the chromaticity white point of an Imagick object. Syntax: bool Imagick::getImageWhitePoint( void) Parameters: This function does not accept any parameter. Return Value: This function returns the chromaticity white point as an associative array with the ke
1 min read
PHP | Imagick getCompressionQuality() Function
The Imagick::getCompressionQuality() function is an inbuilt function in PHP which is used to get the object compression quality. Syntax: int Imagick::getCompressionQuality( void ) Parameters: This function does not accept any parameters. Return Value: This function returns an integer value on success. Below programs illustrate the Imagick::getCompr
1 min read
PHP | Imagick clear() Function
The Imagick::clear() function is an inbuilt function in PHP which is used to clear all resource allocated to an Imagick object. Syntax: bool Imagick::clear( void ) Parameters: This function does not accept any parameter. It just clears off the resources of the Imagick object which is used to call the function. Return Value: This function returns tr
2 min read
PHP | Imagick annotateImage() Function
The Imagick::annotateImage() function is an inbuilt function in PHP which is used to annotates an image with text. This function returns True on success. Syntax: bool Imagick::annotateImage( $draw_settings, $x, $y, $angle, $text ) Parameters: This function accepts five parameters as mentioned above and described below: $draw_settings: This paramete
2 min read
PHP | Imagick adaptiveResizeImage() Function
The Imagick::adaptiveResizeImage() function is an inbuilt function in PHP which provides an adaptively resize image feature to the image. The intensity of an adaptive resize image depends on dramatically decreased at the edge of the image. This function is used to resize the image according to web sites. It is useful when it shrinks the images slig
1 min read
PHP | Imagick adaptiveBlurImage() Function
The Imagick::adaptiveBlurImage() function is an inbuilt function in PHP which is used to add adaptive blur filter in the given image. The intensity of an adaptive blur depends is dramatically decreased at the edge of the image, whereas a standard blur is a uniform across the image. This effect makes the image unclear or less distinct. Syntax: bool
2 min read