wp-includes/class-wp-image-editor-imagick.php:604Efficiently resize the current image
$dst_wint$dst_hint$filter_namestringoptional'FILTER_TRIANGLE'$strip_metabooloptionaltruevoid|WP_Error2 hooks fire while WP_Image_Editor_Imagick::thumbnail_image() runs, in this order:
Filters whether to strip metadata from images when they're resized.
Filters the maximum bit depth of resized images.
protected function thumbnail_image( $dst_w, $dst_h, $filter_name = 'FILTER_TRIANGLE', $strip_meta = true ) { $allowed_filters = array( 'FILTER_POINT', 'FILTER_BOX', 'FILTER_TRIANGLE', 'FILTER_HERMITE', 'FILTER_HANNING', 'FILTER_HAMMING', 'FILTER_BLACKMAN', 'FILTER_GAUSSIAN', 'FILTER_QUADRATIC', 'FILTER_CUBIC', 'FILTER_CATROM', 'FILTER_MITCHELL', 'FILTER_LANCZOS', 'FILTER_BESSEL', 'FILTER_SINC', ); /** * Set the filter value if '$filter_name' name is in the allowed list and the related * Imagick constant is defined or fall back to the default filter. */ if ( in_array( $filter_name, $allowed_filters, true ) && defined( 'Imagick::' . $filter_name ) ) { $filter = constant( 'Imagick::' . $filter_name ); } else { $filter = defined( 'Imagick::FILTER_TRIANGLE' ) ? Imagick::FILTER_TRIANGLE : false; } /** * Filters whether to strip metadata from images when they're resized. * * This filter only applies when resizing using the Imagick editor since GD * always strips profiles by default. * * @since 4.5.0 * * @param bool $strip_meta Whether to strip image metadata during resizing. Default true. */ if ( apply_filters( 'image_strip_meta', $strip_meta ) ) { $this->strip_meta(); // Fail silently if not supported. } try { /** * Special handling for certain types of PNG images: * 1. For PNG images, we need to specify compression settings and remove unneeded chunks. * 2. For indexed PNG images, the number of colors must not exceed 256. * 3. For indexed PNG images with an alpha channel, the tRNS chunk must be preserved. * 4. For indexed PNG images with true alpha transparency (an alpha channel > 1 bit), we need to avoid saving * the image using ImageMagick's 'png8' format, because that supports only binary (1 bit) transparency. * * For #4 we want to check whether the image has a 1-bit alpha channel before resizing, because resizing * may cause the number of alpha values to multiply due to antialiasing. If the original image had only a * 1-bit alpha channel, then a 1-bit alpha channel should be good enough for the resized images. * * Perform all the necessary checks before resizing the image and store the results in variables for later use. */ $is_png = false; $is_indexed_png = false; $is_indexed_png_with_alpha_channel = false; $is_indexed_png_with_true_alpha_transparency = false; if ( 'image/png' === $this->mime_type ) { $is_png = true; if ( is_callable( array( $this->image, 'getImageProperty' ) ) && '3' === $this->image->getImageProperty( 'png:IHDR.color-type-orig' ) ) { $is_indexed_png = true; if ( is_callable( array( $this->image, 'getImageAlphaChannel' ) ) && $this->image->getImageAlphaChannel() ) { $is_indexed_png_with_alpha_channel = true; if ( is_callable( array( $this->image, 'getImageChannelDepth' ) )Introduced in 4.5.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
src/wp-includes/class-wp-image-editor-imagick.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.