Issue Task Under Review

#111106Read image orientation independently of ext-exif, including AVIF and HEIC

Benjamin Kott 10/17/26, 08:41 updated 11/09/26, 00:31

Description

Problem

Photos often store their pixels sideways and say how to turn them upright: JPEG, TIFF, PNG and WebP with an EXIF orientation, AVIF and HEIC with the irot and imir properties of their primary item.

TYPO3 reads the orientation only through exif_read_data(), i.e. only where ext-exif is loaded, and ext-exif reads JPEG and TIFF alone. As a result:

  • the width and height in sys_file_metadata are those of the sideways raster for PNG, WebP, AVIF and HEIC always, and for JPEG and TIFF without ext-exif, while ImageMagick renders these images upright, so aspect ratios are wrong in the cropping wizard and in rendered width/@height@ attributes
  • GIFBUILDER, which draws with GD, places unscaled images sideways, since GD applies no orientation. The AVIF decoder of GD ignores irot/@imir@ as well.

Solution

  • An ImageOrientationReader reads the EXIF orientation of JPEG, TIFF, PNG and WebP, through ext-exif where it is loaded for JPEG and TIFF, by itself otherwise.
  • Of AVIF and HEIC it reads irot/@imir@ of the primary item and expresses them as the equivalent EXIF orientation. All eight orientations are cross-checked against ImageMagick, which applies them through libheif.
  • ImageInfo reports the upright size, GraphicsCanvas (GIFBUILDER) turns images upright.
  • An upgrade wizard corrects the dimensions of images indexed before

Reviews 1

History 09