[TASK] Remove GFX im_imvMaskState and im_negate_mask settings 80/23880/6
authorChristian Kuhn <lolli@schwarzbu.ch>
Tue, 17 Sep 2013 19:23:05 +0000 (21:23 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Wed, 25 Sep 2013 10:50:03 +0000 (12:50 +0200)
There are two very weird settings is GFX array that previously
decided on how "masks" are applied to images if combining
multiple images. GFX/im_negate_mask and GFX/im_imvMaskState are
also manipulated during boostrap and depend on each other.

Fiddling with those settings in ImageMagick 6 and GraphicsMagick
with its supported versions, it turns out that they are obsolete
and can be removed completly. The patch does this.

Change-Id: Ic24c877287382f9e718974a0df3577dad2eeaac9
Resolves: #52088
Releases: 6.2
Reviewed-on: https://review.typo3.org/23880
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
12 files changed:
typo3/sysext/core/Classes/Core/Bootstrap.php
typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php
typo3/sysext/core/Classes/Resource/Processing/LocalCropScaleMaskHelper.php
typo3/sysext/core/Configuration/DefaultConfiguration.php
typo3/sysext/install/Classes/Configuration/Image/CustomPreset.php
typo3/sysext/install/Classes/Configuration/Image/GraphicsMagickPreset.php
typo3/sysext/install/Classes/Configuration/Image/ImageMagick6Preset.php
typo3/sysext/install/Classes/Controller/Action/Tool/TestSetup.php
typo3/sysext/install/Classes/Controller/StepController.php
typo3/sysext/install/Resources/Private/Partials/Action/Tool/TestSetup/CombiningImages.html
typo3/sysext/install/Resources/Private/Partials/Action/Tool/TestSetup/CurrentConfiguration.html
typo3/sysext/install/Resources/Public/Images/TestReference/About.txt

index ed5b46c..3b2388e 100644 (file)
@@ -487,17 +487,11 @@ class Bootstrap {
                        $GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'] = 0;
                }
                if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5']) {
-                       $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] = 1;
                        $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_mask_temp_ext_gif'] = 1;
                        if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'] === 'gm') {
-                               $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] = 0;
-                               $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_imvMaskState'] = 0;
                                $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_v5effects'] = -1;
                        }
                }
-               if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_imvMaskState']) {
-                       $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] ? 0 : 1;
-               }
                return $this;
        }
 
index ea0b13a..e1d165f 100644 (file)
@@ -131,12 +131,6 @@ class GraphicalFunctions {
         */
        public $webImageExt = 'gif,jpg,jpeg,png';
 
-       // Will be ' -negate' if ImageMagick ver 5.2+. See init();
-       /**
-        * @todo Define visibility
-        */
-       public $maskNegate = '';
-
        /**
         * @todo Define visibility
         */
@@ -347,14 +341,6 @@ class GraphicalFunctions {
                        $this->enable_typo3temp_db_tracking = $gfxConf['enable_typo3temp_db_tracking'];
                }
                $this->imageFileExt = $gfxConf['imagefile_ext'];
-               // This should be set if ImageMagick ver. 5+ is used.
-               if ($gfxConf['im_negate_mask']) {
-                       // Boolean. Indicates if the mask images should be inverted first.
-                       // This depends of the ImageMagick version. Below ver. 5.1 this should be FALSE.
-                       // Above ImageMagick version 5.2+ it should be TRUE.
-                       // Just set the flag if the masks works opposite the intension!
-                       $this->maskNegate = ' -negate';
-               }
 
                // Boolean. This is necessary if using ImageMagick 5+.
                // Effects in Imagemagick 5+ tends to render very slowly!!
@@ -677,18 +663,9 @@ class GraphicalFunctions {
                                ImageDestroy($maskImg);
                                // Downscales the mask
                                if ($this->NO_IM_EFFECTS) {
-                                       if ($this->maskNegate) {
-                                               // Negate 2 times makes no negate...
-                                               $command = trim($this->scalecmd . ' ' . $w . 'x' . $h . '!');
-                                       } else {
-                                               $command = trim($this->scalecmd . ' ' . $w . 'x' . $h . '! -negate');
-                                       }
+                                       $command = trim($this->scalecmd . ' ' . $w . 'x' . $h . '! -negate');
                                } else {
-                                       if ($this->maskNegate) {
-                                               $command = trim($conf['niceText.']['before'] . ' ' . $this->scalecmd . ' ' . $w . 'x' . $h . '! ' . $conf['niceText.']['after']);
-                                       } else {
-                                               $command = trim($conf['niceText.']['before'] . ' ' . $this->scalecmd . ' ' . $w . 'x' . $h . '! ' . $conf['niceText.']['after'] . ' -negate');
-                                       }
+                                       $command = trim($conf['niceText.']['before'] . ' ' . $this->scalecmd . ' ' . $w . 'x' . $h . '! ' . $conf['niceText.']['after'] . ' -negate');
                                        if ($conf['niceText.']['sharpen']) {
                                                if ($this->V5_EFFECTS) {
                                                        $command .= $this->v5_sharpen($conf['niceText.']['sharpen']);
@@ -1494,7 +1471,6 @@ class GraphicalFunctions {
                        // Destroy
                        ImageDestroy($blurTextImg);
                        $command = '';
-                       $command .= $this->maskNegate;
                        if ($this->V5_EFFECTS) {
                                $command .= $this->v5_blur($blurRate + 1);
                        } else {
@@ -1525,12 +1501,12 @@ class GraphicalFunctions {
                                        $intensity = MathUtility::forceIntegerInRange($conf['intensity'], 0, 100);
                                }
                                $intensity = ceil(255 - $intensity / 100 * 255);
-                               $this->inputLevels($blurTextImg, 0, $intensity, $this->maskNegate);
+                               $this->inputLevels($blurTextImg, 0, $intensity);
                                $opacity = MathUtility::forceIntegerInRange(intval($conf['opacity']), 0, 100);
                                if ($opacity && $opacity < 100) {
                                        $high = ceil(255 * $opacity / 100);
                                        // Reducing levels as the opacity demands
-                                       $this->outputLevels($blurTextImg, 0, $high, $this->maskNegate);
+                                       $this->outputLevels($blurTextImg, 0, $high);
                                }
                                // Dump the mask again
                                $this->ImageWrite($blurTextImg, $fileMask);
@@ -1927,7 +1903,7 @@ class GraphicalFunctions {
         * @param integer $im GDlib Image Pointer
         * @param integer $low The "low" value (close to 0)
         * @param integer $high The "high" value (close to 255)
-        * @param boolean $swap If swap, then low and high are swapped. (Useful for negated masks...)
+        * @param boolean $swap @deprecated since 6.2, unused and obsolete parameter, was used for older image magick versions
         * @return void
         * @todo Define visibility
         */
@@ -1935,11 +1911,6 @@ class GraphicalFunctions {
                if ($low < $high) {
                        $low = MathUtility::forceIntegerInRange($low, 0, 255);
                        $high = MathUtility::forceIntegerInRange($high, 0, 255);
-                       if ($swap) {
-                               $temp = $low;
-                               $low = 255 - $high;
-                               $high = 255 - $temp;
-                       }
                        $delta = $high - $low;
                        $totalCols = ImageColorsTotal($im);
                        for ($c = 0; $c < $totalCols; $c++) {
@@ -2666,11 +2637,6 @@ class GraphicalFunctions {
        public function combineExec($input, $overlay, $mask, $output, $handleNegation = FALSE) {
                if (!$this->NO_IMAGE_MAGICK) {
                        $params = '-colorspace GRAY +matte';
-                       if ($handleNegation) {
-                               if ($this->maskNegate) {
-                                       $params .= ' ' . $this->maskNegate;
-                               }
-                       }
                        $theMask = $this->randomName() . '.' . $this->gifExtension;
                        $this->imageMagickExec($mask, $theMask, $params);
                        $cmd = GeneralUtility::imageMagickCommand('combine', '-compose over +matte ' . $this->wrapFileName($input) . ' ' . $this->wrapFileName($overlay) . ' ' . $this->wrapFileName($theMask) . ' ' . $this->wrapFileName($output));
@@ -3024,4 +2990,4 @@ class GraphicalFunctions {
 
 }
 
-?>
\ No newline at end of file
+?>
index 5bde458..3595cbb 100644 (file)
@@ -94,7 +94,6 @@ class LocalCropScaleMaskHelper {
                        $maskImage = $configuration['maskImages']['maskImage'];
                        $maskBackgroundImage = $configuration['maskImages']['backgroundImage'];
                        if ($maskImage instanceof Resource\FileInterface && $maskBackgroundImage instanceof Resource\FileInterface) {
-                               $negate = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] ? ' -negate' : '';
                                $temporaryExtension = 'png';
                                if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_mask_temp_ext_gif']) {
                                        // If ImageMagick version 5+
@@ -124,7 +123,7 @@ class LocalCropScaleMaskHelper {
                                        $tmpStr = $gifBuilder->randomName();
                                        //      m_mask
                                        $tempScale['m_mask'] = $tmpStr . '_mask.' . $temporaryExtension;
-                                       $gifBuilder->imageMagickExec($maskImage->getForLocalProcessing(TRUE), $tempScale['m_mask'], $command . $negate);
+                                       $gifBuilder->imageMagickExec($maskImage->getForLocalProcessing(TRUE), $tempScale['m_mask'], $command);
                                        //      m_bgImg
                                        $tempScale['m_bgImg'] = $tmpStr . '_bgImg.miff';
                                        $gifBuilder->imageMagickExec($maskBackgroundImage->getForLocalProcessing(), $tempScale['m_bgImg'], $command);
@@ -133,7 +132,7 @@ class LocalCropScaleMaskHelper {
                                                $tempScale['m_bottomImg'] = $tmpStr . '_bottomImg.' . $temporaryExtension;
                                                $gifBuilder->imageMagickExec($maskBottomImage->getForLocalProcessing(), $tempScale['m_bottomImg'], $command);
                                                $tempScale['m_bottomImg_mask'] = ($tmpStr . '_bottomImg_mask.') . $temporaryExtension;
-                                               $gifBuilder->imageMagickExec($maskBottomImageMask->getForLocalProcessing(), $tempScale['m_bottomImg_mask'], $command . $negate);
+                                               $gifBuilder->imageMagickExec($maskBottomImageMask->getForLocalProcessing(), $tempScale['m_bottomImg_mask'], $command);
                                                // BEGIN combining:
                                                // The image onto the background
                                                $gifBuilder->combineExec($tempScale['m_bgImg'], $tempScale['m_bottomImg'], $tempScale['m_bottomImg_mask'], $tempScale['m_bgImg']);
index 9edfd88..3f102aa 100644 (file)
@@ -42,8 +42,6 @@ return array(
                'im_path' => '/usr/bin/',                                               // Path to the IM tools 'convert', 'combine', 'identify'.
                'im_path_lzw' => '/usr/bin/',                                   // Path to the IM tool 'convert' with LZW enabled! See 'gif_compress'. If your version 4.2.9 of ImageMagick is compiled with LZW you may leave this field blank AND disable the flag 'gif_compress'! Tip: You can call LZW 'convert' with a prefix like 'myver_convert' by setting this path with it, eg. '/usr/bin/myver_' instead of just '/usr/bin/'.
                'im_version_5' => 'im6',                                                // String: Set this either to "im6" or "gm" (uses GraphicsMagick instead of ImageMagick). Setting this value will automatically configure some settings for use with the specified program version.
-               'im_negate_mask' => FALSE,                                              // Boolean: Indicates if the mask images should be inverted first. This depends of the ImageMagick version. Below ver. 5.1 this should be FALSE. Above ImageMagick version 5.2+ it should be TRUE. Just set the flag if the masks works opposite the intension!
-               'im_imvMaskState' => FALSE,                                             // Boolean: If set, the 'im_negate_mask' state is inverted. This is very useful with newer versions of IM5 (at least 5.4.3+) where the 'im_version_5' setting will set 'im_negate_mask' which will eventually be wrong... Halleluja for ImageMagick - have I ever regreted using that package...
                'im_v5effects' => 0,                                                    // <p>Integer (-1, 0, 1)</p><dl><dt>0</dt><dd>disabled</dd><dt>-1</dt><dd>Do not sharpen images by default</dd><dt>1</dt><dd>All; blur and sharpening is allowed in ImageMagick.</dd></dl>
                'im_mask_temp_ext_gif' => FALSE,                                // Boolean: This should be set if ImageMagick is version 5+. This is used in class.tslib_content.php for masking images and the extension png is normally used because it's faster than gif for temporary files. But png seems not to work with some IM 5+ versions, so...
                'im_noScaleUp' => FALSE,                                                // Boolean: If set, images are not being scaled up if told so (in t3lib/stdgraphics.php)
index d4e64bf..20c5d85 100644 (file)
@@ -40,8 +40,6 @@ class CustomPreset extends Configuration\AbstractCustomPreset implements Configu
                'GFX/im_path' => '',
                'GFX/im_path_lzw' => '',
                'GFX/im_version_5' => '',
-               'GFX/im_negate_mask' => 0,
-               'GFX/im_imvMaskState' => 0,
                'GFX/im_v5effects' => 0,
                'GFX/im_mask_temp_ext_gif' => 0,
                'GFX/colorspace' => '',
index 9b0d1a6..bcf48bc 100644 (file)
@@ -51,8 +51,6 @@ class GraphicsMagickPreset extends AbstractImagePreset implements Configuration\
                'GFX/im_path' => '',
                'GFX/im_path_lzw' => '',
                'GFX/im_version_5' => 'gm',
-               'GFX/im_negate_mask' => 0,
-               'GFX/im_imvMaskState' => 0,
                'GFX/im_v5effects' => -1,
                'GFX/im_mask_temp_ext_gif' => 1,
                'GFX/colorspace' => 'RGB',
index 09eeffe..e404c50 100644 (file)
@@ -51,8 +51,6 @@ class ImageMagick6Preset extends AbstractImagePreset implements Configuration\Pr
                'GFX/im_path' => '',
                'GFX/im_path_lzw' => '',
                'GFX/im_version_5' => 'im6',
-               'GFX/im_negate_mask' => 0,
-               'GFX/im_imvMaskState' => 1,
                'GFX/im_v5effects' => 1,
                'GFX/im_mask_temp_ext_gif' => 1,
                'GFX/colorspace' => 'sRGB',
@@ -92,7 +90,7 @@ class ImageMagick6Preset extends AbstractImagePreset implements Configuration\Pr
                                if (strpos($firstResultLine, 'ImageMagick') !== FALSE) {
                                        list(,$version) = explode('ImageMagick', $firstResultLine);
                                        // Example: "6.6.0-4"
-                                       list($version) = explode(' ',trim($version));
+                                       list($version) = explode(' ', trim($version));
                                        if (version_compare($version, '6.0.0') >= 0) {
                                                $this->foundPath = $path;
                                                $result = TRUE;
index 12528b9..fb63924 100644 (file)
@@ -493,9 +493,7 @@ class TestSetup extends Action\AbstractAction implements Action\ActionInterface
                                '\'niceText\' is a concept that tries to improve the antialiasing of the rendered type by'
                                . ' actually rendering the textstring in double size on a black/white mask, downscaling the mask'
                                . ' and masking the text onto the image through this mask. This involves'
-                               . ' ImageMagick \'combine\'/\'composite\' and \'convert\'.' . LF
-                               . ' If the image has another background color than the image above (eg. dark background'
-                               . ' color with light text) then you will have to set TYPO3_CONF_VARS[GFX][im_imvMaskState]=1'
+                               . ' ImageMagick \'combine\'/\'composite\' and \'convert\'.'
                        );
                        $testResults['niceText']['message'] = $message;
                } else {
@@ -597,7 +595,6 @@ class TestSetup extends Action\AbstractAction implements Action\ActionInterface
                $result['imageMagickPath'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path'];
                $result['imageMagickVersion'] = $this->determineImageMagickVersion();
                $result['imageMagick5Effecs'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_v5effects'];
-               $result['imageMagickMaskInvert'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_imvMaskState'];
                $result['gdlibEnabled'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'];
                $result['gdlibPng'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png'];
                $result['freeTypeDpi'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['TTFdpi'];
index 392f346..6c31c10 100644 (file)
@@ -70,12 +70,16 @@ class StepController extends AbstractController {
                'FE/defaultTypoScript_editorcfg.',
                // #25099
                'FE/simulateStaticDocuments',
-               // 52011
+               // #52011
                'GFX/im_combine_filename',
+               // #52088
+               'GFX/im_imvMaskState',
                // #22687
                'GFX/gdlib_2',
                // #52012
                'GFX/im_mask_temp_ext_noloss',
+               // #52088
+               'GFX/im_negate_mask',
                // #52010
                'GFX/im_no_effects',
                // #18431
index 1c2c2d9..23168aa 100644 (file)
                                This verifies that the ImageMagick tool, 'combine'/'composite', is able to
                                combine two images through a grayscale mask.
                        </p>
-                       <p>
-                               If the masking seems to work but inverted, that just means you'll have to make
-                               sure the invert flag is set (some combination of im_negate_mask/im_imvMaskState)
-                       </p>
 
                        <f:for each="{testResults}" as="test">
                                <f:render partial="Action/Tool/TestSetup/DisplayTwinImage" arguments="{_all}"/>
index 6d4eae1..158cf03 100644 (file)
                        </dd>
 
                        <dt>
-                               ImageMagick mask invert:
-                       </dt>
-                       <dd>
-                               {imageConfiguration.imageMagickMaskInvert} <span>(Should be set for some IM versions approx. 5.4+)</span>
-                       </dd>
-
-                       <dt>
                                GDLib enabled:
                        </dt>
                        <dd>
@@ -78,4 +71,4 @@
                        </dd>
                </dl>
        </div>
-</div>
\ No newline at end of file
+</div>
index acbc14e..408ca27 100644 (file)
@@ -10,7 +10,6 @@ $TYPO3_CONF_VARS['GFX']['TTFdpi'] = '96';
 $TYPO3_CONF_VARS['GFX']['gdlib_png'] = '1';
 $TYPO3_CONF_VARS['GFX']['im_path'] = '/usr/bin/';
 $TYPO3_CONF_VARS['GFX']['im_version_5'] = 'im5';
-$TYPO3_CONF_VARS['GFX']['im_imvMaskState'] = '0';
 $TYPO3_CONF_VARS['GFX']['im_v5effects'] = '1';
 $TYPO3_CONF_VARS['GFX']['gdlib_2'] = 1;