Review main Merged

93760[TASK] Introduce value objects for GIFBUILDER effects

Benjamin Kott CR +2 V +2 Hard +931 −61 updated 10/17/26, 11:34

Commit message

Each EFFECT keyword becomes a readonly value object that normalizes
its parameters in the constructor. An effect instance therefore only
ever holds valid values, and the bounds of every effect are defined
and tested in one place instead of inside GifBuilder.

EffectParser maps the closed list of keywords to these objects and
GifBuilder renders them as before. All classes are @internal.

blur and sharpen now stop at 99 as documented. rotate takes any
angle and normalizes it to one turn, which v14 clamped to 0..360.

Review

  • Code review CR +2 Done
    • Benjamin Kott +2
    • Benni Mack +1
  • Verified V +2 Done
    • Benjamin Kott +2
    • Benni Mack +1
    • core-ci +1 CI

Issues 1

Files 22

Review log 2839

Show 1114 earlier messages
  1. Benjamin Kott uploaded patch set 1 04/20/26, 22:37

  2. core-ci voted on patch set 1 V +1 04/20/26, 22:46 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100604

  3. Christian Kuhn commented on patch set 1 04/21/26, 00:49

    it looks to me as if a closure based approach would make sense here: you create ~15 data objects with an empty interface to end up with two closed methods with match statements. the interface is an invitation that leads to a closed door. the commit message states this will change (in one sentence), but it's hard to have the full picture with having 4 split patches already that hide many other decisions away. suggestion here would be: inline into a single parseEffects() that returns list<\Closure(GraphicsCanvas), call it in makeEffect() and have a one-liner foreach executing $effect($canvas). would work for *this* patch, but may collapse in combination with the other patches. but those need reviews as well. i had similar thoughts when i saw GraphicsCanvas in one of the other patch already, which mixes state with service characteristics and could benefit from closures to resolve this as well. this is a powerful and huge refactoring. please mark these change as PoC or WIP so we can look at it and discuss architectural decisions before implying merge readiness.
  4. Benjamin Kott commented on patch set 1 04/21/26, 03:39

    Reply

    thx for the feedback, these are not 4 split patches but a relation chain so you can see the working target on the top. it´s done this way to provide a better picture what to expect in the end. from a standalone view this patch does not make huge sense, i tried come up with a contract between different processors here. i originally started with a simpler enum but needed have the configuration boundaries locked in. it was the best way i have found to be able to let someone declare support for an effect and also have the value object as a contract it claims to support. Please see the full picture here: https://review.typo3.org/c/Packages/TYPO3.CMS/+/93628/47/typo3/sysext/core/Classes/Imaging/Processor/ProcessorChain.php#250 https://review.typo3.org/c/Packages/TYPO3.CMS/+/93628/47/typo3/sysext/core/Classes/Imaging/Processor/Contract/EffectsInterface.php https://review.typo3.org/c/Packages/TYPO3.CMS/+/93628/47/typo3/sysext/core/Classes/Imaging/Processor/ImageMagickProcessor.php#173 https://review.typo3.org/c/Packages/TYPO3.CMS/+/93628/47/typo3/sysext/core/Classes/Imaging/Processor/GraphicsMagickProcessor.php#154 https://review.typo3.org/c/Packages/TYPO3.CMS/+/93628/47/typo3/sysext/core/Classes/Imaging/Processor/GdProcessor.php#276 I am open for better ideas how to design the communication contracts here, i was able to come up to far. the relation chain is kept in tact and updated all the time, this makes it harder to keep in tact but you can always checkout the top one to see how everything fits together in the end. the other patches were more self contained and were bugfixes that need to happen in one way or the other, this one is extracted the functionality already to build up on this in the following patches as i try to get the main patch into a reviewable state and work out the details that still do not feel right, it currently also contains a lot of tests and demos in the styleguide part to showcase it for now, without having a final place for it. 93628: [WIP][TASK] ALLOW GD ONLY | https://review.typo3.org/c/Packages/TYPO3.CMS/+/93628
  5. Benjamin Kott commented on patch set 1 04/21/26, 04:24

    Reply

    just a note here, i consider the patches not marked as wip as merge ready, while the relation chain itself needs to be reviewed from the bottom to top, the changes also the bugfixes are ready from my pow. they now need normal review especially the bugfixes as they probably need to target older versions for the reasons i tried to describe in the commit messages. but i left open IF we want to really backport them or call it a day for released versions, aside from v14 (only the bugfixes), everything else like this one should be target v15
  6. Christian Kuhn voted on patch set 1 CR -2 04/21/26, 04:32

  7. Christian Kuhn commented on patch set 1 04/21/26, 04:35

    Reply

    none of these patches is merge ready until we aligned on fundamential architectural questions. let's sort this out first, please. we can talk about potential backports when that's achieved.
  8. Oliver Hader wrote 06/26/26, 09:49

    Removed Code-Review-2 by Christian Kuhn
  9. Oliver Hader commented on patch set 1 06/26/26, 09:49

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

  11. core-ci voted on patch set 2 V +1 07/21/26, 08:04 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105078

  12. Benjamin Kott rebased onto patch set 3 V +1 07/22/26, 12:48

  13. core-ci voted on patch set 3 V +1 07/22/26, 13:02 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105176

  14. Andreas Kienast rebased onto patch set 4 V +1 07/24/26, 07:21

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

  2. Andreas Kienast rebased onto patch set 5 V -1 07/24/26, 14:07

  3. core-ci voted on patch set 5 V +1 07/24/26, 14:19 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/105322

  4. Benjamin Kott uploaded patch set 6 V +1 09/09/26, 18:51

  5. core-ci voted on patch set 6 V +1 09/09/26, 19:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/108213

  6. Andreas Kienast commented on patch set 6 CR -1 10/10/26, 20:01

    Rotate.php:31

    Clamping is the wrong normalization for an angle. Rotation is cyclic, so any value outside 0..360 still denotes a valid rotation, and clamping silently turns it into a different one, in most cases into none at all. I checked this with additional cases in `GifBuilderTest::effectKeywordDataProvider()`, on a 30x20 canvas: TypoScript before this change PS 6 rotate = 90 20x30 20x30 rotate = -90 20x30 (rotated) 30x20 (not rotated) rotate = 450 20x30 (rotated by 90°) 30x20 (not rotated, clamped to 360) The commit message names `rotate=720` as the example, which hides the problem: 720, 360 and 0 happen to be the same rotation. For every other out-of-range value the image changes, without any notice to the integrator. `EffectTest` pins this behaviour ('rotate clamps below range', 'rotate clamps above range'). In addition, the value changes from `float` to `int`: the previous code rotated by `-(float)$value`, so `rotate = 45.5` now loses its fraction. Please address this in this change: 1. Normalize the angle modulo 360 instead of clamping it, e.g. -30 -> 330, 450 -> 90, and keep it a `float` as before. 2. Adjust the two `EffectTest` cases accordingly, and add GifBuilder cases for a negative angle and one above 360, so the rendered result is covered as well. 3. Correct the commit message: it should not list `rotate` among the effects that "clamp to the documented maximum".
  7. Benjamin Kott commented on patch set 6 10/10/26, 22:39

    Rotate.php:31 Reply

    please see our documentation for that: https://docs.typo3.org/m/typo3/reference-typoscript/main/en-us/Gifbuilder/ObjectNames/Effect/Index.html#confval-gifbuilder-effect-rotate i took the here to follow this one instead of any possible option. im, gm and gd round the final canvas differently i opted that it´s not worth to go the full mile here and only support what is documented as long as its valid. negative expressions can also be achieved bei choosing the counterpart in clockwise rotation.
  8. Benjamin Kott uploaded patch set 7 CR -1 V +1 10/15/26, 16:26

  9. Benjamin Kott commented on patch set 6 10/15/26, 16:26

    Rotate.php:31 Reply

    Agreed, thanks for checking it with real renders. PS 7 normalizes the angle modulo 360 and keeps it a float, so -90 rotates by 270° clockwise and 450 by 90°. EffectTest covers wrapping, fractions and several turns, and GifBuilderTest::rotateNormalizesTheAngleToOneTurn() renders 90, 360, -90 and 450. The commit message no longer lists rotate among the clamped effects, and an Important changelog entry describes the change for integrators.
  10. core-ci voted on patch set 7 V +1 10/15/26, 16:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/111240

  11. Helmut Hummel commented on patch set 7 10/16/26, 14:45

    EffectInterface.php:29

    I can't see an usage (except implements references) of this interface at all, thus I suggest to remove it until it becomes useful
  12. Benjamin Kott uploaded patch set 8 V +1 10/16/26, 15:21

  13. core-ci voted on patch set 8 V +1 10/16/26, 15:29 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/111373

  14. Benjamin Kott uploaded patch set 9 V +1 10/17/26, 00:23

  15. core-ci voted on patch set 9 V +1 10/17/26, 00:32 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/111406

  16. Benjamin Kott updated the commit message in patch set 10 V +1 10/17/26, 01:29

  17. Benjamin Kott commented on patch set 10 10/17/26, 01:39

    EffectInterface.php:29 Reply

    the interface was sharpened, and the patch was adjusted - would you agree that its now fine?
  18. core-ci voted on patch set 10 V +1 10/17/26, 01:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/111409

  19. Benni Mack commented on patch set 10 10/17/26, 11:03

    EffectInterface.php:29 Reply

    i did throw this over ideas from AI multiple times... the marker interface (used at al after point) has the benefit of typing methods to hand over an instance of an implementation of the interface instead of just "object". That's basically it. The approach with the static methods is nice, but now that I looked over it again and again, we could move the objects in a static list (since it's a closed interface) and do everything in the parser. Then: We can leave the interface out in this change, only introduce the DTOs as the interface is not needed right now. In order to prove this change to be "clean", it indeed makes a lot of sense to add the interface later, if we only use the marker then.
  20. Benni Mack uploaded patch set 11 V +1 10/17/26, 11:21

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

  22. Benni Mack commented on patch set 11 10/17/26, 11:34

    Reply

    I'm resolving this one now because I think this change works very will as a standalone patch, ensuring the values we have for each effect are bound to their usage: On closures vs. value objects: for GifBuilder alone, list<\Closure(GraphicsCanvas)> would work, I agree. I'd still keep the value objects: - The bounds of each effect stay independent of the renderer. A closure over GraphicsCanvas is bound to GD. In the chain (93628), ImageMagick and GraphicsMagick need to turn the same normalized rotate/wave values into CLI arguments, so they need to read the values, not run a GD callback. - The values can be tested directly: EffectTest and EffectParserTest compare objects with assertEquals(), while a closure can only be tested by rendering an image. - The cost is small: readonly classes that normalize in their constructor, so an instance only ever holds valid values. If we decide that the processors should not share effect definitions, I'm fine with switching to closures. That decision belongs to 93628 rather than to this patch, though, and this change is better. Apart from this, we should not touch v14 anymore in this regard.

    EffectInterface.php:29 Reply

    I did re-work this one now and I think this is by far the best approach we've had so far for this patch: No interface, just a clear VO principle.
  23. Benni Mack voted on patch set 11 CR +1 V +1 10/17/26, 11:34

  24. Benjamin Kott voted on patch set 11 CR +2 V +2 10/17/26, 11:34

  25. Benjamin Kott merged patch set 12 10/17/26, 11:34