Media: enable high bit depth resized image output with Imagick.
Fix an issue where uploaded HDR images were resized and output as SDR and thus significantly degraded from the original. When using Imagick, output images will now match the bit depth of the uploaded image. Add a new filter ‘image_max_bit_depth’ which developers can use to control the maximum bit depth for resized images. Props adamsilverstein, kirasong, gregbenz, apermo. Fixes #62285. Built from https://develop.svn.wordpress.org/trunk@59588 git-svn-id: http://core.svn.wordpress.org/trunk@58974 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
34b761063c
commit
065f1ef453
|
@ -503,11 +503,23 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
|
|||
}
|
||||
}
|
||||
|
||||
// Limit the bit depth of resized images to 8 bits per channel.
|
||||
// Limit the bit depth of resized images.
|
||||
if ( is_callable( array( $this->image, 'getImageDepth' ) ) && is_callable( array( $this->image, 'setImageDepth' ) ) ) {
|
||||
if ( 8 < $this->image->getImageDepth() ) {
|
||||
$this->image->setImageDepth( 8 );
|
||||
}
|
||||
/**
|
||||
* Filters the maximum bit depth of resized images.
|
||||
*
|
||||
* This filter only applies when resizing using the Imagick editor since GD
|
||||
* does not support getting or setting bit depth.
|
||||
*
|
||||
* Use this to adjust the maximum bit depth of resized images.
|
||||
*
|
||||
* @since 6.8.0
|
||||
*
|
||||
* @param int $max_depth The maximum bit depth. Default is the input depth.
|
||||
* @param int $image_depth The bit depth of the original image.
|
||||
*/
|
||||
$max_depth = apply_filters( 'image_max_bit_depth', $this->image->getImageDepth(), $this->image->getImageDepth() );
|
||||
$this->image->setImageDepth( $max_depth );
|
||||
}
|
||||
} catch ( Exception $e ) {
|
||||
return new WP_Error( 'image_resize_error', $e->getMessage() );
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.8-alpha-59587';
|
||||
$wp_version = '6.8-alpha-59588';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue