Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

PHP | Imagick getImageCompression() Function

  • Last Updated : 19 Nov, 2019

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:

  • 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)

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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!