Imagick::setCompressionQuality

(PECL imagick 0.9.10-0.9.9)
Sets the object's default compression quality
bool Imagick::setCompressionQuality ( int $quality )

Sets the object's default compression quality.

Caution

This method only works for new images e.g. those created through Imagick::newPseudoImage. For existing images you should use Imagick::setImageCompressionQuality().

Parameters:
quality

Sets the object's default compression quality.

Caution

This method only works for new images e.g. those created through Imagick::newPseudoImage. For existing images you should use Imagick::setImageCompressionQuality().

Returns:

Returns TRUE on success.

Examples:
Imagick::setCompressionQuality()
<?php
function setCompressionQuality($imagePath, $quality) {

    $backgroundImagick = new \Imagick(realpath($imagePath));
    $imagick = new \Imagick();
    $imagick->setCompressionQuality($quality);
    $imagick->newPseudoImage(
        $backgroundImagick->getImageWidth(),
        $backgroundImagick->getImageHeight(),
        'canvas:white'
    );

    $imagick->compositeImage(
        $backgroundImagick,
        \Imagick::COMPOSITE_ATOP,
        0,
        0
    );
    
    $imagick->setFormat("jpg");    
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}

?>

doc_php
2016-02-24 16:01:18
Comments
Leave a Comment

Please login to continue.