Media: Ensure Imagick quality is set correctly.

Fix an issue where Imagick did not properly set image quality for AVIF images. Adds a call to `setCompressionQuality`  where we currently call `setImageCompressionQuality`

Props: jamesosborne, adamsilverstein, mukeshpanchal27.

Fixes: #61614.


Built from https://develop.svn.wordpress.org/trunk@59247


git-svn-id: http://core.svn.wordpress.org/trunk@58639 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Adam Silverstein 2024-10-17 17:05:18 +00:00
parent bd1a653f42
commit e0d47a45b1
2 changed files with 6 additions and 1 deletions

View File

@ -206,6 +206,7 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
switch ( $this->mime_type ) {
case 'image/jpeg':
$this->image->setImageCompressionQuality( $quality );
$this->image->setCompressionQuality( $quality );
$this->image->setImageCompression( imagick::COMPRESSION_JPEG );
break;
case 'image/webp':
@ -214,19 +215,23 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
if ( 'lossless' === $webp_info['type'] ) {
// Use WebP lossless settings.
$this->image->setImageCompressionQuality( 100 );
$this->image->setCompressionQuality( 100 );
$this->image->setOption( 'webp:lossless', 'true' );
parent::set_quality( 100 );
} else {
$this->image->setImageCompressionQuality( $quality );
$this->image->setCompressionQuality( $quality );
}
break;
case 'image/avif':
// Set the AVIF encoder to work faster, with minimal impact on image size.
$this->image->setOption( 'heic:speed', 7 );
$this->image->setImageCompressionQuality( $quality );
$this->image->setCompressionQuality( $quality );
break;
default:
$this->image->setImageCompressionQuality( $quality );
$this->image->setCompressionQuality( $quality );
}
} catch ( Exception $e ) {
return new WP_Error( 'image_quality_error', $e->getMessage() );

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.7-beta3-59246';
$wp_version = '6.7-beta3-59247';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.