Review main Merged

89032[BUGFIX] Preserve transparency for image/graphicsmagick conversions

Garvin Hicking CR +2 V +2 Normal +81 −1 updated 04/16/25, 08:41

Commit message

By default, imagemagick and graphicsmagick will convert for example
a SVG image with transparency to a PNG image by replacing transparency
information with white (see [1]).

To preserve transparency, the option "-background none" is added
by default to the list of parameters.

Note that this can also be influenced by using the TYPO3 configuration
option `procvessor_stripColorProfileParameters' to include the option
manually:

```
$GLOBALS['TYPO3_CONF_VARS']['GFX']
    ['processor_stripColorProfileParameters'] = [
  '+profile',
  '*',
  '-background',
  'none'
];
```

This is considered a hack, and TYPO3 should provide this
out-of-the-box.

Due to possible side-effects and the ability to fix this with
configuration, this patch only targets main (v14).

Sadly it is not (easily) possible to run automated tests with
different im/gm versions in the testing suite, and to check
transparency information on compressed files is prone to false
negatives.

The "Admin Tools > Environment > Test Images ..." check has been
enhanced with one variant of transparent SVG to PNG and WEBP to
showcase the behaviour (also showcasing the issue that its not
transparent, when the "-background none" option is not added).

For SVG conversion to properly work and retrieve width/height
information for scaling purposes, this patch allows this as
a drive-by. A todo note to optimize this is already in effect
and should be addressed with a dedicated change.

[1] https://imagemagick.org/script/command-line-options.php#background

Review

  • Code review CR +2 Done
    • Garvin Hicking +2
    • Andreas Kienast +1
    • Benni Mack +1
  • Verified V +2 Done
    • Garvin Hicking +2
    • Andreas Kienast +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 1

Files 7

Review log 1723

  1. Garvin Hicking uploaded patch set 1 04/10/25, 09:08

  2. core-ci voted on patch set 1 V +1 04/10/25, 09:13 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77417

  3. Garvin Hicking marked it work in progress 04/10/25, 09:32

  4. Garvin Hicking uploaded patch set 2 V +1 04/10/25, 10:24

  5. Garvin Hicking commented on patch set 2 04/10/25, 10:24

    This change is ready for review.
  6. core-ci voted on patch set 2 V -1 04/10/25, 10:30 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77427

  7. Garvin Hicking uploaded patch set 3 V -1 04/10/25, 10:33

  8. Garvin Hicking commented on patch set 4 04/10/25, 10:38

    Published edit on patch set 3.
  9. core-ci voted on patch set 3 V +1 04/10/25, 10:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77430

  10. core-ci voted on patch set 4 V +1 04/10/25, 10:45 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77431

  11. Benni Mack updated the commit message in patch set 5 V +1 04/15/25, 15:33

  12. Benni Mack voted on patch set 5 CR +1 04/15/25, 15:33

  13. core-ci voted on patch set 5 V +1 04/15/25, 15:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77768

  14. Benni Mack voted on patch set 5 V +1 04/16/25, 06:21

  15. Andreas Kienast commented on patch set 5 V -1 04/16/25, 07:03

    EnvironmentController.php:682

    why do we pass a height here? This causes distorted renderings in my tests.
  16. Garvin Hicking uploaded patch set 6 CR +1 V +1 04/16/25, 07:29

  17. Garvin Hicking commented on patch set 6 04/16/25, 07:30

    EnvironmentController.php:682 Reply

    Thanks a lot. That was not intentional and a leftover from my tests. (However I don't understand why it showed up for me scaled normally, and not for you - but omitting height like in the other tests still also works for me)
  18. core-ci voted on patch set 6 V +1 04/16/25, 07:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/77808

  19. Garvin Hicking commented on patch set 6 04/16/25, 07:36

    EnvironmentController.php:682 Reply

    OK, Andi pointed me at it: I had `GFX.processor_allowUpscaling` set to `false`, this is why my system behaved differently. Case closed.
  20. Andreas Kienast voted on patch set 6 CR +1 V +1 04/16/25, 07:39

  21. Benni Mack voted on patch set 6 CR +1 V +1 04/16/25, 08:41

  22. Garvin Hicking voted on patch set 6 CR +2 V +2 04/16/25, 08:41

  23. Garvin Hicking merged patch set 7 04/16/25, 08:41