wppaste
WordPress

apply_filters( 'image_max_bit_depth', int $max_depth, int $image_depth )

Since
6.8.0
Filters the maximum bit depth of resized images.

Description

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.

Compatibility

WordPress
since 6.8.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in 4 of the 5 tracked releases, added in 6.8.0.

Parameters

$max_depthint
The maximum bit depth. Default is the input depth.
$image_depthint
The bit depth of the original image.

Where this hook fires · 2

  • wp-includes/class-wp-image-editor-imagick.php:801WP_Image_Editor_Imagick::thumbnail_image()
  • wp-includes/rest-api/class-wp-rest-server.php:1400WP_REST_Server::get_index()

Source code

				 *				 * @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() );		}	}

Changelog

Introduced in 6.8.0. Unchanged from 6.8.8 through 7.1.0.

  1. 6.8.8
  2. 6.9.7
  3. 7.0.4
  4. 7.1.0

Signature, return type and hooks compared across 4 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.