php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #57984 Imagick::setImageCompression() has no effect
Submitted: 2007-12-30 16:20 UTC Modified: 2009-03-14 07:11 UTC
From: mail at hautzinger dot info Assigned:
Status: Not a bug Package: imagick (PECL)
PHP Version: 5.2.1 OS: gutsy gibbon
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mail at hautzinger dot info
New email:
PHP Version: OS:

 

 [2007-12-30 16:20 UTC] mail at hautzinger dot info
Description:
------------
Imagick::setImageCompression() doesn't change the compression at all, besides wich (valid) value passed as parameter.

I use ImageMagick 6.3.7 with PHP 5.2.4-2 with Suhosin-Patch 0.9.6.2 (cli)

Reproduce code:
---------------
$img = new Imagick('test.jpg');

$img->setImageCompression(60);

$img->writeImage('test1.jpg');

Expected result:
----------------
jpg image should be compressed

Actual result:
--------------
nothing happens

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-31 05:47 UTC] mkoppanen@php.net
Thank you for taking the time to write to us, but this is not
a bug.

Imagick::setImageCompression expects one of the compression type constants listed in:
http://php.net/manual/en/imagick.constants.php -> Compression constants.

If you want to set the compression quality 1-100 you need to use Imagick::setImageCompressionQuality.
 [2009-03-14 06:38 UTC] igor dot oszone at gmail dot com
FreeBSD 7.1-RELEASE-p3
PHP Version 5.2.9 (mod_php5)
Suhosin Patch 0.9.7
ImageMagick version ImageMagick 6.4.9-8 2009-03-09 Q16 
imagick module version 	2.2.1

$img1 = new Imagick('upload/313/pNeDUU8F.jpg');
$img1->setCompression(Imagick::COMPRESSION_JPEG);
$img1->setCompressionQuality(40);
$s1= $img1->getImageSize();

$img2 = new Imagick('upload/313/pNeDUU8F.jpg');
$img2->setCompression(Imagick::COMPRESSION_JPEG);
$img2->setCompressionQuality(60);
$s2= $img2->getImageSize();

$img3 = new Imagick('upload/313/pNeDUU8F.jpg');
$img3->setCompression(Imagick::COMPRESSION_JPEG);
$img3->setCompressionQuality(90);
$s3= $img3->getImageSize();

$img4 = new Imagick('upload/313/pNeDUU8F.jpg');
$img4->setCompression(Imagick::COMPRESSION_JPEG);
$img4->setCompressionQuality(900);
$s4= $img4->getImageSize();

echo $s1." = ".$s2." = ".$s3." = ".$s4; 

==============
317983 = 317983 = 317983 = 317983

Replacing setCompression to setImageCompression does not change anything
 [2009-03-14 07:11 UTC] mkoppanen@php.net
<?php

$img1 = new Imagick('test.jpg');
$img1->setImageCompression(Imagick::COMPRESSION_JPEG);
$img1->setImageCompressionQuality(40);
$img1->writeImage('output/1.jpg');

$img2 = new Imagick('test.jpg');
$img2->setImageCompression(Imagick::COMPRESSION_JPEG);
$img2->setImageCompressionQuality(60);
$img2->writeImage('output/2.jpg');

$img3 = new Imagick('test.jpg');
$img3->setImageCompression(Imagick::COMPRESSION_JPEG);
$img3->setImageCompressionQuality(90);
$img3->writeImage('output/3.jpg');

$img4 = new Imagick('test.jpg');
$img4->setImageCompression(Imagick::COMPRESSION_JPEG);
$img4->setImageCompressionQuality(900);
$img4->writeImage('output/4.jpg');

Generates:

22615 1.jpg
27045 2.jpg
31835 3.jpg
52126 4.jpg
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 09:01:29 2024 UTC