From 2400361e2bf76cc8c979829baf6955ba4c5144e8 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 8 Jan 2025 19:37:38 +1100 Subject: [PATCH] Rearranged image settings --- src/_avif.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/_avif.c b/src/_avif.c index 7eeac1241c3..d2ec6438996 100644 --- a/src/_avif.c +++ b/src/_avif.c @@ -306,10 +306,6 @@ AvifEncoderNew(PyObject *self_, PyObject *args) { return NULL; } - image->colorPrimaries = AVIF_COLOR_PRIMARIES_UNSPECIFIED; - image->transferCharacteristics = AVIF_TRANSFER_CHARACTERISTICS_UNSPECIFIED; - image->matrixCoefficients = AVIF_MATRIX_COEFFICIENTS_BT601; - // Validate canvas dimensions if (width <= 0 || height <= 0) { PyErr_SetString(PyExc_ValueError, "invalid canvas dimensions"); @@ -412,10 +408,15 @@ AvifEncoderNew(PyObject *self_, PyObject *args) { PyObject_Del(self); return NULL; } + // colorPrimaries and transferCharacteristics are ignored when an ICC + // profile is present, so set them to UNSPECIFIED. + image->colorPrimaries = AVIF_COLOR_PRIMARIES_UNSPECIFIED; + image->transferCharacteristics = AVIF_TRANSFER_CHARACTERISTICS_UNSPECIFIED; } else { image->colorPrimaries = AVIF_COLOR_PRIMARIES_BT709; image->transferCharacteristics = AVIF_TRANSFER_CHARACTERISTICS_SRGB; } + image->matrixCoefficients = AVIF_MATRIX_COEFFICIENTS_BT601; size = PyBytes_GET_SIZE(exif_bytes); if (size) {