diff --git a/src/pillow_avif/_avif.c b/src/pillow_avif/_avif.c index 8284154..3b2970d 100644 --- a/src/pillow_avif/_avif.c +++ b/src/pillow_avif/_avif.c @@ -143,6 +143,7 @@ static void exif_orientation_to_irot_imir(avifImage *image, int orientation) { const avifTransformFlags otherFlags = image->transformFlags & ~(AVIF_TRANSFORM_IROT | AVIF_TRANSFORM_IMIR); + // // Mapping from Exif orientation as defined in JEITA CP-3451C section 4.6.4.A // Orientation to irot and imir boxes as defined in HEIF ISO/IEC 28002-12:2021 @@ -152,25 +153,41 @@ exif_orientation_to_irot_imir(avifImage *image, int orientation) { // the visual left-hand side. image->transformFlags = otherFlags; image->irot.angle = 0; // ignored +#if AVIF_VERSION_MAJOR >= 1 image->imir.axis = 0; // ignored +#else + image->imir.mode = 0; // ignored +#endif return; case 2: // The 0th row is at the visual top of the image, and the 0th column is // the visual right-hand side. image->transformFlags = otherFlags | AVIF_TRANSFORM_IMIR; image->irot.angle = 0; // ignored +#if AVIF_VERSION_MAJOR >= 1 image->imir.axis = 1; +#else + image->imir.mode = 1; +#endif return; case 3: // The 0th row is at the visual bottom of the image, and the 0th column // is the visual right-hand side. image->transformFlags = otherFlags | AVIF_TRANSFORM_IROT; image->irot.angle = 2; +#if AVIF_VERSION_MAJOR >= 1 image->imir.axis = 0; // ignored +#else + image->imir.mode = 0; // ignored +#endif return; case 4: // The 0th row is at the visual bottom of the image, and the 0th column // is the visual left-hand side. image->transformFlags = otherFlags | AVIF_TRANSFORM_IMIR; image->irot.angle = 0; // ignored +#if AVIF_VERSION_MAJOR >= 1 image->imir.axis = 0; +#else + image->imir.mode = 0; +#endif return; case 5: // The 0th row is the visual left-hand side of the image, and the 0th // column is the visual top. @@ -178,13 +195,21 @@ exif_orientation_to_irot_imir(avifImage *image, int orientation) { otherFlags | AVIF_TRANSFORM_IROT | AVIF_TRANSFORM_IMIR; image->irot.angle = 1; // applied before imir according to MIAF spec // ISO/IEC 28002-12:2021 - section 7.3.6.7 +#if AVIF_VERSION_MAJOR >= 1 image->imir.axis = 0; +#else + image->imir.mode = 0; +#endif return; case 6: // The 0th row is the visual right-hand side of the image, and the 0th // column is the visual top. image->transformFlags = otherFlags | AVIF_TRANSFORM_IROT; image->irot.angle = 3; +#if AVIF_VERSION_MAJOR >= 1 image->imir.axis = 0; // ignored +#else + image->imir.mode = 0; // ignored +#endif return; case 7: // The 0th row is the visual right-hand side of the image, and the 0th // column is the visual bottom. @@ -192,13 +217,21 @@ exif_orientation_to_irot_imir(avifImage *image, int orientation) { otherFlags | AVIF_TRANSFORM_IROT | AVIF_TRANSFORM_IMIR; image->irot.angle = 3; // applied before imir according to MIAF spec // ISO/IEC 28002-12:2021 - section 7.3.6.7 +#if AVIF_VERSION_MAJOR >= 1 image->imir.axis = 0; +#else + image->imir.mode = 0; +#endif return; case 8: // The 0th row is the visual left-hand side of the image, and the 0th // column is the visual bottom. image->transformFlags = otherFlags | AVIF_TRANSFORM_IROT; image->irot.angle = 1; +#if AVIF_VERSION_MAJOR >= 1 image->imir.axis = 0; // ignored +#else + image->imir.mode = 0; // ignored +#endif return; default: // reserved break; @@ -211,7 +244,11 @@ exif_orientation_to_irot_imir(avifImage *image, int orientation) { // left-hand side. image->transformFlags = otherFlags; image->irot.angle = 0; // ignored +#if AVIF_VERSION_MAJOR >= 1 image->imir.axis = 0; // ignored +#else + image->imir.mode = 0; // ignored +#endif } static int