From 1a97289f438806e1f621afb748444dfd0b3cf63d Mon Sep 17 00:00:00 2001 From: Kumataro Date: Mon, 26 Oct 2026 20:42:26 +0900 Subject: [PATCH] doc(imgcodecs): update 16-bit support and opaque alpha channel behavior for AVIF(4.x) - Reading and writing 16-bit AVIF images requires libavif v1.4.0+ - Note that if the alpha plane contains only fully opaque pixels, the destination saves only color channels due to a libavif limitation. Port from https://github.com/opencv/opencv/pull/30519 --- modules/imgcodecs/include/opencv2/imgcodecs.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/imgcodecs/include/opencv2/imgcodecs.hpp b/modules/imgcodecs/include/opencv2/imgcodecs.hpp index 7b89284df3..98ffb268bc 100644 --- a/modules/imgcodecs/include/opencv2/imgcodecs.hpp +++ b/modules/imgcodecs/include/opencv2/imgcodecs.hpp @@ -552,10 +552,11 @@ can be saved using this function, with these exceptions: Fully transparent pixels should have an alpha value of 0, while fully opaque pixels should have an alpha value of 255. - 8-bit single-channel images (CV_8UC1) are not supported due to GIF's limitation to indexed color formats. - With AVIF encoder, 8-bit unsigned (CV_8U) and 16-bit unsigned (CV_16U) images can be saved. - - CV_16U images can be saved as only 10-bit or 12-bit (not 16-bit). See IMWRITE_AVIF_DEPTH. + - CV_16U images can be saved as only 10-bit or 12-bit (and 16-bit with libavif 1.4.0+). See @ref IMWRITE_AVIF_DEPTH. - AVIF images with an alpha channel can be saved using this function. To achieve this, create an 8-bit 4-channel (CV_8UC4) / 16-bit 4-channel (CV_16UC4) BGRA image, ensuring the alpha channel is the last component. - Fully transparent pixels should have an alpha value of 0, while fully opaque pixels should have an alpha value of 255 (8-bit) / 1023 (10-bit) / 4095 (12-bit) (see the code sample below). + Fully transparent pixels should have an alpha value of 0, while fully opaque pixels should have an alpha value of 255 (8-bit) / 1023 (10-bit) / 4095 (12-bit) / 65535 (16-bit) (see the code sample below). + Note that if the alpha plane contains only fully opaque pixels, the destination saves only color channels due to a libavif limitation. If the image format is not supported, the image will be converted to 8-bit unsigned (CV_8U) and saved that way.