diff --git a/src/pillow_avif/_avif.c b/src/pillow_avif/_avif.c index 0fece9e..6669d45 100644 --- a/src/pillow_avif/_avif.c +++ b/src/pillow_avif/_avif.c @@ -790,6 +790,14 @@ AvifDecoderNew(PyObject *self_, PyObject *args) { max_threads = default_max_threads; } self->decoder->maxThreads = max_threads; +#endif +#if AVIF_VERSION >= 90200 + // Turn off libavif's 'clap' (clean aperture) property validation. + self->decoder->strictFlags &= ~AVIF_STRICT_CLAP_VALID; + // Allow the PixelInformationProperty ('pixi') to be missing in AV1 image + // items. libheif v1.11.0 and older does not add the 'pixi' item property to + // AV1 image items. + self->decoder->strictFlags &= ~AVIF_STRICT_PIXI_REQUIRED; #endif self->decoder->codecChoice = codec; diff --git a/tests/images/chimera-missing-pixi.avif b/tests/images/chimera-missing-pixi.avif new file mode 100644 index 0000000..4039547 Binary files /dev/null and b/tests/images/chimera-missing-pixi.avif differ diff --git a/tests/test_file_avif.py b/tests/test_file_avif.py index 8c0096e..7cd1fe1 100644 --- a/tests/test_file_avif.py +++ b/tests/test_file_avif.py @@ -565,6 +565,13 @@ def test_decoder_upsampling_invalid(self): finally: AvifImagePlugin.CHROMA_UPSAMPLING = "auto" + def test_decoder_strict_flags(self): + # This would fail if full avif strictFlags were enabled + with Image.open( + "%s/tests/images/chimera-missing-pixi.avif.avif" % CURR_DIR + ) as im: + assert im.size == (480, 270) + class TestAvifAnimation: @contextmanager