Imagick::setImageCompression

(PECL imagick 2, PECL imagick 3)

Imagick::setImageCompressionConfigure la compression de l'image

Description

public Imagick::setImageCompression(int $compression): bool

Configure la compression de l'image.

Liste de paramètres

compression

Une des constantes COMPRESSION.

Valeurs de retour

Retourne true en cas de succès.

Erreurs / Exceptions

Lance une exception ImagickException si une erreur survient.

add a note

User Contributed Notes 3 notes

up
8
snipes2083 [at] yahoo com
14 years ago
Above it says "One of the COMPRESSION constants" for the parameters. For any of you that found this confusing, you can find a list of the constants here:

Predefined Constants
http://www.php.net/manual/en/imagick.constants.php

As an example for working with a jpeg image:

<?php
$image
= 'jpeg_image.jpg';
$comression_type = Imagick::COMPRESSION_JPEG;

$im = new Imagick($image);
$im->setImageCompression($compression_type);
?>

This class does not actually compress the images but rather sets the compression type that is going to be used.

If you would like to see how to compress the image see:
Imagick::setImageCompressionQuality
up
1
xudongding
5 years ago
const COMPRESSION_UNDEFINED = 0;
const COMPRESSION_NO = 1;
const COMPRESSION_BZIP = 2;
const COMPRESSION_FAX = 6;
const COMPRESSION_GROUP4 = 7;
const COMPRESSION_JPEG = 8;
const COMPRESSION_JPEG2000 = 9;
const COMPRESSION_LOSSLESSJPEG = 10;
const COMPRESSION_LZW = 11;
const COMPRESSION_RLE = 12;
const COMPRESSION_ZIP = 13;
const COMPRESSION_DXT1 = 3;
const COMPRESSION_DXT3 = 4;
const COMPRESSION_DXT5 = 5;
const COMPRESSION_ZIPS = 14;
const COMPRESSION_PIZ = 15;
const COMPRESSION_PXR24 = 16;
const COMPRESSION_B44 = 17;
const COMPRESSION_B44A = 18;
const COMPRESSION_LZMA = 19;
const COMPRESSION_JBIG1 = 20;
const COMPRESSION_JBIG2 = 21;
up
2
jacob at fragdev dot com
5 years ago
On Ubuntu 18.04, these are the default compression methods used for the following common image formats:

PNG: Imagick::COMPRESSION_ZIP
JPEG: Imagick::COMPRESSION_JPEG
GIF: Imagick::COMPRESSION_LZW
To Top