Issue Feature Under Review

#111102Introduce enums and content detection for image formats

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

Description

Problem

Image formats, their file extensions and their media types are passed around as strings. Every place that maps one to the other keeps a list of its own, for example GraphicsCanvas (GIFBUILDER, install tool) and the FileContentParser of Indexed Search, which handles jpg, jpeg and tif by hand.

The format of a file is taken from its name, so an image with a misleading file extension is handed to the wrong decoder.

Proposal

  • Introduce the enums Format, FileExtension and MediaType in TYPO3\CMS\Core\Imaging. Each creates the others, ignoring case and a leading dot; Format::isLossy() tells whether a format is written with a quality.
  • Introduce FormatDetector, which tells the format of a file from its content, without ImageMagick and without ext-fileinfo.
  • Use them in GraphicsCanvas, which then loads images by their content, and in the FileContentParser of Indexed Search, which tells JPEG and TIFF images by their format.

Reviews 1

History 312