钩子文档

image_max_bit_depth

💡 云策文档标注

概述

image_max_bit_depth 过滤器用于调整调整大小后的图像的最大位深度,仅适用于使用 Imagick 编辑器的情况,因为 GD 不支持位深度操作。

关键要点

  • 此过滤器仅在 Imagick 编辑器调整图像大小时生效,GD 编辑器不支持。
  • 参数包括 $max_depth(最大位深度,默认值为输入深度)和 $image_depth(原始图像的位深度)。
  • 源代码示例展示了如何应用过滤器,传递当前图像的深度作为参数。

代码示例

$max_depth = apply_filters( 'image_max_bit_depth', $this->image->getImageDepth(), $this->image->getImageDepth() );

注意事项

  • 此过滤器从 WordPress 6.8.0 版本开始引入。
  • 相关函数包括 WP_Image_Editor_Imagick::thumbnail_image(),用于高效调整图像大小。

📄 原文内容

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.

Parameters

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

Source

$max_depth = apply_filters( 'image_max_bit_depth', $this->image->getImageDepth(), $this->image->getImageDepth() );

Changelog

Version Description
6.8.0 Introduced.