Open In App

PHP | Imagick getImageCompression() Function

The Imagick::getImageCompression() function is an inbuilt function in PHP which is used to get the current image’s compression type.

Syntax:



int Imagick::getImageCompression( void )

Parameters: This function doesn’t accepts any parameter.

Return Value: This function returns an integer value which corresponds to one of compression constant.



List of Compression constants are given below:

Below programs illustrate the Imagick::getImageCompression() function in PHP:
Program 1:




<?php
  
// Create new Imagick Object
$imagick = new Imagick(
  
// Get the Compression
$compression = $imagick->getImageCompression();
echo $compression;
?>

Output:

13

Program 2:




<?php
  
// Create new Imagick Object
$imagick = new Imagick(
  
// Set the Compression to COMPRESSION_DXT1
$imagick->setImageCompression(imagick::COMPRESSION_DXT1);
  
// Get the Compression
$compression = $imagick->getImageCompression();
  
echo $compression;
?>

Output:

3

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


Article Tags :