Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVIF/HEIC compression quality settings have no effect on output file size #711

Open
ChiragAgg5k opened this issue Feb 9, 2025 · 1 comment

Comments

@ChiragAgg5k
Copy link

ChiragAgg5k commented Feb 9, 2025

Description

When using Imagick to save images in AVIF or HEIC formats, changing the compression quality setting (setImageCompressionQuality) does not affect the output file size. The files end up having identical sizes regardless of the quality setting used.

Steps to Reproduce

  1. Load an image using Imagick
  2. Resize it (optional step, included for completeness)
  3. Set format to AVIF or HEIC
  4. Save with different quality settings
  5. Compare file sizes
<?php

$image = new \Imagick('image.jpg');
$image->resizeImage(100, 100, \Imagick::FILTER_LANCZOS, 1);

$image->setImageFormat('avif');
$image->setImageCompressionQuality(100);
$image->writeImage('image_full_quality.avif');
$fullQualitySize = filesize('image_full_quality.avif');

$image->setImageCompressionQuality(50);
$image->writeImage('image_half_quality1.avif');
$halfQualitySize = filesize('image_half_quality1.avif');

$image->setCompressionQuality(50);
$image->writeImage('image_half_quality2.avif');
$halfQualitySize2 = filesize('image_half_quality2.avif');

echo "Full quality size: $fullQualitySize bytes\n";
echo "Half quality size 1: $halfQualitySize bytes\n";
echo "Half quality size 2: $halfQualitySize2 bytes\n";

?>

Output:

Full quality size: 4409 bytes
Half quality size 1: 4409 bytes
Half quality size 2: 4409 bytes

Expected Behavior

  • The file with quality=50 should be smaller than the file with quality=100
  • Different quality settings should result in different file sizes

Actual Behavior

  • Both files have identical sizes
  • Quality setting appears to have no effect on the output
  • Same behavior observed for both AVIF and HEIC formats

Environment

  • PHP Version: 8.3.16
  • ImageMagick Version: 7.1.1-43 Q16-HDRI aarch64 22550
  • Operating System: MacOS
@ChiragAgg5k
Copy link
Author

Seems like the CLI command magick works as expected according to the comment here:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant