[TASK] Remove GFX im_imvMaskState and im_negate_mask settings
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Imaging / GraphicalFunctions.php
index 5279e4c..e1d165f 100644 (file)
@@ -4,7 +4,7 @@ namespace TYPO3\CMS\Core\Imaging;
 /***************************************************************
  *  Copyright notice
  *
- *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
+ *  (c) 1999-2013 Kasper Skårhøj (kasperYYYY@typo3.com)
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -26,33 +26,21 @@ namespace TYPO3\CMS\Core\Imaging;
  *
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
+
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Utility\MathUtility;
+
 /**
  * Standard graphical functions
  *
- * Revised for TYPO3 3.6 July/2003 by Kasper Skårhøj
- *
- * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- */
-/**
- * Class contains a bunch of cool functions for manipulating graphics with GDlib/Freetype and ImageMagick
+ * Class contains a bunch of cool functions for manipulating graphics with GDlib/Freetype and ImageMagick.
  * VERY OFTEN used with gifbuilder that extends this class and provides a TypoScript API to using these functions
  *
- * With TYPO3 4.4 GDlib 1.x support was dropped, also an option from $TYPO3_CONF_VARS
- * $TYPO3_CONF_VARS['GFX']['gdlib_2'] = 0,     // String/Boolean. Set this if you are using the new GDlib 2.0.1+. If you don't set this flag and still use GDlib2, you might encounter strange behaviours like black images etc. This feature might take effect only if ImageMagick is installed and working as well! You can also use the value "no_imagecopyresized_fix" - in that case it will NOT try to fix a known issue where "imagecopyresized" does not work correctly.
- *
  * @author Kasper Skårhøj <kasperYYYY@typo3.com>
- * @package TYPO3
- * @subpackage t3lib
- * @see tslib_gifBuilder
  */
 class GraphicalFunctions {
 
        // Internal configuration, set in init()
-       // The ImageMagick filename used for combining two images. This name changed during the versions.
-       /**
-        * @todo Define visibility
-        */
-       public $combineScript = 'combine';
 
        // If set, there is no frame pointer prepended to the filenames.
        /**
@@ -60,12 +48,6 @@ class GraphicalFunctions {
         */
        public $noFramePrepended = 0;
 
-       // If set, imagecopyresized will not be called directly. For GD2 (some PHP installs?)
-       /**
-        * @todo Define visibility
-        */
-       public $imagecopyresized_fix = 0;
-
        // This should be changed to 'png' if you want this class to read/make PNG-files instead!
        /**
         * @todo Define visibility
@@ -84,6 +66,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',
+               'Gray',
+               '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
@@ -108,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
         */
@@ -163,7 +180,7 @@ class GraphicalFunctions {
         */
        public $dontCheckForExistingTempFile = 0;
 
-       // Prevents imageMagickConvert() from compressing the gif-files with t3lib_div::gif_compress()
+       // Prevents imageMagickConvert() from compressing the gif-files with \TYPO3\CMS\Core\Utility\GeneralUtility::gif_compress()
        /**
         * @todo Define visibility
         */
@@ -292,9 +309,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;
                }
@@ -307,17 +329,11 @@ class GraphicalFunctions {
                        $this->cmds['png'] = '';
                }
                // 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);
-               if ($gfxConf['im_combine_filename']) {
-                       $this->combineScript = $gfxConf['im_combine_filename'];
-               }
+               $this->jpegQuality = MathUtility::forceIntegerInRange($gfxConf['jpg_quality'], 10, 100, 75);
+               $this->cmds['jpg'] = ($this->cmds['jpeg'] = '-colorspace ' . $this->colorspace . ' -sharpen 50 -quality ' . $this->jpegQuality);
                if ($gfxConf['im_noFramePrepended']) {
                        $this->noFramePrepended = 1;
                }
-               // Kept for backwards compatibility, can be turned on manually through localconf.php,
-               // but not through the installer anymore
-               $this->imagecopyresized_fix = $gfxConf['gdlib_2'] === 'no_imagecopyresized_fix' ? 0 : 1;
                if ($gfxConf['gdlib_png']) {
                        $this->gifExtension = 'png';
                }
@@ -325,27 +341,19 @@ 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';
-               }
-               if ($gfxConf['im_no_effects']) {
-                       // Boolean. This is necessary if using ImageMagick 5+.
-                       // 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);
-               }
-               // ... but if 'im_v5effects' is set, don't care about 'im_no_effects'
+
+               // Boolean. This is necessary if using ImageMagick 5+.
+               // 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 ' . $this->colorspace . ' -quality ' . $this->jpegQuality);
+
+               // ... but if 'im_v5effects' is set, enable 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.
@@ -359,7 +367,7 @@ class GraphicalFunctions {
                        $this->csConvObj = $GLOBALS['LANG']->csConvObj;
                } else {
                        // The object may not exist yet, so we need to create it now. Happens in the Install Tool for example.
-                       $this->csConvObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Charset\\CharsetConverter');
+                       $this->csConvObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Charset\\CharsetConverter');
                }
                $this->nativeCharset = 'utf-8';
        }
@@ -378,22 +386,22 @@ class GraphicalFunctions {
         * @param array $conf TypoScript array with configuration for the GIFBUILDER object.
         * @param array $workArea The current working area coordinates.
         * @return void
-        * @see tslib_gifBuilder::make()
+        * @see \TYPO3\CMS\Frontend\Imaging\GifBuilder::make()
         * @todo Define visibility
         */
        public function maskImageOntoImage(&$im, $conf, $workArea) {
                if ($conf['file'] && $conf['mask']) {
                        $imgInf = pathinfo($conf['file']);
                        $imgExt = strtolower($imgInf['extension']);
-                       if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->gdlibExtensions, $imgExt)) {
-                               $BBimage = $this->imageMagickConvert($conf['file'], $this->gifExtension, '', '', '', '', '');
+                       if (!GeneralUtility::inList($this->gdlibExtensions, $imgExt)) {
+                               $BBimage = $this->imageMagickConvert($conf['file'], $this->gifExtension);
                        } else {
                                $BBimage = $this->getImageDimensions($conf['file']);
                        }
                        $maskInf = pathinfo($conf['mask']);
                        $maskExt = strtolower($maskInf['extension']);
-                       if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->gdlibExtensions, $maskExt)) {
-                               $BBmask = $this->imageMagickConvert($conf['mask'], $this->gifExtension, '', '', '', '', '');
+                       if (!GeneralUtility::inList($this->gdlibExtensions, $maskExt)) {
+                               $BBmask = $this->imageMagickConvert($conf['mask'], $this->gifExtension);
                        } else {
                                $BBmask = $this->getImageDimensions($conf['mask']);
                        }
@@ -465,13 +473,13 @@ class GraphicalFunctions {
         * @param array $conf TypoScript array with configuration for the GIFBUILDER object.
         * @param array $workArea The current working area coordinates.
         * @return void
-        * @see tslib_gifBuilder::make(), maskImageOntoImage()
+        * @see \TYPO3\CMS\Frontend\Imaging\GifBuilder::make(), maskImageOntoImage()
         * @todo Define visibility
         */
        public function copyImageOntoImage(&$im, $conf, $workArea) {
                if ($conf['file']) {
-                       if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->gdlibExtensions, $conf['BBOX'][2])) {
-                               $conf['BBOX'] = $this->imageMagickConvert($conf['BBOX'][3], $this->gifExtension, '', '', '', '', '');
+                       if (!GeneralUtility::inList($this->gdlibExtensions, $conf['BBOX'][2])) {
+                               $conf['BBOX'] = $this->imageMagickConvert($conf['BBOX'][3], $this->gifExtension);
                                $conf['file'] = $conf['BBOX'][3];
                        }
                        $cpImg = $this->imageCreateFromFile($conf['file']);
@@ -494,9 +502,9 @@ class GraphicalFunctions {
        public function copyGifOntoGif(&$im, $cpImg, $conf, $workArea) {
                $cpW = imagesx($cpImg);
                $cpH = imagesy($cpImg);
-               $tile = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $conf['tile']);
-               $tile[0] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($tile[0], 1, 20);
-               $tile[1] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($tile[1], 1, 20);
+               $tile = GeneralUtility::intExplode(',', $conf['tile']);
+               $tile[0] = MathUtility::forceIntegerInRange($tile[0], 1, 20);
+               $tile[1] = MathUtility::forceIntegerInRange($tile[1], 1, 20);
                $cpOff = $this->objPosition($conf, $workArea, array($cpW * $tile[0], $cpH * $tile[1]));
                for ($xt = 0; $xt < $tile[0]; $xt++) {
                        $Xstart = $cpOff[0] + $cpW * $xt;
@@ -569,11 +577,11 @@ class GraphicalFunctions {
         * @param integer $srcHeight Source height
         * @return void
         * @access private
-        * @see t3lib_iconWorks::imagecopyresized()
+        * @see \TYPO3\CMS\Backend\Utility\IconUtility::imagecopyresized()
         * @todo Define visibility
         */
        public function imagecopyresized(&$dstImg, $srcImg, $dstX, $dstY, $srcX, $srcY, $dstWidth, $dstHeight, $srcWidth, $srcHeight) {
-               if ($this->imagecopyresized_fix && !$this->saveAlphaLayer) {
+               if (!$this->saveAlphaLayer) {
                        // Make true color image
                        $tmpImg = imagecreatetruecolor(imagesx($dstImg), imagesy($dstImg));
                        // Copy the source image onto that
@@ -599,7 +607,7 @@ class GraphicalFunctions {
         * @param array $conf TypoScript array with configuration for the GIFBUILDER object.
         * @param array $workArea The current working area coordinates.
         * @return void
-        * @see tslib_gifBuilder::make()
+        * @see \TYPO3\CMS\Frontend\Imaging\GifBuilder::make()
         * @todo Define visibility
         */
        public function makeText(&$im, $conf, $workArea) {
@@ -637,7 +645,7 @@ class GraphicalFunctions {
                                $fileColor = $tmpStr . '_colorNT.' . $this->gifExtension;
                                $fileMask = $tmpStr . '_maskNT.' . $this->gifExtension;
                                // Scalefactor
-                               $sF = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($conf['niceText.']['scaleFactor'], 2, 5);
+                               $sF = MathUtility::forceIntegerInRange($conf['niceText.']['scaleFactor'], 2, 5);
                                $newW = ceil($sF * imagesx($im));
                                $newH = ceil($sF * imagesy($im));
                                // Make mask
@@ -655,23 +663,14 @@ 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']);
                                                } else {
-                                                       $command .= ' -sharpen ' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($conf['niceText.']['sharpen'], 1, 99);
+                                                       $command .= ' -sharpen ' . MathUtility::forceIntegerInRange($conf['niceText.']['sharpen'], 1, 99);
                                                }
                                        }
                                }
@@ -710,7 +709,7 @@ class GraphicalFunctions {
         *
         * @param array $conf TypoScript array for the TEXT GIFBUILDER object
         * @param array $workArea Workarea definition
-        * @param array $BB Bounding box information, was set in tslib_gifBuilder::start()
+        * @param array $BB Bounding box information, was set in \TYPO3\CMS\Frontend\Imaging\GifBuilder::start()
         * @return array [0]=x, [1]=y, [2]=w, [3]=h
         * @access private
         * @see makeText()
@@ -729,34 +728,33 @@ class GraphicalFunctions {
                $w = $workArea[2];
                $h = $workArea[3];
                switch ($conf['align']) {
-               case 'right':
-
-               case 'center':
-                       $factor = abs(cos($angle));
-                       $sign = cos($angle) < 0 ? -1 : 1;
-                       $len1 = $sign * $factor * $straightBB[0];
-                       $len2 = $sign * $BB[0];
-                       $result[0] = $w - ceil(($len2 * $factor + (1 - $factor) * $len1));
-                       $factor = abs(sin($angle));
-                       $sign = sin($angle) < 0 ? -1 : 1;
-                       $len1 = $sign * $factor * $straightBB[0];
-                       $len2 = $sign * $BB[1];
-                       $result[1] = ceil($len2 * $factor + (1 - $factor) * $len1);
-                       break;
+                       case 'right':
+
+                       case 'center':
+                               $factor = abs(cos($angle));
+                               $sign = cos($angle) < 0 ? -1 : 1;
+                               $len1 = $sign * $factor * $straightBB[0];
+                               $len2 = $sign * $BB[0];
+                               $result[0] = $w - ceil(($len2 * $factor + (1 - $factor) * $len1));
+                               $factor = abs(sin($angle));
+                               $sign = sin($angle) < 0 ? -1 : 1;
+                               $len1 = $sign * $factor * $straightBB[0];
+                               $len2 = $sign * $BB[1];
+                               $result[1] = ceil($len2 * $factor + (1 - $factor) * $len1);
+                               break;
                }
                switch ($conf['align']) {
-               case 'right':
-                       break;
-               case 'center':
-                       $result[0] = round($result[0] / 2);
-                       $result[1] = round($result[1] / 2);
-                       break;
-               default:
-                       $result[0] = 0;
-                       $result[1] = 0;
-                       break;
-               }
-               $result = $this->applyOffset($result, \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $conf['offset']));
+                       case 'right':
+                               break;
+                       case 'center':
+                               $result[0] = round($result[0] / 2);
+                               $result[1] = round($result[1] / 2);
+                               break;
+                       default:
+                               $result[0] = 0;
+                               $result[1] = 0;
+               }
+               $result = $this->applyOffset($result, GeneralUtility::intExplode(',', $conf['offset']));
                $result = $this->applyOffset($result, $workArea);
                return $result;
        }
@@ -767,7 +765,7 @@ class GraphicalFunctions {
         * @param array $conf TypoScript array for the TEXT GIFBUILDER object
         * @return array Array with three keys [0]/[1] being x/y and [2] being the bounding box array
         * @access private
-        * @see txtPosition(), tslib_gifBuilder::start()
+        * @see txtPosition(), \TYPO3\CMS\Frontend\Imaging\GifBuilder::start()
         * @todo Define visibility
         */
        public function calcBBox($conf) {
@@ -866,7 +864,7 @@ class GraphicalFunctions {
         * @todo Define visibility
         */
        public function calcTextCordsForMap($cords, $offset, $conf) {
-               $pars = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $conf['explode'] . ',');
+               $pars = GeneralUtility::intExplode(',', $conf['explode'] . ',');
                $newCords[0] = $cords[0] + $offset[0] - $pars[0];
                $newCords[1] = $cords[1] + $offset[1] + $pars[1];
                $newCords[2] = $cords[2] + $offset[0] + $pars[0];
@@ -929,7 +927,7 @@ class GraphicalFunctions {
         * @param array $conf The TypoScript properties of the TEXT GIFBUILDER object
         * @return integer The new fontSize
         * @access private
-        * @see tslib_gifBuilder::start()
+        * @see \TYPO3\CMS\Frontend\Imaging\GifBuilder::start()
         * @todo Define visibility
         */
        public function fontResize($conf) {
@@ -992,7 +990,7 @@ class GraphicalFunctions {
                                 */
                                $try = 0;
                                do {
-                                       $calc = ImageTTFBBox(\TYPO3\CMS\Core\Utility\GeneralUtility::freetypeDpiComp($sF * $strCfg['fontSize']), $angle, $fontFile, $strCfg['str']);
+                                       $calc = ImageTTFBBox(GeneralUtility::freetypeDpiComp($sF * $strCfg['fontSize']), $angle, $fontFile, $strCfg['str']);
                                } while ($calc[2] < 0 && $try++ < 10);
                                // Calculate offsets:
                                if (!count($offsetInfo)) {
@@ -1050,9 +1048,9 @@ class GraphicalFunctions {
                        $fontFile = self::prependAbsolutePath($strCfg['fontFile']);
                        if (is_readable($fontFile)) {
                                // Render part:
-                               ImageTTFText($im, \TYPO3\CMS\Core\Utility\GeneralUtility::freetypeDpiComp($sF * $strCfg['fontSize']), $angle, $x, $y, $colorIndex, $fontFile, $strCfg['str']);
+                               ImageTTFText($im, GeneralUtility::freetypeDpiComp($sF * $strCfg['fontSize']), $angle, $x, $y, $colorIndex, $fontFile, $strCfg['str']);
                                // Calculate offset to apply:
-                               $wordInf = ImageTTFBBox(\TYPO3\CMS\Core\Utility\GeneralUtility::freetypeDpiComp($sF * $strCfg['fontSize']), $angle, self::prependAbsolutePath($strCfg['fontFile']), $strCfg['str']);
+                               $wordInf = ImageTTFBBox(GeneralUtility::freetypeDpiComp($sF * $strCfg['fontSize']), $angle, self::prependAbsolutePath($strCfg['fontFile']), $strCfg['str']);
                                $x += $wordInf[2] - $wordInf[0] + intval($splitRendering['compX']) + intval($strCfg['xSpaceAfter']);
                                $y += $wordInf[5] - $wordInf[7] - intval($splitRendering['compY']) - intval($strCfg['ySpaceAfter']);
                        } else {
@@ -1088,111 +1086,111 @@ class GraphicalFunctions {
                                $cfg = $splitRendering[$key . '.'];
                                // Process each type of split rendering keyword:
                                switch ((string) $splitRendering[$key]) {
-                               case 'highlightWord':
-                                       if (strlen($cfg['value'])) {
-                                               $newResult = array();
-                                               // Traverse the current parts of the result array:
-                                               foreach ($result as $part) {
-                                                       // Explode the string value by the word value to highlight:
-                                                       $explodedParts = explode($cfg['value'], $part['str']);
-                                                       foreach ($explodedParts as $c => $expValue) {
-                                                               if (strlen($expValue)) {
-                                                                       $newResult[] = array_merge($part, array('str' => $expValue));
-                                                               }
-                                                               if ($c + 1 < count($explodedParts)) {
-                                                                       $newResult[] = array(
-                                                                               'str' => $cfg['value'],
-                                                                               'fontSize' => $cfg['fontSize'] ? $cfg['fontSize'] : $part['fontSize'],
-                                                                               'fontFile' => $cfg['fontFile'] ? $cfg['fontFile'] : $part['fontFile'],
-                                                                               'color' => $cfg['color'],
-                                                                               'xSpaceBefore' => $cfg['xSpaceBefore'],
-                                                                               'xSpaceAfter' => $cfg['xSpaceAfter'],
-                                                                               'ySpaceBefore' => $cfg['ySpaceBefore'],
-                                                                               'ySpaceAfter' => $cfg['ySpaceAfter']
-                                                                       );
+                                       case 'highlightWord':
+                                               if (strlen($cfg['value'])) {
+                                                       $newResult = array();
+                                                       // Traverse the current parts of the result array:
+                                                       foreach ($result as $part) {
+                                                               // Explode the string value by the word value to highlight:
+                                                               $explodedParts = explode($cfg['value'], $part['str']);
+                                                               foreach ($explodedParts as $c => $expValue) {
+                                                                       if (strlen($expValue)) {
+                                                                               $newResult[] = array_merge($part, array('str' => $expValue));
+                                                                       }
+                                                                       if ($c + 1 < count($explodedParts)) {
+                                                                               $newResult[] = array(
+                                                                                       'str' => $cfg['value'],
+                                                                                       'fontSize' => $cfg['fontSize'] ? $cfg['fontSize'] : $part['fontSize'],
+                                                                                       'fontFile' => $cfg['fontFile'] ? $cfg['fontFile'] : $part['fontFile'],
+                                                                                       'color' => $cfg['color'],
+                                                                                       'xSpaceBefore' => $cfg['xSpaceBefore'],
+                                                                                       'xSpaceAfter' => $cfg['xSpaceAfter'],
+                                                                                       'ySpaceBefore' => $cfg['ySpaceBefore'],
+                                                                                       'ySpaceAfter' => $cfg['ySpaceAfter']
+                                                                               );
+                                                                       }
                                                                }
                                                        }
-                                               }
-                                               // Set the new result as result array:
-                                               if (count($newResult)) {
-                                                       $result = $newResult;
-                                               }
-                                       }
-                                       break;
-                               case 'charRange':
-                                       if (strlen($cfg['value'])) {
-                                               // Initialize range:
-                                               $ranges = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $cfg['value'], 1);
-                                               foreach ($ranges as $i => $rangeDef) {
-                                                       $ranges[$i] = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode('-', $ranges[$i]);
-                                                       if (!isset($ranges[$i][1])) {
-                                                               $ranges[$i][1] = $ranges[$i][0];
+                                                       // Set the new result as result array:
+                                                       if (count($newResult)) {
+                                                               $result = $newResult;
                                                        }
                                                }
-                                               $newResult = array();
-                                               // Traverse the current parts of the result array:
-                                               foreach ($result as $part) {
-                                                       // Initialize:
-                                                       $currentState = -1;
-                                                       $bankAccum = '';
-                                                       // Explode the string value by the word value to highlight:
-                                                       $utf8Chars = $this->singleChars($part['str']);
-                                                       foreach ($utf8Chars as $utfChar) {
-                                                               // Find number and evaluate position:
-                                                               $uNumber = $this->csConvObj->utf8CharToUnumber($utfChar);
-                                                               $inRange = 0;
-                                                               foreach ($ranges as $rangeDef) {
-                                                                       if ($uNumber >= $rangeDef[0] && (!$rangeDef[1] || $uNumber <= $rangeDef[1])) {
-                                                                               $inRange = 1;
-                                                                               break;
-                                                                       }
-                                                               }
-                                                               if ($currentState == -1) {
-                                                                       $currentState = $inRange;
+                                               break;
+                                       case 'charRange':
+                                               if (strlen($cfg['value'])) {
+                                                       // Initialize range:
+                                                       $ranges = GeneralUtility::trimExplode(',', $cfg['value'], TRUE);
+                                                       foreach ($ranges as $i => $rangeDef) {
+                                                               $ranges[$i] = GeneralUtility::intExplode('-', $ranges[$i]);
+                                                               if (!isset($ranges[$i][1])) {
+                                                                       $ranges[$i][1] = $ranges[$i][0];
                                                                }
-                                                               // Initialize first char
-                                                               // Switch bank:
-                                                               if ($inRange != $currentState && !\TYPO3\CMS\Core\Utility\GeneralUtility::inList('32,10,13,9', $uNumber)) {
-                                                                       // Set result:
-                                                                       if (strlen($bankAccum)) {
-                                                                               $newResult[] = array(
-                                                                                       'str' => $bankAccum,
-                                                                                       'fontSize' => $currentState && $cfg['fontSize'] ? $cfg['fontSize'] : $part['fontSize'],
-                                                                                       'fontFile' => $currentState && $cfg['fontFile'] ? $cfg['fontFile'] : $part['fontFile'],
-                                                                                       'color' => $currentState ? $cfg['color'] : '',
-                                                                                       'xSpaceBefore' => $currentState ? $cfg['xSpaceBefore'] : '',
-                                                                                       'xSpaceAfter' => $currentState ? $cfg['xSpaceAfter'] : '',
-                                                                                       'ySpaceBefore' => $currentState ? $cfg['ySpaceBefore'] : '',
-                                                                                       'ySpaceAfter' => $currentState ? $cfg['ySpaceAfter'] : ''
-                                                                               );
+                                                       }
+                                                       $newResult = array();
+                                                       // Traverse the current parts of the result array:
+                                                       foreach ($result as $part) {
+                                                               // Initialize:
+                                                               $currentState = -1;
+                                                               $bankAccum = '';
+                                                               // Explode the string value by the word value to highlight:
+                                                               $utf8Chars = $this->singleChars($part['str']);
+                                                               foreach ($utf8Chars as $utfChar) {
+                                                                       // Find number and evaluate position:
+                                                                       $uNumber = $this->csConvObj->utf8CharToUnumber($utfChar);
+                                                                       $inRange = 0;
+                                                                       foreach ($ranges as $rangeDef) {
+                                                                               if ($uNumber >= $rangeDef[0] && (!$rangeDef[1] || $uNumber <= $rangeDef[1])) {
+                                                                                       $inRange = 1;
+                                                                                       break;
+                                                                               }
+                                                                       }
+                                                                       if ($currentState == -1) {
+                                                                               $currentState = $inRange;
                                                                        }
-                                                                       // Initialize new settings:
-                                                                       $currentState = $inRange;
-                                                                       $bankAccum = '';
+                                                                       // Initialize first char
+                                                                       // Switch bank:
+                                                                       if ($inRange != $currentState && !GeneralUtility::inList('32,10,13,9', $uNumber)) {
+                                                                               // Set result:
+                                                                               if (strlen($bankAccum)) {
+                                                                                       $newResult[] = array(
+                                                                                               'str' => $bankAccum,
+                                                                                               'fontSize' => $currentState && $cfg['fontSize'] ? $cfg['fontSize'] : $part['fontSize'],
+                                                                                               'fontFile' => $currentState && $cfg['fontFile'] ? $cfg['fontFile'] : $part['fontFile'],
+                                                                                               'color' => $currentState ? $cfg['color'] : '',
+                                                                                               'xSpaceBefore' => $currentState ? $cfg['xSpaceBefore'] : '',
+                                                                                               'xSpaceAfter' => $currentState ? $cfg['xSpaceAfter'] : '',
+                                                                                               'ySpaceBefore' => $currentState ? $cfg['ySpaceBefore'] : '',
+                                                                                               'ySpaceAfter' => $currentState ? $cfg['ySpaceAfter'] : ''
+                                                                                       );
+                                                                               }
+                                                                               // Initialize new settings:
+                                                                               $currentState = $inRange;
+                                                                               $bankAccum = '';
+                                                                       }
+                                                                       // Add char to bank:
+                                                                       $bankAccum .= $utfChar;
+                                                               }
+                                                               // Set result for FINAL part:
+                                                               if (strlen($bankAccum)) {
+                                                                       $newResult[] = array(
+                                                                               'str' => $bankAccum,
+                                                                               'fontSize' => $currentState && $cfg['fontSize'] ? $cfg['fontSize'] : $part['fontSize'],
+                                                                               'fontFile' => $currentState && $cfg['fontFile'] ? $cfg['fontFile'] : $part['fontFile'],
+                                                                               'color' => $currentState ? $cfg['color'] : '',
+                                                                               'xSpaceBefore' => $currentState ? $cfg['xSpaceBefore'] : '',
+                                                                               'xSpaceAfter' => $currentState ? $cfg['xSpaceAfter'] : '',
+                                                                               'ySpaceBefore' => $currentState ? $cfg['ySpaceBefore'] : '',
+                                                                               'ySpaceAfter' => $currentState ? $cfg['ySpaceAfter'] : ''
+                                                                       );
                                                                }
-                                                               // Add char to bank:
-                                                               $bankAccum .= $utfChar;
                                                        }
-                                                       // Set result for FINAL part:
-                                                       if (strlen($bankAccum)) {
-                                                               $newResult[] = array(
-                                                                       'str' => $bankAccum,
-                                                                       'fontSize' => $currentState && $cfg['fontSize'] ? $cfg['fontSize'] : $part['fontSize'],
-                                                                       'fontFile' => $currentState && $cfg['fontFile'] ? $cfg['fontFile'] : $part['fontFile'],
-                                                                       'color' => $currentState ? $cfg['color'] : '',
-                                                                       'xSpaceBefore' => $currentState ? $cfg['xSpaceBefore'] : '',
-                                                                       'xSpaceAfter' => $currentState ? $cfg['xSpaceAfter'] : '',
-                                                                       'ySpaceBefore' => $currentState ? $cfg['ySpaceBefore'] : '',
-                                                                       'ySpaceAfter' => $currentState ? $cfg['ySpaceAfter'] : ''
-                                                               );
+                                                       // Set the new result as result array:
+                                                       if (count($newResult)) {
+                                                               $result = $newResult;
                                                        }
                                                }
-                                               // Set the new result as result array:
-                                               if (count($newResult)) {
-                                                       $result = $newResult;
-                                               }
-                                       }
-                                       break;
+                                               break;
                                }
                        }
                }
@@ -1231,7 +1229,7 @@ class GraphicalFunctions {
                        $sF = 1;
                } else {
                        // NICETEXT::
-                       $sF = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($conf['niceText.']['scaleFactor'], 2, 5);
+                       $sF = MathUtility::forceIntegerInRange($conf['niceText.']['scaleFactor'], 2, 5);
                }
                return $sF;
        }
@@ -1352,14 +1350,14 @@ class GraphicalFunctions {
         * @param array $workArea The current working area coordinates.
         * @param array $txtConf TypoScript array with configuration for the associated TEXT GIFBUILDER object.
         * @return void
-        * @see tslib_gifBuilder::make(), makeText()
+        * @see \TYPO3\CMS\Frontend\Imaging\GifBuilder::make(), makeText()
         * @todo Define visibility
         */
        public function makeOutline(&$im, $conf, $workArea, $txtConf) {
                $thickness = intval($conf['thickness']);
                if ($thickness) {
                        $txtConf['fontColor'] = $conf['color'];
-                       $outLineDist = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($thickness, 1, 2);
+                       $outLineDist = MathUtility::forceIntegerInRange($thickness, 1, 2);
                        for ($b = 1; $b <= $outLineDist; $b++) {
                                if ($b == 1) {
                                        $it = 8;
@@ -1411,13 +1409,13 @@ class GraphicalFunctions {
         * @param array $workArea The current working area coordinates.
         * @param array $txtConf TypoScript array with configuration for the associated TEXT GIFBUILDER object.
         * @return void
-        * @see tslib_gifBuilder::make(), makeShadow()
+        * @see \TYPO3\CMS\Frontend\Imaging\GifBuilder::make(), makeShadow()
         * @todo Define visibility
         */
        public function makeEmboss(&$im, $conf, $workArea, $txtConf) {
                $conf['color'] = $conf['highColor'];
                $this->makeShadow($im, $conf, $workArea, $txtConf);
-               $newOffset = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $conf['offset']);
+               $newOffset = GeneralUtility::intExplode(',', $conf['offset']);
                $newOffset[0] *= -1;
                $newOffset[1] *= -1;
                $conf['offset'] = implode(',', $newOffset);
@@ -1434,12 +1432,12 @@ class GraphicalFunctions {
         * @param array $workArea The current working area coordinates.
         * @param array $txtConf TypoScript array with configuration for the associated TEXT GIFBUILDER object.
         * @retur void
-        * @see tslib_gifBuilder::make(), makeText(), makeEmboss()
+        * @see \TYPO3\CMS\Frontend\Imaging\GifBuilder::make(), makeText(), makeEmboss()
         * @todo Define visibility
         */
        public function makeShadow(&$im, $conf, $workArea, $txtConf) {
-               $workArea = $this->applyOffset($workArea, \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $conf['offset']));
-               $blurRate = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(intval($conf['blur']), 0, 99);
+               $workArea = $this->applyOffset($workArea, GeneralUtility::intExplode(',', $conf['offset']));
+               $blurRate = MathUtility::forceIntegerInRange(intval($conf['blur']), 0, 99);
                // No effects if ImageMagick ver. 5+
                if (!$blurRate || $this->NO_IM_EFFECTS) {
                        $txtConf['fontColor'] = $conf['color'];
@@ -1473,7 +1471,6 @@ class GraphicalFunctions {
                        // Destroy
                        ImageDestroy($blurTextImg);
                        $command = '';
-                       $command .= $this->maskNegate;
                        if ($this->V5_EFFECTS) {
                                $command .= $this->v5_blur($blurRate + 1);
                        } else {
@@ -1482,7 +1479,7 @@ class GraphicalFunctions {
                                $times = ceil($blurRate / 10);
                                // Here I boost the blur-rate so that it is 100 already at 25. The rest is done by up to 99 iterations of the blur-command.
                                $newBlurRate = $blurRate * 4;
-                               $newBlurRate = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($newBlurRate, 1, 99);
+                               $newBlurRate = MathUtility::forceIntegerInRange($newBlurRate, 1, 99);
                                // Building blur-command
                                for ($a = 0; $a < $times; $a++) {
                                        $command .= ' -blur ' . $blurRate;
@@ -1501,15 +1498,15 @@ class GraphicalFunctions {
                                // Adjust the mask
                                $intensity = 40;
                                if ($conf['intensity']) {
-                                       $intensity = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($conf['intensity'], 0, 100);
+                                       $intensity = MathUtility::forceIntegerInRange($conf['intensity'], 0, 100);
                                }
                                $intensity = ceil(255 - $intensity / 100 * 255);
-                               $this->inputLevels($blurTextImg, 0, $intensity, $this->maskNegate);
-                               $opacity = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(intval($conf['opacity']), 0, 100);
+                               $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);
@@ -1550,11 +1547,11 @@ class GraphicalFunctions {
         * @param array $conf TypoScript array with configuration for the GIFBUILDER object.
         * @param array $workArea The current working area coordinates.
         * @return void
-        * @see tslib_gifBuilder::make()
+        * @see \TYPO3\CMS\Frontend\Imaging\GifBuilder::make()
         * @todo Define visibility
         */
        public function makeBox(&$im, $conf, $workArea) {
-               $cords = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $conf['dimensions'] . ',,,');
+               $cords = GeneralUtility::intExplode(',', $conf['dimensions'] . ',,,');
                $conf['offset'] = $cords[0] . ',' . $cords[1];
                $cords = $this->objPosition($conf, $workArea, array($cords[2], $cords[3]));
                $cols = $this->convertColor($conf['color']);
@@ -1563,7 +1560,7 @@ class GraphicalFunctions {
                        // conversion:
                        // PHP 0 = opaque, 127 = transparent
                        // TYPO3 100 = opaque, 0 = transparent
-                       $opacity = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(intval($conf['opacity']), 1, 100, 1);
+                       $opacity = MathUtility::forceIntegerInRange(intval($conf['opacity']), 1, 100, 1);
                        $opacity = abs($opacity - 100);
                        $opacity = round(127 * $opacity / 100);
                }
@@ -1590,10 +1587,10 @@ class GraphicalFunctions {
         * @param array $conf TypoScript array with configuration for the GIFBUILDER object.
         * @param array $workArea The current working area coordinates.
         * @return void
-        * @see tslib_gifBuilder::make()
+        * @see \TYPO3\CMS\Frontend\Imaging\GifBuilder::make()
         */
        public function makeEllipse(&$im, array $conf, array $workArea) {
-               $ellipseConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $conf['dimensions'] . ',,,');
+               $ellipseConfiguration = GeneralUtility::intExplode(',', $conf['dimensions'] . ',,,');
                // Ellipse offset inside workArea (x/y)
                $conf['offset'] = $ellipseConfiguration[0] . ',' . $ellipseConfiguration[1];
                // @see objPosition
@@ -1610,7 +1607,7 @@ class GraphicalFunctions {
         * @param pointer $im GDlib image pointer
         * @param array $conf TypoScript array with configuration for the GIFBUILDER object.
         * @return void
-        * @see tslib_gifBuilder::make(), applyImageMagickToPHPGif()
+        * @see \TYPO3\CMS\Frontend\Imaging\GifBuilder::make(), applyImageMagickToPHPGif()
         * @todo Define visibility
         */
        public function makeEffect(&$im, $conf) {
@@ -1640,67 +1637,67 @@ class GraphicalFunctions {
                        $value = trim($pairs[1]);
                        $effect = strtolower(trim($pairs[0]));
                        switch ($effect) {
-                       case 'gamma':
-                               $commands .= ' -gamma ' . doubleval($value);
-                               break;
-                       case 'blur':
-                               if (!$this->NO_IM_EFFECTS) {
-                                       if ($this->V5_EFFECTS) {
-                                               $commands .= $this->v5_blur($value);
-                                       } else {
-                                               $commands .= ' -blur ' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($value, 1, 99);
+                               case 'gamma':
+                                       $commands .= ' -gamma ' . doubleval($value);
+                                       break;
+                               case 'blur':
+                                       if (!$this->NO_IM_EFFECTS) {
+                                               if ($this->V5_EFFECTS) {
+                                                       $commands .= $this->v5_blur($value);
+                                               } else {
+                                                       $commands .= ' -blur ' . MathUtility::forceIntegerInRange($value, 1, 99);
+                                               }
                                        }
-                               }
-                               break;
-                       case 'sharpen':
-                               if (!$this->NO_IM_EFFECTS) {
-                                       if ($this->V5_EFFECTS) {
-                                               $commands .= $this->v5_sharpen($value);
-                                       } else {
-                                               $commands .= ' -sharpen ' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($value, 1, 99);
+                                       break;
+                               case 'sharpen':
+                                       if (!$this->NO_IM_EFFECTS) {
+                                               if ($this->V5_EFFECTS) {
+                                                       $commands .= $this->v5_sharpen($value);
+                                               } else {
+                                                       $commands .= ' -sharpen ' . MathUtility::forceIntegerInRange($value, 1, 99);
+                                               }
                                        }
-                               }
-                               break;
-                       case 'rotate':
-                               $commands .= ' -rotate ' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($value, 0, 360);
-                               break;
-                       case 'solarize':
-                               $commands .= ' -solarize ' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($value, 0, 99);
-                               break;
-                       case 'swirl':
-                               $commands .= ' -swirl ' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($value, 0, 1000);
-                               break;
-                       case 'wave':
-                               $params = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $value);
-                               $commands .= ' -wave ' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($params[0], 0, 99) . 'x' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($params[1], 0, 99);
-                               break;
-                       case 'charcoal':
-                               $commands .= ' -charcoal ' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($value, 0, 100);
-                               break;
-                       case 'gray':
-                               $commands .= ' -colorspace GRAY';
-                               break;
-                       case 'edge':
-                               $commands .= ' -edge ' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($value, 0, 99);
-                               break;
-                       case 'emboss':
-                               $commands .= ' -emboss';
-                               break;
-                       case 'flip':
-                               $commands .= ' -flip';
-                               break;
-                       case 'flop':
-                               $commands .= ' -flop';
-                               break;
-                       case 'colors':
-                               $commands .= ' -colors ' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($value, 2, 255);
-                               break;
-                       case 'shear':
-                               $commands .= ' -shear ' . \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($value, -90, 90);
-                               break;
-                       case 'invert':
-                               $commands .= ' -negate';
-                               break;
+                                       break;
+                               case 'rotate':
+                                       $commands .= ' -rotate ' . MathUtility::forceIntegerInRange($value, 0, 360);
+                                       break;
+                               case 'solarize':
+                                       $commands .= ' -solarize ' . MathUtility::forceIntegerInRange($value, 0, 99);
+                                       break;
+                               case 'swirl':
+                                       $commands .= ' -swirl ' . MathUtility::forceIntegerInRange($value, 0, 1000);
+                                       break;
+                               case 'wave':
+                                       $params = GeneralUtility::intExplode(',', $value);
+                                       $commands .= ' -wave ' . MathUtility::forceIntegerInRange($params[0], 0, 99) . 'x' . MathUtility::forceIntegerInRange($params[1], 0, 99);
+                                       break;
+                               case 'charcoal':
+                                       $commands .= ' -charcoal ' . MathUtility::forceIntegerInRange($value, 0, 100);
+                                       break;
+                               case 'gray':
+                                       $commands .= ' -colorspace GRAY';
+                                       break;
+                               case 'edge':
+                                       $commands .= ' -edge ' . MathUtility::forceIntegerInRange($value, 0, 99);
+                                       break;
+                               case 'emboss':
+                                       $commands .= ' -emboss';
+                                       break;
+                               case 'flip':
+                                       $commands .= ' -flip';
+                                       break;
+                               case 'flop':
+                                       $commands .= ' -flop';
+                                       break;
+                               case 'colors':
+                                       $commands .= ' -colors ' . MathUtility::forceIntegerInRange($value, 2, 255);
+                                       break;
+                               case 'shear':
+                                       $commands .= ' -shear ' . MathUtility::forceIntegerInRange($value, -90, 90);
+                                       break;
+                               case 'invert':
+                                       $commands .= ' -negate';
+                                       break;
                        }
                }
                return $commands;
@@ -1712,7 +1709,7 @@ class GraphicalFunctions {
         * @param pointer $im GDlib image pointer
         * @param array $conf TypoScript array with configuration for the GIFBUILDER object.
         * @return void
-        * @see tslib_gifBuilder::make(), autoLevels(), outputLevels(), inputLevels()
+        * @see \TYPO3\CMS\Frontend\Imaging\GifBuilder::make(), autoLevels(), outputLevels(), inputLevels()
         * @todo Define visibility
         */
        public function adjust(&$im, $conf) {
@@ -1726,18 +1723,18 @@ class GraphicalFunctions {
                        $value = trim($pairs[1]);
                        $effect = strtolower(trim($pairs[0]));
                        switch ($effect) {
-                       case 'inputlevels':
-                               // low,high
-                               $params = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $value);
-                               $this->inputLevels($im, $params[0], $params[1]);
-                               break;
-                       case 'outputlevels':
-                               $params = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $value);
-                               $this->outputLevels($im, $params[0], $params[1]);
-                               break;
-                       case 'autolevels':
-                               $this->autoLevels($im);
-                               break;
+                               case 'inputlevels':
+                                       // low,high
+                                       $params = GeneralUtility::intExplode(',', $value);
+                                       $this->inputLevels($im, $params[0], $params[1]);
+                                       break;
+                               case 'outputlevels':
+                                       $params = GeneralUtility::intExplode(',', $value);
+                                       $this->outputLevels($im, $params[0], $params[1]);
+                                       break;
+                               case 'autolevels':
+                                       $this->autoLevels($im);
+                                       break;
                        }
                }
        }
@@ -1748,13 +1745,13 @@ class GraphicalFunctions {
         * @param pointer $im GDlib image pointer
         * @param array $conf TypoScript array with configuration for the GIFBUILDER object.
         * @return void
-        * @see tslib_gifBuilder::make()
+        * @see \TYPO3\CMS\Frontend\Imaging\GifBuilder::make()
         * @todo Define visibility
         */
        public function crop(&$im, $conf) {
                // Clears workArea to total image
                $this->setWorkArea('');
-               $cords = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $conf['crop'] . ',,,');
+               $cords = GeneralUtility::intExplode(',', $conf['crop'] . ',,,');
                $conf['offset'] = $cords[0] . ',' . $cords[1];
                $cords = $this->objPosition($conf, $this->workArea, array($cords[2], $cords[3]));
                $newIm = imagecreatetruecolor($cords[2], $cords[3]);
@@ -1787,7 +1784,7 @@ class GraphicalFunctions {
         * @param pointer $im GDlib image pointer
         * @param array $conf TypoScript array with configuration for the GIFBUILDER object.
         * @return void
-        * @see tslib_gifBuilder::make()
+        * @see \TYPO3\CMS\Frontend\Imaging\GifBuilder::make()
         * @todo Define visibility
         */
        public function scale(&$im, $conf) {
@@ -1795,7 +1792,7 @@ class GraphicalFunctions {
                        $tmpStr = $this->randomName();
                        $theFile = $tmpStr . '.' . $this->gifExtension;
                        $this->ImageWrite($im, $theFile);
-                       $theNewFile = $this->imageMagickConvert($theFile, $this->gifExtension, $conf['width'], $conf['height'], $conf['params'], '', '');
+                       $theNewFile = $this->imageMagickConvert($theFile, $this->gifExtension, $conf['width'], $conf['height'], $conf['params']);
                        $tmpImg = $this->imageCreateFromFile($theNewFile[3]);
                        if ($tmpImg) {
                                ImageDestroy($im);
@@ -1821,11 +1818,11 @@ class GraphicalFunctions {
         * @param string $workArea Working area dimensions, comma separated
         * @return void
         * @access private
-        * @see tslib_gifBuilder::make()
+        * @see \TYPO3\CMS\Frontend\Imaging\GifBuilder::make()
         * @todo Define visibility
         */
        public function setWorkArea($workArea) {
-               $this->workArea = \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $workArea);
+               $this->workArea = GeneralUtility::intExplode(',', $workArea);
                $this->workArea = $this->applyOffset($this->workArea, $this->OFFSET);
                if (!$this->workArea[2]) {
                        $this->workArea[2] = $this->w;
@@ -1881,8 +1878,8 @@ class GraphicalFunctions {
         */
        public function outputLevels(&$im, $low, $high, $swap = '') {
                if ($low < $high) {
-                       $low = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($low, 0, 255);
-                       $high = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($high, 0, 255);
+                       $low = MathUtility::forceIntegerInRange($low, 0, 255);
+                       $high = MathUtility::forceIntegerInRange($high, 0, 255);
                        if ($swap) {
                                $temp = $low;
                                $low = 255 - $high;
@@ -1906,26 +1903,21 @@ 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
         */
        public function inputLevels(&$im, $low, $high, $swap = '') {
                if ($low < $high) {
-                       $low = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($low, 0, 255);
-                       $high = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($high, 0, 255);
-                       if ($swap) {
-                               $temp = $low;
-                               $low = 255 - $high;
-                               $high = 255 - $temp;
-                       }
+                       $low = MathUtility::forceIntegerInRange($low, 0, 255);
+                       $high = MathUtility::forceIntegerInRange($high, 0, 255);
                        $delta = $high - $low;
                        $totalCols = ImageColorsTotal($im);
                        for ($c = 0; $c < $totalCols; $c++) {
                                $cols = ImageColorsForIndex($im, $c);
-                               $cols['red'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(($cols['red'] - $low) / $delta * 255, 0, 255);
-                               $cols['green'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(($cols['green'] - $low) / $delta * 255, 0, 255);
-                               $cols['blue'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(($cols['blue'] - $low) / $delta * 255, 0, 255);
+                               $cols['red'] = MathUtility::forceIntegerInRange(($cols['red'] - $low) / $delta * 255, 0, 255);
+                               $cols['green'] = MathUtility::forceIntegerInRange(($cols['green'] - $low) / $delta * 255, 0, 255);
+                               $cols['blue'] = MathUtility::forceIntegerInRange(($cols['blue'] - $low) / $delta * 255, 0, 255);
                                ImageColorSet($im, $c, $cols['red'], $cols['green'], $cols['blue']);
                        }
                }
@@ -1940,10 +1932,10 @@ class GraphicalFunctions {
         * @todo Define visibility
         */
        public function IMreduceColors($file, $cols) {
-               $fI = \TYPO3\CMS\Core\Utility\GeneralUtility::split_fileref($file);
+               $fI = GeneralUtility::split_fileref($file);
                $ext = strtolower($fI['fileext']);
                $result = $this->randomName() . '.' . $ext;
-               if (($reduce = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($cols, 0, $ext == 'gif' ? 256 : $this->truecolorColors, 0)) > 0) {
+               if (($reduce = MathUtility::forceIntegerInRange($cols, 0, $ext == 'gif' ? 256 : $this->truecolorColors, 0)) > 0) {
                        $params = ' -colors ' . $reduce;
                        if ($reduce <= 256) {
                                $params .= ' -type Palette';
@@ -1967,7 +1959,7 @@ class GraphicalFunctions {
        /**
         * Checks if the $fontFile is already at an absolute path and if not, prepends the correct path.
         * Use PATH_site unless we are in the backend.
-        * Call it by t3lib_stdGraphic::prependAbsolutePath()
+        * Call it by \TYPO3\CMS\Core\Imaging\GraphicalFunctions::prependAbsolutePath()
         *
         * @param string $fontFile The font file
         * @return string The font file with absolute path.
@@ -1975,7 +1967,7 @@ class GraphicalFunctions {
         */
        public function prependAbsolutePath($fontFile) {
                $absPath = defined('PATH_typo3') ? dirname(PATH_thisScript) . '/' : PATH_site;
-               $fontFile = \TYPO3\CMS\Core\Utility\GeneralUtility::isAbsPath($fontFile) ? $fontFile : \TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath($absPath . $fontFile);
+               $fontFile = GeneralUtility::isAbsPath($fontFile) ? $fontFile : GeneralUtility::resolveBackPath($absPath . $fontFile);
                return $fontFile;
        }
 
@@ -1989,7 +1981,7 @@ class GraphicalFunctions {
         * @todo Define visibility
         */
        public function v5_sharpen($factor) {
-               $factor = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(ceil($factor / 10), 0, 10);
+               $factor = MathUtility::forceIntegerInRange(ceil($factor / 10), 0, 10);
                $sharpenArr = explode(',', ',' . $this->im5fx_sharpenSteps);
                $sharpenF = trim($sharpenArr[$factor]);
                if ($sharpenF) {
@@ -2008,7 +2000,7 @@ class GraphicalFunctions {
         * @todo Define visibility
         */
        public function v5_blur($factor) {
-               $factor = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange(ceil($factor / 10), 0, 10);
+               $factor = MathUtility::forceIntegerInRange(ceil($factor / 10), 0, 10);
                $blurArr = explode(',', ',' . $this->im5fx_blurSteps);
                $blurF = trim($blurArr[$factor]);
                if ($blurF) {
@@ -2081,14 +2073,14 @@ class GraphicalFunctions {
                        $cParts[1] = trim($cParts[1]);
                        if (substr($cParts[1], 0, 1) == '*') {
                                $val = doubleval(substr($cParts[1], 1));
-                               $col[0] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($col[0] * $val, 0, 255);
-                               $col[1] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($col[1] * $val, 0, 255);
-                               $col[2] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($col[2] * $val, 0, 255);
+                               $col[0] = MathUtility::forceIntegerInRange($col[0] * $val, 0, 255);
+                               $col[1] = MathUtility::forceIntegerInRange($col[1] * $val, 0, 255);
+                               $col[2] = MathUtility::forceIntegerInRange($col[2] * $val, 0, 255);
                        } else {
                                $val = intval($cParts[1]);
-                               $col[0] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($col[0] + $val, 0, 255);
-                               $col[1] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($col[1] + $val, 0, 255);
-                               $col[2] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($col[2] + $val, 0, 255);
+                               $col[0] = MathUtility::forceIntegerInRange($col[0] + $val, 0, 255);
+                               $col[1] = MathUtility::forceIntegerInRange($col[1] + $val, 0, 255);
+                               $col[2] = MathUtility::forceIntegerInRange($col[2] + $val, 0, 255);
                        }
                }
                return $col;
@@ -2156,29 +2148,27 @@ class GraphicalFunctions {
                $align[0] = strtolower(substr(trim($align[0]), 0, 1));
                $align[1] = strtolower(substr(trim($align[1]), 0, 1));
                switch ($align[0]) {
-               case 'r':
-                       $result[0] = $w - $result[2];
-                       break;
-               case 'c':
-                       $result[0] = round(($w - $result[2]) / 2);
-                       break;
-               default:
-                       $result[0] = 0;
-                       break;
+                       case 'r':
+                               $result[0] = $w - $result[2];
+                               break;
+                       case 'c':
+                               $result[0] = round(($w - $result[2]) / 2);
+                               break;
+                       default:
+                               $result[0] = 0;
                }
                switch ($align[1]) {
-               case 'b':
-                       // y pos
-                       $result[1] = $h - $result[3];
-                       break;
-               case 'c':
-                       $result[1] = round(($h - $result[3]) / 2);
-                       break;
-               default:
-                       $result[1] = 0;
-                       break;
-               }
-               $result = $this->applyOffset($result, \TYPO3\CMS\Core\Utility\GeneralUtility::intExplode(',', $conf['offset']));
+                       case 'b':
+                               // y pos
+                               $result[1] = $h - $result[3];
+                               break;
+                       case 'c':
+                               $result[1] = round(($h - $result[3]) / 2);
+                               break;
+                       default:
+                               $result[1] = 0;
+               }
+               $result = $this->applyOffset($result, GeneralUtility::intExplode(',', $conf['offset']));
                $result = $this->applyOffset($result, $workArea);
                return $result;
        }
@@ -2200,10 +2190,10 @@ class GraphicalFunctions {
         * @param array $options An array with options passed to getImageScale (see this function).
         * @param boolean $mustCreate If set, then another image than the input imagefile MUST be returned. Otherwise you can risk that the input image is good enough regarding messures etc and is of course not rendered to a new, temporary file in typo3temp/. But this option will force it to.
         * @return array [0]/[1] is w/h, [2] is file extension and [3] is the filename.
-        * @see getImageScale(), typo3/show_item.php, fileList_ext::renderImage(), tslib_cObj::getImgResource(), SC_tslib_showpic::show(), maskImageOntoImage(), copyImageOntoImage(), scale()
+        * @see getImageScale(), typo3/show_item.php, fileList_ext::renderImage(), \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::getImgResource(), SC_tslib_showpic::show(), maskImageOntoImage(), copyImageOntoImage(), scale()
         * @todo Define visibility
         */
-       public function imageMagickConvert($imagefile, $newExt = '', $w = '', $h = '', $params = '', $frame = '', $options = '', $mustCreate = 0) {
+       public function imageMagickConvert($imagefile, $newExt = '', $w = '', $h = '', $params = '', $frame = '', $options = array(), $mustCreate = FALSE) {
                if ($this->NO_IMAGE_MAGICK) {
                        // Returning file info right away
                        return $this->getImageDimensions($imagefile);
@@ -2215,7 +2205,7 @@ class GraphicalFunctions {
                                $newExt = $info[2];
                        }
                        if ($newExt == 'web') {
-                               if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->webImageExt, $info[2])) {
+                               if (GeneralUtility::inList($this->webImageExt, $info[2])) {
                                        $newExt = $info[2];
                                } else {
                                        $newExt = $this->gif_or_jpg($info[2], $info[0], $info[1]);
@@ -2224,7 +2214,7 @@ class GraphicalFunctions {
                                        }
                                }
                        }
-                       if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->imageFileExt, $newExt)) {
+                       if (GeneralUtility::inList($this->imageFileExt, $newExt)) {
                                if (strstr($w . $h, 'm')) {
                                        $max = 1;
                                } else {
@@ -2242,7 +2232,7 @@ class GraphicalFunctions {
                                if ($noScale && !$data['crs'] && !$params && !$frame && $newExt == $info[2] && !$mustCreate) {
                                        // Set the new width and height before returning,
                                        // if the noScale option is set
-                                       if ($options['noScale']) {
+                                       if (!empty($options['noScale'])) {
                                                $info[0] = $data[0];
                                                $info[1] = $data[1];
                                        }
@@ -2265,14 +2255,14 @@ class GraphicalFunctions {
                                        }
                                        $offsetX = intval(($data[0] - $data['origW']) * ($data['cropH'] + 100) / 200);
                                        $offsetY = intval(($data[1] - $data['origH']) * ($data['cropV'] + 100) / 200);
-                                       $params .= ' -crop ' . $data['origW'] . 'x' . $data['origH'] . '+' . $offsetX . '+' . $offsetY . ' ';
+                                       $params .= ' -crop ' . $data['origW'] . 'x' . $data['origH'] . '+' . $offsetX . '+' . $offsetY . '! ';
                                }
                                $command = $this->scalecmd . ' ' . $info[0] . 'x' . $info[1] . '! ' . $params . ' ';
                                $cropscale = $data['crs'] ? 'crs-V' . $data['cropV'] . 'H' . $data['cropH'] : '';
                                if ($this->alternativeOutputKey) {
-                                       $theOutputName = \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5($command . $cropscale . basename($imagefile) . $this->alternativeOutputKey . '[' . $frame . ']');
+                                       $theOutputName = GeneralUtility::shortMD5($command . $cropscale . basename($imagefile) . $this->alternativeOutputKey . '[' . $frame . ']');
                                } else {
-                                       $theOutputName = \TYPO3\CMS\Core\Utility\GeneralUtility::shortMD5($command . $cropscale . $imagefile . filemtime($imagefile) . '[' . $frame . ']');
+                                       $theOutputName = GeneralUtility::shortMD5($command . $cropscale . $imagefile . filemtime($imagefile) . '[' . $frame . ']');
                                }
                                if ($this->imageMagickConvert_forceFileNameBody) {
                                        $theOutputName = $this->imageMagickConvert_forceFileNameBody;
@@ -2295,7 +2285,7 @@ class GraphicalFunctions {
                                        }
                                        if ($info[2] == $this->gifExtension && !$this->dontCompress) {
                                                // Compress with IM (lzw) or GD (rle)  (Workaround for the absence of lzw-compression in GD)
-                                               \TYPO3\CMS\Core\Utility\GeneralUtility::gif_compress($info[3], '');
+                                               GeneralUtility::gif_compress($info[3], '');
                                        }
                                        return $info;
                                }
@@ -2308,12 +2298,12 @@ class GraphicalFunctions {
         *
         * @param string $imageFile The image filepath
         * @return array Returns an array where [0]/[1] is w/h, [2] is extension and [3] is the filename.
-        * @see imageMagickConvert(), tslib_cObj::getImgResource()
+        * @see imageMagickConvert(), \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::getImgResource()
         * @todo Define visibility
         */
        public function getImageDimensions($imageFile) {
                preg_match('/([^\\.]*)$/', $imageFile, $reg);
-               if (file_exists($imageFile) && \TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->imageFileExt, strtolower($reg[0]))) {
+               if (file_exists($imageFile) && GeneralUtility::inList($this->imageFileExt, strtolower($reg[0]))) {
                        if ($returnArr = $this->getCachedImageDimensions($imageFile)) {
                                return $returnArr;
                        } else {
@@ -2418,7 +2408,7 @@ class GraphicalFunctions {
                $w = intval($w);
                $h = intval($h);
                // If there are max-values...
-               if ($options['maxW']) {
+               if (!empty($options['maxW'])) {
                        // If width is given...
                        if ($w) {
                                if ($w > $options['maxW']) {
@@ -2434,7 +2424,7 @@ class GraphicalFunctions {
                                }
                        }
                }
-               if ($options['maxH']) {
+               if (!empty($options['maxH'])) {
                        // If height is given...
                        if ($h) {
                                if ($h > $options['maxH']) {
@@ -2496,13 +2486,13 @@ class GraphicalFunctions {
                $out[0] = $info[0];
                $out[1] = $info[1];
                // Set minimum-measures!
-               if ($options['minW'] && $out[0] < $options['minW']) {
+               if (isset($options['minW']) && $out[0] < $options['minW']) {
                        if (($max || $crs) && $out[0]) {
                                $out[1] = round($out[1] * $options['minW'] / $out[0]);
                        }
                        $out[0] = $options['minW'];
                }
-               if ($options['minH'] && $out[1] < $options['minH']) {
+               if (isset($options['minH']) && $out[1] < $options['minH']) {
                        if (($max || $crs) && $out[1]) {
                                $out[0] = round($out[0] * $options['minH'] / $out[1]);
                        }
@@ -2529,11 +2519,11 @@ class GraphicalFunctions {
                                // If not, we look up in the cache_typo3temp_log table to see if there is a image being rendered right now.
                                $md5Hash = md5($output);
                                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('md5hash', 'cache_typo3temp_log', 'md5hash=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($md5Hash, 'cache_typo3temp_log') . ' AND tstamp>' . ($GLOBALS['EXEC_TIME'] - 30));
-                               // If there was a record, the image is being generated by another proces (we assume)
+                               // If there was a record, the image is being generated by another process (we assume)
                                if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                                        $GLOBALS['TYPO3_DB']->sql_free_result($res);
                                        if (is_object($GLOBALS['TSFE'])) {
-                                               $GLOBALS['TSFE']->set_no_cache();
+                                               $GLOBALS['TSFE']->set_no_cache('Another process renders this file now: ' . $output);
                                        }
                                        // ...so we set no_cache, because we dont want this page (which will NOT display an image...!) to be cached! (Only a page with the correct image on...)
                                        if (is_object($GLOBALS['TT'])) {
@@ -2578,7 +2568,7 @@ class GraphicalFunctions {
        public function imageMagickIdentify($imagefile) {
                if (!$this->NO_IMAGE_MAGICK) {
                        $frame = $this->noFramePrepended ? '' : '[0]';
-                       $cmd = \TYPO3\CMS\Core\Utility\GeneralUtility::imageMagickCommand('identify', $this->wrapFileName($imagefile) . $frame);
+                       $cmd = GeneralUtility::imageMagickCommand('identify', $this->wrapFileName($imagefile) . $frame);
                        $returnVal = array();
                        \TYPO3\CMS\Core\Utility\CommandUtility::exec($cmd, $returnVal);
                        $splitstring = $returnVal[0];
@@ -2623,11 +2613,11 @@ class GraphicalFunctions {
                        } else {
                                $frame = '';
                        }
-                       $cmd = \TYPO3\CMS\Core\Utility\GeneralUtility::imageMagickCommand('convert', $params . ' ' . $this->wrapFileName($input) . $frame . ' ' . $this->wrapFileName($output));
+                       $cmd = GeneralUtility::imageMagickCommand('convert', $params . ' ' . $this->wrapFileName($input) . $frame . ' ' . $this->wrapFileName($output));
                        $this->IM_commands[] = array($output, $cmd);
                        $ret = \TYPO3\CMS\Core\Utility\CommandUtility::exec($cmd);
                        // Change the permissions of the file
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::fixPermissions($output);
+                       GeneralUtility::fixPermissions($output);
                        return $ret;
                }
        }
@@ -2647,19 +2637,14 @@ 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 = \TYPO3\CMS\Core\Utility\GeneralUtility::imageMagickCommand('combine', '-compose over +matte ' . $this->wrapFileName($input) . ' ' . $this->wrapFileName($overlay) . ' ' . $this->wrapFileName($theMask) . ' ' . $this->wrapFileName($output));
+                       $cmd = GeneralUtility::imageMagickCommand('combine', '-compose over +matte ' . $this->wrapFileName($input) . ' ' . $this->wrapFileName($overlay) . ' ' . $this->wrapFileName($theMask) . ' ' . $this->wrapFileName($output));
                        // +matte = no alpha layer in output
                        $this->IM_commands[] = array($output, $cmd);
                        $ret = \TYPO3\CMS\Core\Utility\CommandUtility::exec($cmd);
                        // Change the permissions of the file
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::fixPermissions($output);
+                       GeneralUtility::fixPermissions($output);
                        if (is_file($theMask)) {
                                @unlink($theMask);
                        }
@@ -2709,19 +2694,19 @@ class GraphicalFunctions {
         * Creates subdirectory in typo3temp/ if not already found.
         *
         * @param string $dirName Name of sub directory
-        * @return boolean Result of t3lib_div::mkdir(), TRUE if it went well.
+        * @return boolean Result of \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir(), TRUE if it went well.
         * @todo Define visibility
         */
        public function createTempSubDir($dirName) {
                // Checking if the this->tempPath is already prefixed with PATH_site and if not, prefix it with that constant.
-               if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($this->tempPath, PATH_site)) {
+               if (GeneralUtility::isFirstPartOfStr($this->tempPath, PATH_site)) {
                        $tmpPath = $this->tempPath;
                } else {
                        $tmpPath = PATH_site . $this->tempPath;
                }
                // Making the temporary filename:
                if (!@is_dir(($tmpPath . $dirName))) {
-                       return \TYPO3\CMS\Core\Utility\GeneralUtility::mkdir($tmpPath . $dirName);
+                       return GeneralUtility::mkdir($tmpPath . $dirName);
                }
        }
 
@@ -2775,7 +2760,7 @@ class GraphicalFunctions {
         *
         * @param string $file The filename to write to.
         * @return string Returns input filename
-        * @see tslib_gifBuilder::gifBuild()
+        * @see \TYPO3\CMS\Frontend\Imaging\GifBuilder::gifBuild()
         * @todo Define visibility
         */
        public function output($file) {
@@ -2784,35 +2769,35 @@ class GraphicalFunctions {
                        preg_match('/([^\\.]*)$/', $file, $reg);
                        $ext = strtolower($reg[0]);
                        switch ($ext) {
-                       case 'gif':
-
-                       case 'png':
-                               if ($this->ImageWrite($this->im, $file)) {
-                                       // ImageMagick operations
-                                       if ($this->setup['reduceColors'] || !$this->png_truecolor) {
-                                               $reduced = $this->IMreduceColors($file, \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->setup['reduceColors'], 256, $this->truecolorColors, 256));
-                                               if ($reduced) {
-                                                       @copy($reduced, $file);
-                                                       @unlink($reduced);
+                               case 'gif':
+
+                               case 'png':
+                                       if ($this->ImageWrite($this->im, $file)) {
+                                               // ImageMagick operations
+                                               if ($this->setup['reduceColors'] || !$this->png_truecolor) {
+                                                       $reduced = $this->IMreduceColors($file, MathUtility::forceIntegerInRange($this->setup['reduceColors'], 256, $this->truecolorColors, 256));
+                                                       if ($reduced) {
+                                                               @copy($reduced, $file);
+                                                               @unlink($reduced);
+                                                       }
                                                }
+                                               // Compress with IM! (adds extra compression, LZW from ImageMagick)
+                                               // (Workaround for the absence of lzw-compression in GD)
+                                               GeneralUtility::gif_compress($file, 'IM');
                                        }
-                                       // Compress with IM! (adds extra compression, LZW from ImageMagick)
-                                       // (Workaround for the absence of lzw-compression in GD)
-                                       \TYPO3\CMS\Core\Utility\GeneralUtility::gif_compress($file, 'IM');
-                               }
-                               break;
-                       case 'jpg':
+                                       break;
+                               case 'jpg':
 
-                       case 'jpeg':
-                               // Use the default
-                               $quality = 0;
-                               if ($this->setup['quality']) {
-                                       $quality = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->setup['quality'], 10, 100);
-                               }
-                               if ($this->ImageWrite($this->im, $file, $quality)) {
+                               case 'jpeg':
+                                       // Use the default
+                                       $quality = 0;
+                                       if ($this->setup['quality']) {
+                                               $quality = MathUtility::forceIntegerInRange($this->setup['quality'], 10, 100);
+                                       }
+                                       if ($this->ImageWrite($this->im, $file, $quality)) {
 
-                               }
-                               break;
+                                       }
+                                       break;
                        }
                        $GLOBALS['TEMP_IMAGES_ON_PAGE'][] = $file;
                }
@@ -2823,7 +2808,7 @@ class GraphicalFunctions {
         * Destroy internal image pointer, $this->im
         *
         * @return void
-        * @see tslib_gifBuilder::gifBuild()
+        * @see \TYPO3\CMS\Frontend\Imaging\GifBuilder::gifBuild()
         * @todo Define visibility
         */
        public function destroy() {
@@ -2856,30 +2841,30 @@ class GraphicalFunctions {
                $ext = strtolower(substr($theImage, strrpos($theImage, '.') + 1));
                $result = FALSE;
                switch ($ext) {
-               case 'jpg':
+                       case 'jpg':
 
-               case 'jpeg':
-                       if (function_exists('imageJpeg')) {
-                               if ($quality == 0) {
-                                       $quality = $this->jpegQuality;
+                       case 'jpeg':
+                               if (function_exists('imageJpeg')) {
+                                       if ($quality == 0) {
+                                               $quality = $this->jpegQuality;
+                                       }
+                                       $result = imageJpeg($destImg, $theImage, $quality);
                                }
-                               $result = imageJpeg($destImg, $theImage, $quality);
-                       }
-                       break;
-               case 'gif':
-                       if (function_exists('imageGif')) {
-                               imagetruecolortopalette($destImg, TRUE, 256);
-                               $result = imageGif($destImg, $theImage);
-                       }
-                       break;
-               case 'png':
-                       if (function_exists('imagePng')) {
-                               $result = ImagePng($destImg, $theImage);
-                       }
-                       break;
+                               break;
+                       case 'gif':
+                               if (function_exists('imageGif')) {
+                                       imagetruecolortopalette($destImg, TRUE, 256);
+                                       $result = imageGif($destImg, $theImage);
+                               }
+                               break;
+                       case 'png':
+                               if (function_exists('imagePng')) {
+                                       $result = ImagePng($destImg, $theImage);
+                               }
+                               break;
                }
                if ($result) {
-                       \TYPO3\CMS\Core\Utility\GeneralUtility::fixPermissions($theImage);
+                       GeneralUtility::fixPermissions($theImage);
                }
                return $result;
        }
@@ -2896,27 +2881,27 @@ class GraphicalFunctions {
                $imgInf = pathinfo($sourceImg);
                $ext = strtolower($imgInf['extension']);
                switch ($ext) {
-               case 'gif':
-                       if (function_exists('imagecreatefromgif')) {
-                               return imageCreateFromGif($sourceImg);
-                       }
-                       break;
-               case 'png':
-                       if (function_exists('imagecreatefrompng')) {
-                               $imageHandle = imageCreateFromPng($sourceImg);
-                               if ($this->saveAlphaLayer) {
-                                       imagesavealpha($imageHandle, TRUE);
+                       case 'gif':
+                               if (function_exists('imagecreatefromgif')) {
+                                       return imageCreateFromGif($sourceImg);
                                }
-                               return $imageHandle;
-                       }
-                       break;
-               case 'jpg':
+                               break;
+                       case 'png':
+                               if (function_exists('imagecreatefrompng')) {
+                                       $imageHandle = imageCreateFromPng($sourceImg);
+                                       if ($this->saveAlphaLayer) {
+                                               imagesavealpha($imageHandle, TRUE);
+                                       }
+                                       return $imageHandle;
+                               }
+                               break;
+                       case 'jpg':
 
-               case 'jpeg':
-                       if (function_exists('imagecreatefromjpeg')) {
-                               return imageCreateFromJpeg($sourceImg);
-                       }
-                       break;
+                       case 'jpeg':
+                               if (function_exists('imagecreatefromjpeg')) {
+                                       return imageCreateFromJpeg($sourceImg);
+                               }
+                               break;
                }
                // If non of the above:
                $i = @getimagesize($sourceImg);
@@ -3005,5 +2990,4 @@ class GraphicalFunctions {
 
 }
 
-
-?>
\ No newline at end of file
+?>