Project

General

Profile

Actions

Bug #91274

open

Image composite operations fail with ImageMagick 7

Added by Alexander Nitsche about 4 years ago. Updated 4 months ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
Image Generation / GIFBUILDER
Target version:
-
Start date:
2020-05-03
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
9
PHP Version:
7.3
Tags:
Complexity:
medium
Is Regression:
Sprint Focus:

Description

Problem/Description

The standard graphical functions class TYPO3\CMS\Core\Imaging\GraphicalFunctions fails to work properly with ImageMagick 7 (current major release) as it uses the outdated option +matte to remove the alpha layer in the output file instead of the more versatile option -alpha. See https://www.imagemagick.org/script/command-line-options.php#alpha for further details.

Affected example

  1. Run a TYPO3 instance with ImageMagick 7
  2. Navigate to TYPO3 Admin Panel > Environment > Image Processing and run the tests
  3. Check the test results: 4 tests have failed:
    1. Combine using a GIF mask with only black and white
    2. Combine using a JPG mask with graylevels
    3. Render text with TrueType font using 'niceText' option
    4. Render 'niceText' with a shadow under

Environment

  1. MariaDB 10.4.12
  2. Nginx 1.16.1
  3. PHP 7.3.17
  4. TYPO3 9.5.16
  5. ImageMagick 7.0.9-7 Q16 x86_64 2019-12-03

Checking the TYPO3 code base on GitHub this problem should be also reproducable on TYPO3 10.

Fixing the problem

I assume this problem can be either resolved by adding a hint in the TYPO3 docs and TYPO3 system tests that it does not support ImageMagick 7 at the moment
— or
by adding a switch to the TYPO3\CMS\Core\Imaging\GraphicalFunctions class which uses +matte or -alpha depending on the ImageMagick version (the history of ImageMagick has to be checked)
— or
by adding some smart switch to the TYPO3\CMS\Core\Imaging\GraphicalFunctions class which checks for the support of the feature +matte and -alpha of the installed ImageMagick/GraphicMagick and uses the one which is available.

Proof of Concept

Run the image tests and confirm that the 4 tests mentioned above fail. Replace all occurrences of +matte by -alpha off in TYPO3\CMS\Core\Imaging\GraphicalFunctions, run the image tests again and confirm that all tests succeed.

Greetings
Alex


Files

fails_1.png (146 KB) fails_1.png Fail - Combine using a GIF Alexander Nitsche, 2020-05-03 13:28
fails_2.png (135 KB) fails_2.png Fail - Combine using a JPG Alexander Nitsche, 2020-05-03 13:28
fails_3.png (88.2 KB) fails_3.png Fail - Render niceText Alexander Nitsche, 2020-05-03 13:28
succeeds_1.png (161 KB) succeeds_1.png Success - Combine using a GIF Alexander Nitsche, 2020-05-03 13:28
succeeds_2.png (150 KB) succeeds_2.png Success - Combine using a JPG Alexander Nitsche, 2020-05-03 13:28
succeeds_3.png (132 KB) succeeds_3.png Success - Render niceText Alexander Nitsche, 2020-05-03 13:28
fails_4.png (66.2 KB) fails_4.png Fail - Render text with TrueType Alexander Nitsche, 2020-05-03 13:31
succeeds_4.png (79.8 KB) succeeds_4.png Success - Render text with TrueType Alexander Nitsche, 2020-05-03 13:31
Actions

Also available in: Atom PDF