Skip to content

Commit

Permalink
fix: disable decoder strictness for clap and pixi properties
Browse files Browse the repository at this point in the history
fixes #28
  • Loading branch information
fdintino committed Jul 7, 2024
1 parent b9e95bb commit 0be3b37
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/pillow_avif/_avif.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Binary file added tests/images/chimera-missing-pixi.avif
Binary file not shown.
7 changes: 7 additions & 0 deletions tests/test_file_avif.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0be3b37

Please sign in to comment.