[BUGFIX] Allow Setting colorspace in the Install Tool. 74/17474/12
authorAnja Leichsenring <aleichsenring@ab-softlab.de>
Sat, 12 Jan 2013 10:50:37 +0000 (11:50 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 7 Mar 2013 23:22:47 +0000 (00:22 +0100)
Some versions of Imagemagick (6.7.0 and above) use the sRGB colorspace
instead RGB as before. This results in darker images after processing,
because TYPO3 hardcoded the RGB colorspace in graphical functions.

This patch introduces a setting in the GFX part of the Install Tool,
lets the user choose the sufficient colorspace.
This selection is used in graphical functions.

Additionaly a hint on the setting was added to the Image Processing Test
'Read Images' in the Install Tool.

Fixes: #36597
Releases: 6.1, 6.0, 4.7, 4.5
Change-Id: I50a26c414705afa3177a2f12fc3bb4532c2d0f7f
Reviewed-on: https://review.typo3.org/17474
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
typo3/sysext/core/Configuration/DefaultConfiguration.php
typo3/sysext/install/Classes/Installer.php

index 2013a1c..cbba891 100644 (file)
@@ -82,6 +82,47 @@ class GraphicalFunctions {
         */
        public $png_truecolor = FALSE;
 
+       /**
+        * defines the RGB colorspace to use
+        *
+        * @var string
+        */
+       protected $colorspace = 'RGB';
+
+       /**
+        * colorspace names allowed
+        *
+        * @var array
+        */
+       protected $allowedColorSpaceNames = array(
+               'CMY',
+               'CMYK',
+               'Grey',
+               'HCL',
+               'HSB',
+               'HSL',
+               'HWB',
+               'Lab',
+               'LCH',
+               'LMS',
+               'Log',
+               'Luv',
+               'OHTA',
+               'Rec601Luma',
+               'Rec601YCbCr',
+               'Rec709Luma',
+               'Rec709YCbCr',
+               'RGB',
+               'sRGB',
+               'Transparent',
+               'XYZ',
+               'YCbCr',
+               'YCC',
+               'YIQ',
+               'YCbCr',
+               'YUV'
+       );
+
        // 16777216 Colors is the maximum value for PNG, JPEG truecolor images (24-bit, 8-bit / Channel)
        /**
         * @todo Define visibility
@@ -290,9 +331,14 @@ class GraphicalFunctions {
                if (function_exists('imagecreatefromgif') && function_exists('imagegif')) {
                        $this->gdlibExtensions .= ',gif';
                }
-               if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['png_truecolor']) {
+               if ($gfxConf['png_truecolor']) {
                        $this->png_truecolor = TRUE;
                }
+
+               if ($gfxConf['colorspace'] && in_array($gfxConf['colorspace'], $this->allowedColorSpaceNames, TRUE)) {
+                       $this->colorspace = $gfxConf['colorspace'];
+               }
+
                if (!$gfxConf['im']) {
                        $this->NO_IMAGE_MAGICK = 1;
                }
@@ -306,7 +352,7 @@ class GraphicalFunctions {
                }
                // Setting default JPG parameters:
                $this->jpegQuality = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($gfxConf['jpg_quality'], 10, 100, 75);
-               $this->cmds['jpg'] = ($this->cmds['jpeg'] = '-colorspace RGB -sharpen 50 -quality ' . $this->jpegQuality);
+               $this->cmds['jpg'] = ($this->cmds['jpeg'] = '-colorspace ' . $this->colorspace . ' -sharpen 50 -quality ' . $this->jpegQuality);
                if ($gfxConf['im_combine_filename']) {
                        $this->combineScript = $gfxConf['im_combine_filename'];
                }
@@ -336,14 +382,14 @@ class GraphicalFunctions {
                        // Effects in Imagemagick 5+ tends to render very slowly!!
                        // - therefore must be disabled in order not to perform sharpen, blurring and such.
                        $this->NO_IM_EFFECTS = 1;
-                       $this->cmds['jpg'] = ($this->cmds['jpeg'] = '-colorspace RGB -quality ' . $this->jpegQuality);
+                       $this->cmds['jpg'] = ($this->cmds['jpeg'] = '-colorspace ' . $this->colorspace . ' -quality ' . $this->jpegQuality);
                }
                // ... but if 'im_v5effects' is set, don't care about 'im_no_effects'
                if ($gfxConf['im_v5effects']) {
                        $this->NO_IM_EFFECTS = 0;
                        $this->V5_EFFECTS = 1;
                        if ($gfxConf['im_v5effects'] > 0) {
-                               $this->cmds['jpg'] = ($this->cmds['jpeg'] = '-colorspace RGB -quality ' . intval($gfxConf['jpg_quality']) . $this->v5_sharpen(10));
+                               $this->cmds['jpg'] = ($this->cmds['jpeg'] = '-colorspace ' . $this->colorspace . ' -quality ' . intval($gfxConf['jpg_quality']) . $this->v5_sharpen(10));
                        }
                }
                // Secures that images are not scaled up.
@@ -3003,5 +3049,4 @@ class GraphicalFunctions {
 
 }
 
-
-?>
+?>
\ No newline at end of file
index ff91d80..4f21fa5 100644 (file)
@@ -55,7 +55,8 @@ return array(
                'jpg_quality' => 70,                                                    // Integer: Default JPEG generation quality
                'enable_typo3temp_db_tracking' => FALSE,                // Boolean: If set, then all files in typo3temp will be logged in a database table. In addition to being a log of the files with original filenames, it also serves to secure that the same image is not rendered simultaneously by two different processes.
                'TTFdpi' => 96,                                                                 // Integer: Enter how many dpi the FreeType module uses. Freetype1 should be set to 72. Freetype2 should be set to 96 (otherwise fonts are rendered way bigger than FreeType1). This works as a global scaling factor for Freetype.
-               'png_truecolor' => TRUE
+               'png_truecolor' => TRUE,
+               'colorspace' => 'RGB',                                                  // String: Specifiy the colorspace to use. Some ImageMagick versions (like 6.7.0 and above) use the sRGB colorspace, so all images are darker then the original. <br />Possible Values: CMY, CMYK, Grey, HCL, HSB, HSL, HWB, Lab, LCH, LMS, Log, Luv, OHTA, Rec601Luma, Rec601YCbCr, Rec709Luma, Rec709YCbCr, RGB, sRGB, Transparent, XYZ, YCbCr, YCC, YIQ, YCbCr, YUV
        ),
        'SYS' => array(
                // System related concerning both frontend and backend.
index d9a175e..5d29a90 100644 (file)
@@ -4023,7 +4023,11 @@ REMOTE_ADDR was \'' . \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REMOTE
                                                TIF, BMP, PCX, TGA, PDF, AI. The tool \'identify\' will
                                                be used to read the  pixeldimensions of non-web formats.
                                                The tool \'convert\' is used to read the image and write
-                                               a temporary JPG-file
+                                               a temporary JPG-file.
+                                       </p>
+                                       <p>
+                                               In case the images appear remarkably darker than the reference images,
+                                               try to set [TYPO3_CONF_VARS][GFX][colorspace] = sRGB.
                                        </p>
                                ');
                        if ($imActive) {