Review main Ready for review

96772[FEATURE] Add an enum and detection for image formats

Benjamin Kott CR 0 V 0 Expert +1087 −57 updated 11/09/26, 00:42

Commit message

Image formats, their file extensions and their media types are passed
around as strings, and each place that maps one to the other keeps a
list of its own.

The enum Format names them instead and knows the file extensions and
media types of each format, ignoring case and a leading dot, and
whether a format is lossy.

FormatDetector tells the format of a file from its content with the
new FileInfo::getMimeTypeOfContent(), which a media type configured
for the file extension does not change, and not with ImageMagick.
It takes an AVIF that libmagic calls HEIF by its compatible brands,
TGA only with its file extension and SVG by its root element.

GraphicsCanvas, which GIFBUILDER and the install tool draw with,
uses them instead of its own lists and loads an image by its
content.

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 9
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/72/96772/9 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/72/96772/9 && git cherry-pick FETCH_HEAD

Review

  • Code review CR 0 Needs a vote
  • Verified V 0 Needs a vote
    • core-ci +1 CI

Relation chain 7

  1. main 96780[!!!][TASK] Rename GFX/processor_effects to GFX/sharpen Based on this change Merged Benjamin Kott CR +2 V +2 Hard +214 −103

    The chain has patch set 2 of 7, the changes above it need a rebase.

  2. main 96773[BUGFIX] Let GD sharpening grow with its strength Based on this change Merged Benjamin Kott CR +2 V +2 Normal +90 −4

    The chain has patch set 3 of 8, the changes above it need a rebase.

  3. main 96778[!!!][TASK] Remove the GFX setting thumbnails Based on this change Merged Benjamin Kott CR +2 V +2 Normal +118 −63

    The chain has patch set 4 of 5, the changes above it need a rebase.

  4. main 96777[!!!][TASK] Require the PHP extension gd Based on this change Merged Benjamin Kott CR +2 V +2 Easy +46 −3

    The chain has patch set 1 of 2, the changes above it need a rebase.

  5. main 93628[WIP][TASK] Make GD the baseline image processor Based on this change Work in progress Merge conflict Benjamin Kott CR 0 V -1 Impossible +16163 −3817
  6. main 96776[TASK] Read image orientation independently of ext-exif Based on this change Merge conflict Benjamin Kott CR 0 V 0 Expert +1212 −31
  7. 96772 [FEATURE] Add an enum and detection for image formats This change

Merge conflicts 6

Issues 1

Files 44

Show 24 more files

Review log 1827

Show 12 earlier messages
  1. Benjamin Kott uploaded patch set 1 10/17/26, 01:29

  2. core-ci voted on patch set 1 V +1 10/17/26, 01:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/111410

  1. Benjamin Kott rebased onto patch set 2 V +1 10/17/26, 11:55

  2. core-ci voted on patch set 2 V +1 10/17/26, 12:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/111450

  3. Simon Schaufelberger commented on patch set 2 10/17/26, 12:17

    mvg.svg:1

    what kind of svg file format is that?
  4. Garvin Hicking commented on patch set 2 10/17/26, 12:25

    I'm a bit afraid we lock ourselves into reinventing our own mime.types wheel and need to harmonize that, fixating supported image formats to a specific TYPO3 version. Not sure yet how we could solve it: make an own extension out of it, supporting multiple cores? Making them configurable? Adding easy mappings for future formats? We've failed on this when lagging behing webp and avif/heic. Given AI speed cycles I'm afraid we'll lag behind future formats. What are your thoughts? (I have only briefly glanced at this and wanted to raise this topic before merging)
  5. Benjamin Kott commented on patch set 2 10/17/26, 13:39

    mvg.svg:1 Reply

    It is indeed not an SVG at all. It is an ImageMagick MVG script named .svg, the ImageTragick attack vector. ImageMagick recognises MVG by its content and runs it. The test proves FormatDetector returns null for it, so such a file never reaches a decoder.
  6. Benjamin Kott commented on patch set 2 10/17/26, 13:51

    Reply

    The goal is to bundle image handling, and for that TYPO3 needs more than media types: - what a file really is, - who can read and write it, - whether it's lossy, - whether browsers display it. Today that's scattered as string lists across the core. Even AVIF isn't handled correctly everywhere yet; that follows later in this chain. New formats will still need work beyond adding a case, and we'll have to adjust again in the future. But with Format as the shared vocabulary, it happens in one known place instead of across the core.
  7. Garvin Hicking commented on patch set 2 10/17/26, 15:29

    Reply

    How about an external typo3/media package for these structures then, maybe merging it with typo3/icons (or how's it called)? Then we can maintain that vocabulary with more compatibility and be faster to adjust formats across major versions of TYPO3.
  8. Simon Schaufelberger commented on patch set 2 10/17/26, 16:04

    mvg.svg:1 Reply

    Acknowledged
  9. Benjamin Kott commented on patch set 2 10/17/26, 18:17

    Reply

    Extracting is maybe an option later on once everything is settled but it also would mean that we extract the complete image handling and move it into a dedicated package. I cannot see the benefits yet and think it will make it more complex and slow.
  10. Garvin Hicking commented on patch set 2 10/17/26, 21:17

    Reply

    Can we combine this with https://review.typo3.org/c/Packages/TYPO3.CMS/+/96800 at least? That one also basically cries for being maintained independently from TYPO3 releases (to me). I think we should aim for being able to support new formats with quicker turnarounds and not move slowly with LTS releases. To me that's a huge benefit, if we find a data structure that is capable of being extensible. I don't think we'd need to rip out the whole image processing into its own package. But then again, the whole image rework as to my knowledge was aimed to replace exactly that in our Core-facing API, to allow for other implementations. I'll resolve this one here, I'm not deep enough into the patch and I think I'm approaching it with a different mindset and will not be blocking efforts.
  11. Benjamin Kott uploaded patch set 3 V +1 10/19/26, 14:51

  12. core-ci voted on patch set 3 V +1 10/19/26, 15:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/111662

  13. Garvin Hicking commented on patch set 3 10/19/26, 20:56

    Format.php:55 Unresolved

    Could we move these two definitions to either TYPO3_CONF_VARS just like allowedMimeTypes for forward compat of new mime types or file extensions? Or use a custom dedicated PHP file in config/system that could override this here if present?
  14. Benjamin Kott rebased onto patch set 4 V +1 10/20/26, 21:10

  15. core-ci voted on patch set 4 V -1 10/20/26, 21:29 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/111940

  16. Benjamin Kott rebased onto patch set 5 V -1 10/20/26, 21:59

  17. core-ci voted on patch set 5 V +1 10/20/26, 22:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/111945

  18. Benjamin Kott rebased onto patch set 6 V +1 10/21/26, 12:05

  19. core-ci voted on patch set 6 V +1 10/21/26, 12:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112002

  20. Benjamin Kott rebased onto patch set 7 V +1 10/21/26, 17:33

  21. core-ci voted on patch set 7 V +1 10/21/26, 17:48 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112026

  22. Benjamin Kott rebased onto patch set 8 V +1 10/22/26, 18:42

  23. core-ci voted on patch set 8 V +1 10/22/26, 19:09 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/112171

  24. Benjamin Kott uploaded patch set 9 V +1 11/09/26, 00:31

  25. core-ci voted on patch set 9 V +1 11/09/26, 00:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/113612