Review main Merged

93666[BUGFIX] Route GifBuilder through a pure-GD canvas

Benjamin Kott CR +2 V +2 Nightmare +3175 −794 updated 08/26/26, 08:18

Commit message

GifBuilder operated on a \GdImage in memory but reached for a CLI
binary mid-pipeline. Most GIFBUILDER objects stayed in GD — BOX,
ELLIPSE, OUTLINE, EMBOSS, CROP and ADJUST call imagefilledrectangle,
imagefilledellipse, imageconvolution and friends directly — but
EFFECT, IMAGE+mask, SCALE, the niceText branch of TEXT, SHADOW
(with processor_effects and blur>0), and the transparent-colour
remap each wrote the current \GdImage to a temporary PNG via
ImageWrite(), shelled out to convert/gm through imageMagickExec()
or combineExec(), then rehydrated the result with
imageCreateFromFile(). Every EFFECT keyword, every remapped
transparent colour and every shadow layer added another
encode/fork/exec/decode cycle; on a page with three text layers
that is six temp files and six subprocesses just to render a
background, and any IM return-code failure was swallowed by an
isset() check on the re-read image.

Several EFFECT keywords also produced output that did not match
their documented TypoScript contract. solarize has a documented
range of 0–99, but solarize=N was concatenated straight into the
IM command as `-solarize N` — IM reads a bare integer on
`-solarize` as a threshold on its compiled quantum range (0–255
on Q8 builds, 0–65535 on Q16), so the same TypoScript produced
completely different images on two hosts and neither matched a
percentage scale; the correct portable form is `-solarize N%`.
shear has a documented range of -90…90, but shear geometry is
computed through tan(angle), and tan(±90°) diverges, so shear=90
asked IM for an image with effectively infinite width and the
shell-out returned nothing usable. emboss is documented as taking
no value, and the code emitted a bare `-emboss` with no radius;
modern IM and GM require a numeric radius on that flag and
silently fail when one isn't supplied, so the EFFECT keyword
appeared accepted while the rendered image came back with no
emboss applied.

The install tool's imageProcessingGdlib* actions under
Environment → Test Setup instantiated a GifBuilder via
GeneralUtility::makeInstance() and drove it through its public
rendering helpers — makeBox(), makeText(), makeShadow(),
ImageWrite(), imageCreateFromFile(), calcBBox() — which are
documented as "Implements the TEXT/BOX/… GIFBUILDER object" and
are meant to be driven from start() and gifBuild(), not from
outside. The two niceText actions additionally gated on
isImageMagickEnabledAndConfigured() and shelled out internally
for the mask scaling and the shadow blur, yet reported their
output under a "Gdlib" banner with $gifBuilder->
getGraphicalFunctions()->IM_commands attached to the response
payload, so the Environment panel presented IM test results as
GD test results. Breakage in the pure-GD path was therefore
invisible in the installer, and any refactor of GifBuilder's
internal rendering helpers broke the installer with it.

GraphicsCanvas is introduced in typo3/sysext/core/Classes/Imaging/
GraphicsCanvas.php as a narrow, typed PHP wrapper around a
truecolour \GdImage. It exposes the primitives GifBuilder needs
(fillRect, fillEllipse, drawText, copyOnto, mask, invert, crop,
scale, and the effect keywords) and nothing else. GifBuilder now
owns a GraphicsCanvas per render and delegates to it, so every
object stays in the same in-memory \GdImage for the full pipeline;
ImageWrite() is called once, at the very end, when the finished
image is written to the processed-file path. applyImageMagickToPHPGif()
and the `processor_effects` gate are no longer reached on the
EFFECT path — all sixteen keywords (blur, charcoal, colors, edge,
emboss, sharpen, gray, invert, gamma, solarize, swirl, flip, flop,
rotate, shear, wave) are implemented with GD primitives or small
pixel loops on the canvas. solarize takes a real percentage,
shear is clamped to ±85° so the computed destination width stays
finite, emboss runs a fixed 3x3 convolution kernel for a
deterministic result, and the image never leaves PHP between
effect keywords.

The imageProcessingGdlib* actions are rewritten to construct a
GraphicsCanvas directly, use its public methods, and call
saveToFile() at the end — no GifBuilder, no ContentObjectRenderer,
no reliance on protected helpers promoted to public. Alongside,
the niceText infobox has its trailing IM/GM sentence removed, the
obsolete ImageMagick-5 "shadow" infobox is dropped,
TestInput/Test.webp is resized from 768x576 to 400x300 to match
the other FromFile fixtures, and the seven Gdlib-* reference
images are regenerated from the new canvas output.

GraphicsCanvas answers which formats it can read and write from
imagetypes(), the format bits the running GD build was compiled
with, rather than by matching the prose keys of gd_info(). The
check returns false when the GD extension is absent, so canRead()
and canWrite() no longer depend on isAvailable() having been asked
first.

The backend ThumbnailViewHelper and the workspaces grid stop
rendering an <img> for a processed file that fell back to a
non-image original: no processor was able to create a thumbnail
there and the markup pointed at the source file. The ViewHelper
returns an empty tag, the workspaces diff view falls through to a
plain public URL.

Review

  • Code review CR +2 Done
    • Benjamin Kott +2
    • Georg Ringer +1
    • Andreas Kienast +1
  • Verified V +2 Done
    • Benjamin Kott +2
    • Georg Ringer +1
    • Andreas Kienast +1
    • core-ci +1 CI

Issues 1

Files 34

Show 14 more files

Review log 4971

Show 3046 earlier messages
  1. Benjamin Kott uploaded patch set 1 04/14/26, 13:05

  2. Benjamin Kott rebased onto patch set 2 04/14/26, 13:11

  3. core-ci voted on patch set 1 V -1 04/14/26, 13:32 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100160

  4. core-ci voted on patch set 2 V -1 04/14/26, 13:35 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100162

  5. Christian Kuhn voted on patch set 2 CR -2 04/14/26, 13:39

  6. Benjamin Kott uploaded patch set 3 V -1 04/14/26, 14:33

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  7. core-ci voted on patch set 3 V +1 04/14/26, 14:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100170

  8. Benjamin Kott uploaded patch set 4 V +1 04/14/26, 15:35

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  9. core-ci voted on patch set 4 V -1 04/14/26, 15:44 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100172

  10. Christian Kuhn commented on patch set 4 CR -2 04/14/26, 17:17

  11. Benjamin Kott uploaded patch set 5 V -1 04/14/26, 23:02

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  12. Benjamin Kott updated the commit message in patch set 6 04/14/26, 23:05

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  13. core-ci voted on patch set 5 V +1 04/14/26, 23:14 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100210

  14. core-ci voted on patch set 6 V +1 04/14/26, 23:16 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100211

  15. Benjamin Kott uploaded patch set 7 V +1 04/15/26, 00:41

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  16. core-ci voted on patch set 7 V +1 04/15/26, 00:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100214

  17. Benjamin Kott rebased onto patch set 8 V +1 04/15/26, 09:02

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  18. core-ci voted on patch set 8 V +1 04/15/26, 09:40 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100238

  19. Benjamin Kott uploaded patch set 9 V +1 04/16/26, 12:58

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  20. Benjamin Kott uploaded patch set 10 04/16/26, 13:24

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  21. core-ci voted on patch set 10 V +1 04/16/26, 13:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100321

  22. core-ci voted on patch set 9 V +1 04/16/26, 13:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100319

  23. Benjamin Kott uploaded patch set 11 V +1 04/16/26, 13:46

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  24. Benjamin Kott uploaded patch set 12 04/16/26, 13:59

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  25. core-ci voted on patch set 11 V +1 04/16/26, 14:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100327

  26. core-ci voted on patch set 12 V +1 04/16/26, 14:11 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100329

  27. Benjamin Kott uploaded patch set 13 V +1 04/20/26, 06:44

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  28. core-ci voted on patch set 13 V +1 04/20/26, 07:00 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100509

  29. Benjamin Kott uploaded patch set 14 V +1 04/20/26, 21:17

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  30. core-ci voted on patch set 14 V +1 04/20/26, 21:26 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100602

  31. Benjamin Kott commented on patch set 14 05/05/26, 09:11

    How do we proceed here? Processing is still blocked here.
  32. Garvin Hicking commented on patch set 14 05/29/26, 10:24

    When I open the styleguide "graphical functions" layer (that I now understand why it's there and not in "environment") and scroll in the modal popup, close the modal popup, I can no longer scroll in the regular interface.
  33. Garvin Hicking commented on patch set 14 05/29/26, 11:18

    ThumbnailViewHelper.php:102

    from my understanding this would prevent image processor that for example turn a PDF file into a thumbnail?!

    GraphicsCanvas.php:38

    I know this would take serious effort, so please bear with me... but I think we need the same SvgImage / SvgFactory distinction here. So we need one "Canvas" value object, and one "CanvasOperations" service class, which can take a canvas object as input and apply its transformations. This will prevent fluent API of course, but I think it will be much more beneficial in the future, better testable, and also better for LLM Agents to work with hard architectural decisions that we'll need to enforce across the core. So instead of: ``` $canvas = GraphicsCanvas::create(8, 8, 0, 0, 0); $canvas->fillRect(0, 0, 4, 4, $canvas->allocateColor(255, 0, 0)); $canvas->fillRect(4, 0, 4, 4, $canvas->allocateColor(0, 255, 0)); $canvas->fillRect(0, 4, 4, 4, $canvas->allocateColor(0, 0, 255)); $canvas->fillRect(4, 4, 4, 4, $canvas->allocateColor(255, 255, 255)); ``` let's have this: ``` $canvas = GraphicsCanvasFactory::create(8, 8, 0, 0, 0); $this->graphicsCanvasOperations->fillRect($canvas, 0, 0, 4, 4, $this->graphicsCanvasOperations->allocateColor(255, 0, 0)); $this->graphicsCanvasOperations->fillRect($canvas, 4, 0, 4, 4, $this->graphicsCanvasOperations->allocateColor(0, 255, 0)); $this->graphicsCanvasOperations->fillRect($canvas, 0, 4, 4, 4, $this->graphicsCanvasOperations->allocateColor(0, 0, 255)); $this->graphicsCanvasOperations->fillRect($canvas, 4, 4, 4, 4, $this->graphicsCanvasOperations->allocateColor(255, 255, 255)); ``` or even this: ``` $canvas = GraphicsCanvasFactory::create(8, 8, 0, 0, 0); $operations = [ $this->graphicsCanvasOperationEnum::fillRect => [0, 0, 4, 4, $this->graphicsCanvasOperations->allocateColor(255, 0, 0)), $this->graphicsCanvasOperationEnum::fillRect => [4, 0, 4, 4, $this->graphicsCanvasOperations->allocateColor(0, 255, 0)), $this->graphicsCanvasOperationEnum::fillRect => [0, 4, 4, 4, $this->graphicsCanvasOperations->allocateColor(0, 0, 255)), $this->graphicsCanvasOperationEnum::fillRect => [4, 4, 4, 4, $this->graphicsCanvasOperations->allocateColor(255, 255, 255)), ]; $canvas = $this->graphicsCanvasOperations->apply($canvas, $operations); ``` The result could even be a immutable canvas object then, still with "ease of use" of multiple applications. We could even "outsource" every single operation as a GraphicalCanvas\Operation\rect, GraphicalCanvas\Operation\circle etc. object, make it a tagged iterator, collect every operation dynamically, and then let GDLib or ImageMagick provide each operation on their own. I think only this allows us to refactor it into this in the future, if we now make the right architectural, binding choices.

    LocalImageProcessor.php:389

    See other note - I like that we defer this 1990-looking gif. We probably should log an error for this though instead. Definitely a custom/other processor though needs to be able to create previews for non-image files.

    Deprecation-109578-GifBuilderGetTemporaryImageWithText.rst:6

    Honestly I think we could keep this method arround, it might be nice for extensions and implementors to have such a "dummy rendering" in place?

    GraphicalFunctionsController.php:61

    I think we could extract this as a ArrayUtility helper method.

    GraphicalFunctionsController.php:127

    I would extract this into a private method instead for better maintainability/readability.

    GraphicalFunctionsController.php:173

    Extract this into a helper method too to prevent a very long running "main" method. Better even, create a "DemoProvider" class that has this scaffodling, to keep the Controller a bit more "sane" to read.

    GraphicalFunctionsController.php:700

    Use short domain language notation.

    GifBuilder.fluid.html:10

    I love this view!

    GridDataService.php:806

    (same question - what does this do to PDF previews and other custom processors?)
  34. Oliver Hader wrote 06/26/26, 09:47

    Removed Code-Review-2 by Christian Kuhn
  35. Oliver Hader commented on patch set 14 06/26/26, 09:48

    Unblocking this patch to proceed in a constructive way, without blocking this initiative by the `-2` that has been given.
  36. Benjamin Kott rebased onto patch set 15 V +1 07/21/26, 07:45

  37. core-ci voted on patch set 15 V +1 07/21/26, 07:58 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105077

  38. Benjamin Kott uploaded patch set 16 V +1 07/22/26, 11:15

  39. Benjamin Kott commented on patch set 16 07/22/26, 11:18

    GraphicalFunctionsController.php:61 Reply

    Done

    GraphicalFunctionsController.php:127 Reply

    Done

    GraphicalFunctionsController.php:173 Reply

    Done

    GraphicalFunctionsController.php:700 Reply

    Done
  40. Benjamin Kott commented on patch set 16 07/22/26, 11:21

    ThumbnailViewHelper.php:102 Reply

    is image runs against, gfx image config, that currently needs to hold pdf to be processed, added tests
  41. core-ci voted on patch set 16 V +1 07/22/26, 11:23 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105161

  42. Benjamin Kott commented on patch set 16 07/22/26, 12:16

    Reply

    Done
  43. Benjamin Kott commented on patch set 16 07/22/26, 12:26

    LocalImageProcessor.php:389 Reply

    Done
  44. Benjamin Kott commented on patch set 16 07/22/26, 12:28

    GridDataService.php:806 Reply

    pdfs need to be marked as image to be processed we only exclude other files
  45. Garvin Hicking commented on patch set 16 07/22/26, 12:31

    Deprecation-109578-GifBuilderGetTemporaryImageWithText.rst:6 Reply

    Talked to Benji about this. The new API already will make it easier to integrate this properly. No need to carry the legacy weight around then, which will forever be bound the the 1990s gif. Resolving.
  46. Garvin Hicking commented on patch set 16 07/22/26, 12:35

    GraphicsCanvas.php:38 Reply

    I won't find time for this to implement myself in the foreseeable time, and also don't want to implement something that no one else is supporting. However, personally I can't vote on the "working model" approach, but I won't be blocking anyone who feels to go with the current approach. I'll leave it unresolved for the positive voters to resolve. I'd be happy for anyone pushing this patch forward in either direction, if they feel this is an architectural sound way for the future and can maintain the concept. Thanks for the work already in this patch, and any further finishing touches on it! 😊
  1. Andreas Kienast commented on patch set 16 07/23/26, 15:01

    GifBuilder.php:2330

    Interesting, this file doesn't exist.
  2. Andreas Kienast commented on patch set 16 CR -1 07/24/26, 05:48

    Needs a rebase after https://review.typo3.org/c/Packages/TYPO3.CMS/+/94909 went in. Also, the ReST has to be moved and the deprecations need adjustments (v15 -> v16).

    GifBuilder.php:2330 Reply

    Never mind, my IDE trolled me...
  3. Andreas Kienast uploaded patch set 17 CR -1 V +1 07/24/26, 07:21

  4. core-ci voted on patch set 17 V -1 07/24/26, 07:38 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105295

  5. Andreas Kienast uploaded patch set 18 V -1 07/24/26, 14:07

  6. Andreas Kienast commented on patch set 18 07/24/26, 14:08

    GraphicsCanvas.php:76

    `canRead()` and `canWrite()` should perhaps also check whether `isAvailable()` is true. wdyt?
  7. core-ci voted on patch set 18 V +1 07/24/26, 14:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105321

  8. Benni Mack commented on patch set 18 07/24/26, 14:33

    this patch covers a lot of changes, I'd rather split this up. First, I recommends building a capabiliites / "supported" class (service). Then, the "generateTemporaryImage" could a separate change, even a bugfix to actually render a shipped SVG "Could not generate preview image" so we do not need to generate another temp image again. This would then reduce this code making a review easier to grasp.
  9. Benni Mack uploaded patch set 19 V +1 07/25/26, 14:15

  10. Benni Mack commented on patch set 19 07/25/26, 14:17

    Reply

    I updated this patch

    GraphicsCanvas.php:38 Reply

    @garvin@hick.ing please see the changes now, I made the GraphicsCanvas immutable and also extracted some capabilities, which we're gonna touch in followup patches now again.

    GraphicsCanvas.php:76 Reply

    Done
  11. core-ci voted on patch set 19 V +1 07/25/26, 14:22 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105394

  12. Benjamin Kott uploaded patch set 20 V +1 08/25/26, 12:50

  13. Benjamin Kott commented on patch set 20 08/25/26, 12:53

    GraphicsCanvas.php:38 Reply

    as discussed with benni, revoked bennis changes, and improved the gd detection
  14. core-ci voted on patch set 20 V +1 08/25/26, 12:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107089

  15. Georg Ringer voted on patch set 20 CR +1 V +1 08/25/26, 13:42

  16. Georg Ringer uploaded patch set 21 08/25/26, 14:29

    Copied Votes: * Code-Review+1 (copy condition: "**changekind:NO_CHANGE** OR is:MIN") * Verified+1 (copy condition: "**changekind:NO_CHANGE**")
  17. core-ci voted on patch set 21 V +1 08/25/26, 14:37 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107091

  18. Andreas Kienast commented on patch set 21 CR -1 08/26/26, 05:59

    GraphicsCanvas.php:182

    Excerpt from https://www.php.net/manual/en/function.imagesavealpha.php: > Note: > > **imagesavealpha()** is only meaningful for PNG images, since the full alpha channel is always saved for WebP and AVIF. It is not recommended to rely on this behavior, as it may change in the future. Thus, **imagesavealpha()** should be called deliberately also for WebP and AVIF images.

    GraphicsCanvas.php:244

    This method is unused, but single calls to `imagesavealpha()` and `imagealphablending()` are spread in this class.

    GraphicalFunctionsController.php:46

    We can finally use typed constants (`private const string ...`)
  19. Benjamin Kott uploaded patch set 22 CR +1 V +1 08/26/26, 07:11

  20. Benjamin Kott commented on patch set 22 08/26/26, 07:11

    GraphicsCanvas.php:182 Reply

    Done

    GraphicsCanvas.php:244 Reply

    Done

    GraphicalFunctionsController.php:46 Reply

    Done
  21. core-ci voted on patch set 22 V +1 08/26/26, 07:18 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107119

  22. Andreas Kienast voted on patch set 22 CR +1 V +1 08/26/26, 07:25

  23. Georg Ringer voted on patch set 22 CR +1 V +1 08/26/26, 08:10

  24. Benjamin Kott voted on patch set 22 CR +2 V +2 08/26/26, 08:18

  25. Benjamin Kott merged patch set 23 08/26/26, 08:18