Review main Abandoned

94937[TASK] Extract image configuration and capabilities into own classes

Benni Mack CR 0 V 0 Expert +1192 −134 updated 10/14/26, 11:17

Commit message

Image processing code currently mixes three concerns in its worker
objects: what the administrator wants (TYPO3_CONF_VARS/GFX), what the
environment can actually do (GD compiled formats, binary presence),
and the processing work itself. GraphicalFunctions parses the GFX
configuration in its constructor and re-reads $GLOBALS at call time
in several places, which makes candidate configurations (install tool
preset testing) and isolated testing unnecessarily hard.

Two new concepts are introduced in EXT:core, both immutable and
deliberately usable without the dependency injection container:

ImageConfiguration is a readonly value object carrying the parsed GFX
configuration. Invariants are enforced on construction: quality values
are clamped to their valid ranges, lossless webp encoding is
represented explicitly, and the colorspace is guaranteed to be a known
name, defaulting per configured processor (ImageMagick: sRGB,
GraphicsMagick: RGB). Instances are created via
ImageConfigurationFactory, either from the live configuration
(fromGlobals()) or from any GFX-shaped candidate array (fromArray()).
The configuration never probes the environment.

The Imaging\Capabilities namespace answers what a backend can do:
ImageProcessingCapabilitiesInterface exposes availability, version,
readable/writable file formats and colorspace conversion support.
GdCapabilities probes decode and encode support separately per format
via the imagecreatefrom*()/image*() function pairs, since a GD build
can ship a decoder without the matching encoder. ImageMagick and
GraphicsMagick capabilities are probed through the binary configured
in a given ImageConfiguration - never through $GLOBALS - and parse
the "convert -list format" output into an immutable snapshot;
GraphicsMagick mirrors PDF capability onto the .ai extension it
handles transparently. Capability objects never read configuration
globals, configuration objects never probe: environment facts and
administrator intent stay separate by construction.

GraphicalFunctions now takes over all values from an optionally
injected ImageConfiguration (defaulting to the live one) and no longer
reads $GLOBALS['TYPO3_CONF_VARS']['GFX'] anywhere. Behaviour is
unchanged.

All new classes are marked @internal until the per-processor
architecture is finalized.

Review

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

Issues 2

Files 11

Review log 45

  1. Benni Mack uploaded patch set 1 07/24/26, 20:18

  2. core-ci voted on patch set 1 V +1 07/24/26, 20:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105355

  3. Garvin Hicking commented on patch set 1 07/25/26, 07:17

    AbstractBinaryCapabilities.php:44 Unresolved

    Could we abstract this to support future image types without changing core code? Eg HEIC? Or 3D file formats.

    ImageConfigurationFactory.php:46 Unresolved

    these quality options are somewhat crude, maybe take the chance to create a more generic value object for those, too?
  4. Benni Mack marked it work in progress 09/02/26, 17:27

  5. Benni Mack abandoned the change 10/14/26, 11:17

    wont do