2 namespace TYPO3\CMS\Core\Imaging;
132 'png' =>
'-colors 64'
261 'aqua' => array(0, 255, 255),
262 'black' => array(0, 0, 0),
263 'blue' => array(0, 0, 255),
264 'fuchsia' => array(255, 0, 255),
265 'gray' => array(128, 128, 128),
266 'green' => array(0, 128, 0),
267 'lime' => array(0, 255, 0),
268 'maroon' => array(128, 0, 0),
269 'navy' => array(0, 0, 128),
270 'olive' => array(128, 128, 0),
271 'purple' => array(128, 0, 128),
272 'red' => array(255, 0, 0),
273 'silver' => array(192, 192, 192),
274 'teal' => array(0, 128, 128),
275 'yellow' => array(255, 255, 0),
276 'white' => array(255, 255, 255)
301 $gfxConf =
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'];
302 if (function_exists(
'imagecreatefromjpeg') && function_exists(
'imagejpeg')) {
303 $this->gdlibExtensions .=
',jpg,jpeg';
305 if (function_exists(
'imagecreatefrompng') && function_exists(
'imagepng')) {
306 $this->gdlibExtensions .=
',png';
308 if (function_exists(
'imagecreatefromgif') && function_exists(
'imagegif')) {
309 $this->gdlibExtensions .=
',gif';
311 if ($gfxConf[
'png_truecolor']) {
312 $this->png_truecolor =
true;
315 if ($gfxConf[
'colorspace'] && in_array($gfxConf[
'colorspace'], $this->allowedColorSpaceNames,
true)) {
316 $this->colorspace = $gfxConf[
'colorspace'];
319 if (!$gfxConf[
'im']) {
320 $this->NO_IMAGE_MAGICK = 1;
322 if (!$this->NO_IMAGE_MAGICK && (!$gfxConf[
'im_version_5'] || $gfxConf[
'im_version_5'] ===
'im4' || $gfxConf[
'im_version_5'] ===
'im5')) {
323 throw new \RuntimeException(
'Your TYPO3 installation is configured to use an old version of ImageMagick, which is not supported anymore. ' .
'Please upgrade to ImageMagick version 6 or GraphicksMagick and set $TYPO3_CONF_VARS[\'GFX\'][\'im_version_5\'] appropriately.', 1305059666);
327 if ($this->png_truecolor) {
328 $this->cmds[
'png'] =
'';
332 $this->cmds[
'jpg'] = ($this->cmds[
'jpeg'] =
'-colorspace ' . $this->colorspace .
' -sharpen 50 -quality ' . $this->jpegQuality);
333 if ($gfxConf[
'im_noFramePrepended']) {
334 $this->noFramePrepended = 1;
336 if ($gfxConf[
'gdlib_png']) {
337 $this->gifExtension =
'png';
339 $this->imageFileExt = $gfxConf[
'imagefile_ext'];
344 $this->NO_IM_EFFECTS = 1;
345 $this->cmds[
'jpg'] = ($this->cmds[
'jpeg'] =
'-colorspace ' . $this->colorspace .
' -quality ' . $this->jpegQuality);
348 if ($gfxConf[
'im_v5effects']) {
349 $this->NO_IM_EFFECTS = 0;
350 $this->V5_EFFECTS = 1;
351 if ($gfxConf[
'im_v5effects'] > 0) {
352 $this->cmds[
'jpg'] = ($this->cmds[
'jpeg'] =
'-colorspace ' . $this->colorspace .
' -quality ' . (int)$gfxConf[
'jpg_quality'] . $this->
v5_sharpen(10));
356 if ($gfxConf[
'im_noScaleUp']) {
357 $this->mayScaleUp = 0;
359 if (TYPO3_MODE ==
'FE') {
360 $this->csConvObj =
$GLOBALS[
'TSFE']->csConvObj;
363 $this->csConvObj =
$GLOBALS[
'LANG']->csConvObj;
368 $this->nativeCharset =
'utf-8';
389 if ($conf[
'file'] && $conf[
'mask']) {
390 $imgInf = pathinfo($conf[
'file']);
391 $imgExt = strtolower($imgInf[
'extension']);
397 $maskInf = pathinfo($conf[
'mask']);
398 $maskExt = strtolower($maskInf[
'extension']);
404 if ($BBimage && $BBmask) {
413 $destImg = imagecreatetruecolor($w, $h);
415 if ($this->saveAlphaLayer) {
416 imagesavealpha($destImg,
true);
417 $Bcolor = imagecolorallocatealpha($destImg, 0, 0, 0, 127);
418 imagefill($destImg, 0, 0, $Bcolor);
420 $Bcolor = ImageColorAllocate($destImg, 0, 0, 0);
421 ImageFilledRectangle($destImg, 0, 0, $w, $h, $Bcolor);
425 imageDestroy($cpImg);
426 imageDestroy($destImg);
429 $destImg = imagecreatetruecolor($w, $h);
430 if ($this->saveAlphaLayer) {
431 imagesavealpha($destImg,
true);
432 $Bcolor = imagecolorallocatealpha($destImg, 0, 0, 0, 127);
433 imagefill($destImg, 0, 0, $Bcolor);
435 $Bcolor = ImageColorAllocate($destImg, 0, 0, 0);
436 ImageFilledRectangle($destImg, 0, 0, $w, $h, $Bcolor);
440 imageDestroy($cpImg);
441 imageDestroy($destImg);
445 $this->
combineExec($theDest, $theImage, $theMask, $theDest,
true);
450 if (!$this->saveAlphaLayer) {
451 ImageColorTransparent($backIm, -1);
456 if (!$this->dontUnlinkTempFiles) {
479 $conf[
'file'] = $conf[
'BBOX'][3];
483 imageDestroy($cpImg);
499 $cpW = imagesx($cpImg);
500 $cpH = imagesy($cpImg);
505 for ($xt = 0; $xt < $tile[0]; $xt++) {
506 $Xstart = $cpOff[0] + $cpW * $xt;
516 $w = $cpW - $cpImgCutX;
523 for ($yt = 0; $yt < $tile[1]; $yt++) {
524 $Ystart = $cpOff[1] + $cpH * $yt;
533 $h = $cpH - $cpImgCutY;
539 $this->
imagecopyresized($im, $cpImg, $Xstart, $Ystart, $cpImgCutX, $cpImgCutY, $w, $h, $w, $h);
578 public function imagecopyresized(&$dstImg, $srcImg, $dstX, $dstY, $srcX, $srcY, $dstWidth, $dstHeight, $srcWidth, $srcHeight)
580 if (!$this->saveAlphaLayer) {
582 $tmpImg = imagecreatetruecolor(imagesx($dstImg), imagesy($dstImg));
584 imagecopyresized($tmpImg, $dstImg, 0, 0, 0, 0, imagesx($dstImg), imagesy($dstImg), imagesx($dstImg), imagesy($dstImg));
586 imagecopyresized($tmpImg, $srcImg, $dstX, $dstY, $srcX, $srcY, $dstWidth, $dstHeight, $srcWidth, $srcHeight);
590 imagecopyresized($dstImg, $srcImg, $dstX, $dstY, $srcX, $srcY, $dstWidth, $dstHeight, $srcWidth, $srcHeight);
615 if ($conf[
'imgMap'] && is_array($conf[
'imgMap.'])) {
618 if (!$conf[
'hideButCreateMap']) {
622 if (!$conf[
'niceText']) {
623 $Fcolor = ImageColorAllocate($im, $cols[0], $cols[1], $cols[2]);
625 $Fcolor = $conf[
'antiAlias'] ? $Fcolor : -$Fcolor;
626 for ($a = 0; $a < $conf[
'iterations']; $a++) {
628 if ($spacing || $wordSpacing) {
629 $this->
SpacedImageTTFText($im, $conf[
'fontSize'], $conf[
'angle'], $txtPos[0], $txtPos[1], $Fcolor, self::prependAbsolutePath($conf[
'fontFile']), $theText, $spacing, $wordSpacing, $conf[
'splitRendering.']);
631 $this->
renderTTFText($im, $conf[
'fontSize'], $conf[
'angle'], $txtPos[0], $txtPos[1], $Fcolor, $conf[
'fontFile'], $theText, $conf[
'splitRendering.'], $conf);
645 $newW = ceil($sF * imagesx($im));
646 $newH = ceil($sF * imagesy($im));
648 $maskImg = imagecreatetruecolor($newW, $newH);
649 $Bcolor = ImageColorAllocate($maskImg, 255, 255, 255);
650 ImageFilledRectangle($maskImg, 0, 0, $newW, $newH, $Bcolor);
651 $Fcolor = ImageColorAllocate($maskImg, 0, 0, 0);
653 if ($spacing || $wordSpacing) {
654 $this->
SpacedImageTTFText($maskImg, $conf[
'fontSize'], $conf[
'angle'], $txtPos[0], $txtPos[1], $Fcolor, self::prependAbsolutePath($conf[
'fontFile']), $theText, $spacing, $wordSpacing, $conf[
'splitRendering.'], $sF);
656 $this->
renderTTFText($maskImg, $conf[
'fontSize'], $conf[
'angle'], $txtPos[0], $txtPos[1], $Fcolor, $conf[
'fontFile'], $theText, $conf[
'splitRendering.'], $conf, $sF);
659 ImageDestroy($maskImg);
661 if ($this->NO_IM_EFFECTS) {
662 $command = trim($this->scalecmd .
' ' . $w .
'x' . $h .
'! -negate');
664 $command = trim($conf[
'niceText.'][
'before'] .
' ' . $this->scalecmd .
' ' . $w .
'x' . $h .
'! ' . $conf[
'niceText.'][
'after'] .
' -negate');
665 if ($conf[
'niceText.'][
'sharpen']) {
666 if ($this->V5_EFFECTS) {
667 $command .= $this->
v5_sharpen($conf[
'niceText.'][
'sharpen']);
675 $colorImg = imagecreatetruecolor($w, $h);
676 $Ccolor = ImageColorAllocate($colorImg, $cols[0], $cols[1], $cols[2]);
677 ImageFilledRectangle($colorImg, 0, 0, $w, $h, $Ccolor);
679 ImageDestroy($colorImg);
683 $this->
combineExec($fileMenu, $fileColor, $fileMask, $fileMenu);
688 if (!$this->saveAlphaLayer) {
689 ImageColorTransparent($backIm, -1);
694 if (!$this->dontUnlinkTempFiles) {
715 $angle = (int)$conf[
'angle'] / 180 * pi();
717 $straightBB = $this->
calcBBox($conf);
724 switch ($conf[
'align']) {
728 $factor = abs(cos($angle));
729 $sign = cos($angle) < 0 ? -1 : 1;
730 $len1 = $sign * $factor * $straightBB[0];
731 $len2 = $sign * $BB[0];
732 $result[0] = $w - ceil(($len2 * $factor + (1 - $factor) * $len1));
733 $factor = abs(sin($angle));
734 $sign = sin($angle) < 0 ? -1 : 1;
735 $len1 = $sign * $factor * $straightBB[0];
736 $len2 = $sign * $BB[1];
737 $result[1] = ceil($len2 * $factor + (1 - $factor) * $len1);
740 switch ($conf[
'align']) {
744 $result[0] = round($result[0] / 2);
745 $result[1] = round($result[1] / 2);
769 $charInf = $this->
ImageTTFBBoxWrapper($conf[
'fontSize'], $conf[
'angle'], $conf[
'fontFile'], $theText, $conf[
'splitRendering.'], $sF);
770 $theBBoxInfo = $charInf;
771 if ($conf[
'angle']) {
772 $xArr = array($charInf[0], $charInf[2], $charInf[4], $charInf[6]);
773 $yArr = array($charInf[1], $charInf[3], $charInf[5], $charInf[7]);
774 $x = max($xArr) - min($xArr);
775 $y = max($yArr) - min($yArr);
777 $x = $charInf[2] - $charInf[0];
778 $y = $charInf[1] - $charInf[7];
781 $theBBoxInfo[
'lineHeight'] = $y;
783 if ($spacing || $wordSpacing) {
785 if (!$spacing && $wordSpacing) {
786 $bits = explode(
' ', $theText);
787 foreach ($bits as $word) {
789 $wordInf = $this->
ImageTTFBBoxWrapper($conf[
'fontSize'], $conf[
'angle'], $conf[
'fontFile'], $word, $conf[
'splitRendering.'], $sF);
790 $wordW = $wordInf[2] - $wordInf[0];
791 $x += $wordW + $wordSpacing;
796 foreach ($utf8Chars as $char) {
797 $charInf = $this->
ImageTTFBBoxWrapper($conf[
'fontSize'], $conf[
'angle'], $conf[
'fontFile'], $char, $conf[
'splitRendering.'], $sF);
798 $charW = $charInf[2] - $charInf[0];
799 $x += $charW + ($char ==
' ' ? $wordSpacing : $spacing);
802 }
elseif (isset($conf[
'breakWidth']) && $conf[
'breakWidth'] && $this->
getRenderedTextWidth($conf[
'text'], $conf) > $conf[
'breakWidth']) {
805 $breakWidth = $conf[
'breakWidth'];
809 foreach ($wordPairs as $index => $wordPair) {
811 if ($index == 0 || $currentWidth + $wordWidth <= $breakWidth) {
812 $currentWidth += $wordWidth;
814 $maxWidth = max($maxWidth, $currentWidth);
817 $currentWidth = $wordWidth;
820 $x = max($maxWidth, $currentWidth) * $sF;
825 if (is_array($theBBoxInfo)) {
826 foreach ($theBBoxInfo as &$value) {
827 $value = ceil($value / $sF);
832 return array($x, $y, $theBBoxInfo);
846 $this->map .=
'<area' .
' shape="poly"' .
' coords="' . implode(
',', $cords) .
'"'
847 .
' href="' . htmlspecialchars($conf[
'url']) .
'"'
848 . ($conf[
'target'] ?
' target="' . htmlspecialchars($conf[
'target']) .
'"' :
'')
849 . ((
string)$conf[
'titleText'] !==
'' ?
' title="' . htmlspecialchars($conf[
'titleText']) .
'"' :
'')
850 .
' alt="' . htmlspecialchars($conf[
'altText']) .
'" />';
866 $newCords[0] = $cords[0] + $offset[0] - $pars[0];
867 $newCords[1] = $cords[1] + $offset[1] + $pars[1];
868 $newCords[2] = $cords[2] + $offset[0] + $pars[0];
869 $newCords[3] = $cords[3] + $offset[1] + $pars[1];
870 $newCords[4] = $cords[4] + $offset[0] + $pars[0];
871 $newCords[5] = $cords[5] + $offset[1] - $pars[1];
872 $newCords[6] = $cords[6] + $offset[0] - $pars[0];
873 $newCords[7] = $cords[7] + $offset[1] - $pars[1];
897 public function SpacedImageTTFText(&$im, $fontSize, $angle, $x, $y, $Fcolor, $fontFile, $text, $spacing, $wordSpacing, $splitRenderingConf, $sF = 1)
901 if (!$spacing && $wordSpacing) {
902 $bits = explode(
' ', $text);
903 foreach ($bits as $word) {
905 $wordInf = $this->
ImageTTFBBoxWrapper($fontSize, $angle, $fontFile, $word, $splitRenderingConf, $sF);
906 $wordW = $wordInf[2] - $wordInf[0];
907 $this->
ImageTTFTextWrapper($im, $fontSize, $angle, $x, $y, $Fcolor, $fontFile, $word, $splitRenderingConf, $sF);
908 $x += $wordW + $wordSpacing;
913 foreach ($utf8Chars as $char) {
914 $charInf = $this->
ImageTTFBBoxWrapper($fontSize, $angle, $fontFile, $char, $splitRenderingConf, $sF);
915 $charW = $charInf[2] - $charInf[0];
916 $this->
ImageTTFTextWrapper($im, $fontSize, $angle, $x, $y, $Fcolor, $fontFile, $char, $splitRenderingConf, $sF);
917 $x += $charW + ($char ==
' ' ? $wordSpacing : $spacing);
933 $maxWidth = (int)$conf[
'maxWidth'];
937 if ($spacing || $wordSpacing) {
938 return $conf[
'fontSize'];
942 $bounds = $this->
ImageTTFBBoxWrapper($conf[
'fontSize'], $conf[
'angle'], $conf[
'fontFile'], $this->
recodeString($conf[
'text']), $conf[
'splitRendering.']);
943 if ($conf[
'angle'] < 0) {
944 $pixelWidth = abs($bounds[4] - $bounds[0]);
945 }
elseif ($conf[
'angle'] > 0) {
946 $pixelWidth = abs($bounds[2] - $bounds[6]);
948 $pixelWidth = abs($bounds[4] - $bounds[6]);
951 if ($pixelWidth <= $maxWidth) {
956 }
while ($conf[
'fontSize'] > 1);
959 return $conf[
'fontSize'];
976 $offsetInfo = array();
977 $stringParts = $this->
splitString($string, $splitRendering, $fontSize, $fontFile);
979 foreach ($stringParts as $strCfg) {
980 $fontFile = self::prependAbsolutePath($strCfg[
'fontFile']);
981 if (is_readable($fontFile)) {
992 }
while ($calc[2] < 0 && $try++ < 10);
994 if (empty($offsetInfo)) {
998 $offsetInfo[2] += $calc[2] - $calc[0] + (int)$splitRendering[
'compX'] + (
int)$strCfg[
'xSpaceBefore'] + (int)$strCfg[
'xSpaceAfter'];
999 $offsetInfo[3] += $calc[3] - $calc[1] - (int)$splitRendering[
'compY'] - (
int)$strCfg[
'ySpaceBefore'] - (int)$strCfg[
'ySpaceAfter'];
1000 $offsetInfo[4] += $calc[4] - $calc[6] + (int)$splitRendering[
'compX'] + (
int)$strCfg[
'xSpaceBefore'] + (int)$strCfg[
'xSpaceAfter'];
1001 $offsetInfo[5] += $calc[5] - $calc[7] - (int)$splitRendering[
'compY'] - (
int)$strCfg[
'ySpaceBefore'] - (int)$strCfg[
'ySpaceAfter'];
1004 debug(
'cannot read file: ' . $fontFile, \TYPO3\CMS\Core\Imaging\GraphicalFunctions::class .
'::ImageTTFBBoxWrapper()');
1025 public function ImageTTFTextWrapper($im, $fontSize, $angle, $x, $y, $color, $fontFile, $string, $splitRendering, $sF = 1)
1028 $stringParts = $this->
splitString($string, $splitRendering, $fontSize, $fontFile);
1029 $x = ceil($sF * $x);
1030 $y = ceil($sF * $y);
1032 foreach ($stringParts as $i => $strCfg) {
1034 $colorIndex = $color;
1036 if ($strCfg[
'color'] && $sF == 1) {
1038 $colorIndex = ImageColorAllocate($im, $cols[0], $cols[1], $cols[2]);
1039 $colorIndex = $color >= 0 ? $colorIndex : -$colorIndex;
1043 $x += (int)$strCfg[
'xSpaceBefore'];
1044 $y -= (int)$strCfg[
'ySpaceBefore'];
1046 $fontFile = self::prependAbsolutePath($strCfg[
'fontFile']);
1047 if (is_readable($fontFile)) {
1051 $wordInf = ImageTTFBBox(
GeneralUtility::freetypeDpiComp($sF * $strCfg[
'fontSize']), $angle, self::prependAbsolutePath($strCfg[
'fontFile']), $strCfg[
'str']);
1052 $x += $wordInf[2] - $wordInf[0] + (int)$splitRendering[
'compX'] + (
int)$strCfg[
'xSpaceAfter'];
1053 $y += $wordInf[5] - $wordInf[7] - (int)$splitRendering[
'compY'] - (
int)$strCfg[
'ySpaceAfter'];
1055 debug(
'cannot read file: ' . $fontFile, \TYPO3\CMS\Core\Imaging\GraphicalFunctions::class .
'::ImageTTFTextWrapper()');
1069 public function splitString($string, $splitRendering, $fontSize, $fontFile)
1075 'fontSize' => $fontSize,
1076 'fontFile' => $fontFile
1080 if (is_array($splitRendering)) {
1081 $sKeyArray = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($splitRendering);
1083 foreach ($sKeyArray as $key) {
1084 $cfg = $splitRendering[$key .
'.'];
1086 switch ((
string)$splitRendering[$key]) {
1087 case 'highlightWord':
1088 if ((
string)$cfg[
'value'] !==
'') {
1089 $newResult = array();
1091 foreach ($result as $part) {
1093 $explodedParts = explode($cfg[
'value'], $part[
'str']);
1094 foreach ($explodedParts as $c => $expValue) {
1095 if ((
string)$expValue !==
'') {
1096 $newResult[] = array_merge($part, array(
'str' => $expValue));
1098 if ($c + 1 < count($explodedParts)) {
1099 $newResult[] = array(
1100 'str' => $cfg[
'value'],
1101 'fontSize' => $cfg[
'fontSize'] ? $cfg[
'fontSize'] : $part[
'fontSize'],
1102 'fontFile' => $cfg[
'fontFile'] ? $cfg[
'fontFile'] : $part[
'fontFile'],
1103 'color' => $cfg[
'color'],
1104 'xSpaceBefore' => $cfg[
'xSpaceBefore'],
1105 'xSpaceAfter' => $cfg[
'xSpaceAfter'],
1106 'ySpaceBefore' => $cfg[
'ySpaceBefore'],
1107 'ySpaceAfter' => $cfg[
'ySpaceAfter']
1113 if (!empty($newResult)) {
1114 $result = $newResult;
1119 if ((
string)$cfg[
'value'] !==
'') {
1122 foreach ($ranges as $i => $rangeDef) {
1124 if (!isset($ranges[$i][1])) {
1125 $ranges[$i][1] = $ranges[$i][0];
1128 $newResult = array();
1130 foreach ($result as $part) {
1136 foreach ($utf8Chars as $utfChar) {
1138 $uNumber = $this->csConvObj->utf8CharToUnumber($utfChar);
1140 foreach ($ranges as $rangeDef) {
1141 if ($uNumber >= $rangeDef[0] && (!$rangeDef[1] || $uNumber <= $rangeDef[1])) {
1146 if ($currentState == -1) {
1147 $currentState = $inRange;
1153 if ($bankAccum !==
'') {
1154 $newResult[] = array(
1155 'str' => $bankAccum,
1156 'fontSize' => $currentState && $cfg[
'fontSize'] ? $cfg[
'fontSize'] : $part[
'fontSize'],
1157 'fontFile' => $currentState && $cfg[
'fontFile'] ? $cfg[
'fontFile'] : $part[
'fontFile'],
1158 'color' => $currentState ? $cfg[
'color'] :
'',
1159 'xSpaceBefore' => $currentState ? $cfg[
'xSpaceBefore'] :
'',
1160 'xSpaceAfter' => $currentState ? $cfg[
'xSpaceAfter'] :
'',
1161 'ySpaceBefore' => $currentState ? $cfg[
'ySpaceBefore'] :
'',
1162 'ySpaceAfter' => $currentState ? $cfg[
'ySpaceAfter'] :
''
1166 $currentState = $inRange;
1170 $bankAccum .= $utfChar;
1173 if ($bankAccum !==
'') {
1174 $newResult[] = array(
1175 'str' => $bankAccum,
1176 'fontSize' => $currentState && $cfg[
'fontSize'] ? $cfg[
'fontSize'] : $part[
'fontSize'],
1177 'fontFile' => $currentState && $cfg[
'fontFile'] ? $cfg[
'fontFile'] : $part[
'fontFile'],
1178 'color' => $currentState ? $cfg[
'color'] :
'',
1179 'xSpaceBefore' => $currentState ? $cfg[
'xSpaceBefore'] :
'',
1180 'xSpaceAfter' => $currentState ? $cfg[
'xSpaceAfter'] :
'',
1181 'ySpaceBefore' => $currentState ? $cfg[
'ySpaceBefore'] :
'',
1182 'ySpaceAfter' => $currentState ? $cfg[
'ySpaceAfter'] :
''
1187 if (!empty($newResult)) {
1188 $result = $newResult;
1209 $spacing = (int)$conf[
'spacing'];
1210 $wordSpacing = (int)$conf[
'wordSpacing'];
1211 $wordSpacing = $wordSpacing ?: $spacing * 2;
1212 $spacing *= $scaleFactor;
1213 $wordSpacing *= $scaleFactor;
1214 return array($spacing, $wordSpacing);
1226 if (!$conf[
'niceText']) {
1251 protected function renderTTFText(&$im, $fontSize, $angle, $x, $y, $color, $fontFile, $string, $splitRendering, $conf, $sF = 1)
1253 if (isset($conf[
'breakWidth']) && $conf[
'breakWidth'] && $this->
getRenderedTextWidth($string, $conf) > $conf[
'breakWidth']) {
1256 $breakWidth = $conf[
'breakWidth'];
1260 foreach ($wordPairs as $index => $wordPair) {
1262 if ($index == 0 || $currentWidth + $wordWidth <= $breakWidth) {
1263 $currentWidth += $wordWidth;
1264 $phrase .= $wordPair;
1267 $this->
ImageTTFTextWrapper($im, $fontSize, $angle, $x, $y, $color, $fontFile, $phrase, $splitRendering, $sF);
1271 $currentWidth = $wordWidth;
1272 $phrase = $wordPair;
1276 if ($currentWidth) {
1277 $this->
ImageTTFTextWrapper($im, $fontSize, $angle, $x, $y, $color, $fontFile, $phrase, $splitRendering, $sF);
1280 $this->
ImageTTFTextWrapper($im, $fontSize, $angle, $x, $y, $color, $fontFile, $string, $splitRendering, $sF);
1292 $wordPairs = array();
1293 $wordsArray = preg_split(
'#([- .,!:]+)#', $string, -1, PREG_SPLIT_DELIM_CAPTURE);
1294 $wordsCount = count($wordsArray);
1295 for ($index = 0; $index < $wordsCount; $index += 2) {
1296 $wordPairs[] = $wordsArray[$index] . $wordsArray[($index + 1)];
1311 if ($conf[
'angle'] < 0) {
1312 $pixelWidth = abs($bounds[4] - $bounds[0]);
1313 }
elseif ($conf[
'angle'] > 0) {
1314 $pixelWidth = abs($bounds[2] - $bounds[6]);
1316 $pixelWidth = abs($bounds[4] - $bounds[6]);
1330 if (!isset($boundingBox)) {
1331 $boundingBox = $this->
calcBBox($conf);
1332 $boundingBox = $boundingBox[2];
1334 if (isset($conf[
'breakSpace']) && $conf[
'breakSpace']) {
1335 $breakSpace = $boundingBox[
'lineHeight'] * $conf[
'breakSpace'];
1337 $breakSpace = $boundingBox[
'lineHeight'];
1359 $thickness = (int)$conf[
'thickness'];
1361 $txtConf[
'fontColor'] = $conf[
'color'];
1363 for ($b = 1; $b <= $outLineDist; $b++) {
1370 for ($a = 0; $a < $it; $a++) {
1390 if ($distance && $iterations) {
1391 for ($a = 0; $a < $iterations; $a++) {
1392 $yOff = round(sin((2 * pi() / $iterations * ($a + 1))) * 100 * $distance);
1394 $yOff = (int)(ceil(abs(($yOff / 100))) * ($yOff / abs($yOff)));
1396 $xOff = round(cos((2 * pi() / $iterations * ($a + 1))) * 100 * $distance);
1398 $xOff = (int)(ceil(abs(($xOff / 100))) * ($xOff / abs($xOff)));
1400 $res[$a] = array($xOff, $yOff);
1418 $conf[
'color'] = $conf[
'highColor'];
1421 $newOffset[0] *= -1;
1422 $newOffset[1] *= -1;
1423 $conf[
'offset'] = implode(
',', $newOffset);
1424 $conf[
'color'] = $conf[
'lowColor'];
1444 if (!$blurRate || $this->NO_IM_EFFECTS) {
1445 $txtConf[
'fontColor'] = $conf[
'color'];
1457 $blurColImg = imagecreatetruecolor($w, $h);
1459 $Bcolor = ImageColorAllocate($blurColImg, $bcols[0], $bcols[1], $bcols[2]);
1460 ImageFilledRectangle($blurColImg, 0, 0, $w, $h, $Bcolor);
1462 ImageDestroy($blurColImg);
1464 $blurTextImg = imagecreatetruecolor($w + $blurBorder * 2, $h + $blurBorder * 2);
1466 $Bcolor = ImageColorAllocate($blurTextImg, 0, 0, 0);
1467 ImageFilledRectangle($blurTextImg, 0, 0, $w + $blurBorder * 2, $h + $blurBorder * 2, $Bcolor);
1468 $txtConf[
'fontColor'] =
'white';
1469 $blurBordArr = array($blurBorder, $blurBorder);
1474 ImageDestroy($blurTextImg);
1476 if ($this->V5_EFFECTS) {
1477 $command .= $this->
v5_blur($blurRate + 1);
1481 $times = ceil($blurRate / 10);
1483 $newBlurRate = $blurRate * 4;
1486 for ($a = 0; $a < $times; $a++) {
1487 $command .=
' -blur ' . $blurRate;
1494 if ($blurTextImg_tmp) {
1496 $blurTextImg = imagecreatetruecolor($w, $h);
1497 $this->
imagecopyresized($blurTextImg, $blurTextImg_tmp, 0, 0, $blurBorder, $blurBorder, $w, $h, $w, $h);
1499 ImageDestroy($blurTextImg_tmp);
1502 if ($conf[
'intensity']) {
1505 $intensity = ceil(255 - $intensity / 100 * 255);
1508 if ($opacity && $opacity < 100) {
1509 $high = ceil(255 * $opacity / 100);
1516 ImageDestroy($blurTextImg);
1520 $this->
combineExec($fileMenu, $fileColor, $fileMask, $fileMenu);
1525 if (!$this->saveAlphaLayer) {
1526 ImageColorTransparent($backIm, -1);
1532 if (!$this->dontUnlinkTempFiles) {
1557 $conf[
'offset'] = $cords[0] .
',' . $cords[1];
1561 if (isset($conf[
'opacity'])) {
1566 $opacity = abs($opacity - 100);
1567 $opacity = round(127 * $opacity / 100);
1569 $tmpColor = ImageColorAllocateAlpha($im, $cols[0], $cols[1], $cols[2], $opacity);
1570 imagefilledrectangle($im, $cords[0], $cords[1], $cords[0] + $cords[2] - 1, $cords[1] + $cords[3] - 1, $tmpColor);
1598 $conf[
'offset'] = $ellipseConfiguration[0] .
',' . $ellipseConfiguration[1];
1600 $imageCoordinates = $this->
objPosition($conf, $workArea, array($ellipseConfiguration[2], $ellipseConfiguration[3]));
1602 $fillingColor = imagecolorallocate($im, $color[0], $color[1], $color[2]);
1603 imagefilledellipse($im, $imageCoordinates[0], $imageCoordinates[1], $imageCoordinates[2], $imageCoordinates[3], $fillingColor);
1617 $commands = $this->
IMparams($conf[
'value']);
1633 if (!trim($setup)) {
1636 $effects = explode(
'|', $setup);
1638 foreach ($effects as $val) {
1639 $pairs = explode(
'=', $val, 2);
1640 $value = trim($pairs[1]);
1641 $effect = strtolower(trim($pairs[0]));
1644 $commands .=
' -gamma ' . doubleval($value);
1647 if (!$this->NO_IM_EFFECTS) {
1648 if ($this->V5_EFFECTS) {
1649 $commands .= $this->
v5_blur($value);
1656 if (!$this->NO_IM_EFFECTS) {
1657 if ($this->V5_EFFECTS) {
1681 $commands .=
' -colorspace GRAY';
1687 $commands .=
' -emboss';
1690 $commands .=
' -flip';
1693 $commands .=
' -flop';
1702 $commands .=
' -negate';
1719 $setup = $conf[
'value'];
1720 if (!trim($setup)) {
1723 $effects = explode(
'|', $setup);
1724 foreach ($effects as $val) {
1725 $pairs = explode(
'=', $val, 2);
1726 $value = trim($pairs[1]);
1727 $effect = strtolower(trim($pairs[0]));
1734 case 'outputlevels':
1739 $this->autoLevels($im);
1758 $conf[
'offset'] = $cords[0] .
',' . $cords[1];
1759 $cords = $this->
objPosition($conf, $this->workArea, array($cords[2], $cords[3]));
1760 $newIm = imagecreatetruecolor($cords[2], $cords[3]);
1761 $cols = $this->
convertColor($conf[
'backColor'] ? $conf[
'backColor'] : $this->setup[
'backColor']);
1762 $Bcolor = ImageColorAllocate($newIm, $cols[0], $cols[1], $cols[2]);
1763 ImageFilledRectangle($newIm, 0, 0, $cords[2], $cords[3], $Bcolor);
1765 $workArea = array(0, 0, $cords[2], $cords[3]);
1766 if ($cords[0] < 0) {
1769 $newConf[
'offset'] = -$cords[0];
1771 if ($cords[1] < 0) {
1774 $newConf[
'offset'] .=
',' . -$cords[1];
1778 $this->w = imagesx($im);
1779 $this->h = imagesy($im);
1794 if ($conf[
'width'] || $conf[
'height'] || $conf[
'params']) {
1798 $theNewFile = $this->
imageMagickConvert($theFile, $this->gifExtension, $conf[
'width'], $conf[
'height'], $conf[
'params']);
1803 $this->w = imagesx($im);
1804 $this->h = imagesy($im);
1808 if (!$this->dontUnlinkTempFiles) {
1810 if ($theNewFile[3] && $theNewFile[3] != $theFile) {
1811 unlink($theNewFile[3]);
1829 $this->workArea = $this->
applyOffset($this->workArea, $this->OFFSET);
1830 if (!$this->workArea[2]) {
1831 $this->workArea[2] = $this->w;
1833 if (!$this->workArea[3]) {
1834 $this->workArea[3] = $this->h;
1851 $totalCols = ImageColorsTotal($im);
1854 for ($c = 0; $c < $totalCols; $c++) {
1855 $cols = ImageColorsForIndex($im, $c);
1856 $grayArr[] = round(($cols[
'red'] + $cols[
'green'] + $cols[
'blue']) / 3);
1858 $min = min($grayArr);
1859 $max = max($grayArr);
1860 $delta = $max - $min;
1862 for ($c = 0; $c < $totalCols; $c++) {
1863 $cols = ImageColorsForIndex($im, $c);
1864 $cols[
'red'] = floor(($cols[
'red'] - $min) / $delta * 255);
1865 $cols[
'green'] = floor(($cols[
'green'] - $min) / $delta * 255);
1866 $cols[
'blue'] = floor(($cols[
'blue'] - $min) / $delta * 255);
1867 ImageColorSet($im, $c, $cols[
'red'], $cols[
'green'], $cols[
'blue']);
1889 $high = 255 - $temp;
1891 $delta = $high - $low;
1892 $totalCols = ImageColorsTotal($im);
1893 for ($c = 0; $c < $totalCols; $c++) {
1894 $cols = ImageColorsForIndex($im, $c);
1895 $cols[
'red'] = $low + floor($cols[
'red'] / 255 * $delta);
1896 $cols[
'green'] = $low + floor($cols[
'green'] / 255 * $delta);
1897 $cols[
'blue'] = $low + floor($cols[
'blue'] / 255 * $delta);
1898 ImageColorSet($im, $c, $cols[
'red'], $cols[
'green'], $cols[
'blue']);
1916 $delta = $high - $low;
1917 $totalCols = ImageColorsTotal($im);
1918 for ($c = 0; $c < $totalCols; $c++) {
1919 $cols = ImageColorsForIndex($im, $c);
1923 ImageColorSet($im, $c, $cols[
'red'], $cols[
'green'], $cols[
'blue']);
1938 $ext = strtolower($fI[
'fileext']);
1941 $params =
' -colors ' . $reduce;
1942 if ($reduce <= 256) {
1943 $params .=
' -type Palette';
1945 if ($ext ==
'png' && $reduce <= 256) {
1971 $absPath = defined(
'PATH_typo3') ? dirname(PATH_thisScript) .
'/' : PATH_site;
1987 $sharpenArr = explode(
',',
',' . $this->im5fx_sharpenSteps);
1988 $sharpenF = trim($sharpenArr[$factor]);
1990 $cmd =
' -sharpen ' . $sharpenF;
2006 $blurArr = explode(
',',
',' . $this->im5fx_blurSteps);
2007 $blurF = trim($blurArr[$factor]);
2009 $cmd =
' -blur ' . $blurF;
2023 return $this->tempPath .
'temp/' . md5(uniqid(
'',
true));
2036 $cords[0] = (int)$cords[0] + (
int)$OFFSET[0];
2037 $cords[1] = (int)$cords[1] + (
int)$OFFSET[1];
2051 $cParts = explode(
':', $string, 2);
2053 $string = $cParts[0];
2054 if (strstr($string,
'#')) {
2055 $string = preg_replace(
'/[^A-Fa-f0-9]*/',
'', $string);
2056 $col[] = HexDec(substr($string, 0, 2));
2057 $col[] = HexDec(substr($string, 2, 2));
2058 $col[] = HexDec(substr($string, 4, 2));
2059 }
elseif (strstr($string,
',')) {
2060 $string = preg_replace(
'/[^,0-9]*/',
'', $string);
2061 $strArr = explode(
',', $string);
2062 $col[] = (int)$strArr[0];
2063 $col[] = (int)$strArr[1];
2064 $col[] = (int)$strArr[2];
2066 $string = strtolower(trim($string));
2067 if ($this->colMap[$string]) {
2068 $col = $this->colMap[$string];
2070 $col = array(0, 0, 0);
2074 if (trim($cParts[1])) {
2075 $cParts[1] = trim($cParts[1]);
2076 if ($cParts[1][0] ===
'*') {
2077 $val = doubleval(substr($cParts[1], 1));
2082 $val = (int)$cParts[1];
2101 if ($this->nativeCharset && $this->nativeCharset !=
'utf-8') {
2103 $string = $this->csConvObj->utf8_encode($string, $this->nativeCharset);
2118 if ($this->nativeCharset) {
2120 return $this->csConvObj->utf8_to_numberarray($theText, 1, $returnUnicodeNumber ? 0 : 1);
2123 $c = strlen($theText);
2124 for ($a = 0; $a < $c; $a++) {
2125 $output[] = substr($theText, $a, 1);
2145 $result[2] = $BB[0];
2146 $result[3] = $BB[1];
2149 $align = explode(
',', $conf[
'align']);
2150 $align[0] = strtolower(substr(trim($align[0]), 0, 1));
2151 $align[1] = strtolower(substr(trim($align[1]), 0, 1));
2152 switch ($align[0]) {
2154 $result[0] = $w - $result[2];
2157 $result[0] = round(($w - $result[2]) / 2);
2162 switch ($align[1]) {
2165 $result[1] = $h - $result[3];
2168 $result[1] = round(($h - $result[3]) / 2);
2197 public function imageMagickConvert($imagefile, $newExt =
'', $w =
'', $h =
'', $params =
'', $frame =
'', $options = array(), $mustCreate =
false)
2199 if ($this->NO_IMAGE_MAGICK) {
2204 $newExt = strtolower(trim($newExt));
2209 if ($newExt ==
'web') {
2213 $newExt = $this->
gif_or_jpg($info[2], $info[0], $info[1]);
2215 $params = $this->cmds[$newExt];
2220 if (strstr($w . $h,
'm')) {
2226 $w = $data[
'origW'];
2227 $h = $data[
'origH'];
2233 $noScale = !$w && !$h || $data[0] == $info[0] && $data[1] == $info[1] || !empty($options[
'noScale']);
2234 if ($noScale && !$data[
'crs'] && !$params && !$frame && $newExt == $info[2] && !$mustCreate) {
2237 if (!empty($options[
'noScale'])) {
2238 $info[0] = $data[0];
2239 $info[1] = $data[1];
2241 $info[3] = $imagefile;
2244 $info[0] = $data[0];
2245 $info[1] = $data[1];
2246 $frame = $this->noFramePrepended ?
'' : (int)$frame;
2248 $params = $this->cmds[$newExt];
2252 if (!$data[
'origW']) {
2253 $data[
'origW'] = $data[0];
2255 if (!$data[
'origH']) {
2256 $data[
'origH'] = $data[1];
2258 $offsetX = (int)(($data[0] - $data[
'origW']) * ($data[
'cropH'] + 100) / 200);
2259 $offsetY = (int)(($data[1] - $data[
'origH']) * ($data[
'cropV'] + 100) / 200);
2260 $params .=
' -crop ' . $data[
'origW'] .
'x' . $data[
'origH'] .
'+' . $offsetX .
'+' . $offsetY .
'! ';
2262 $command = $this->scalecmd .
' ' . $info[0] .
'x' . $info[1] .
'! ' . $params .
' ';
2263 $cropscale = $data[
'crs'] ?
'crs-V' . $data[
'cropV'] .
'H' . $data[
'cropH'] :
'';
2264 if ($this->alternativeOutputKey) {
2265 $theOutputName =
GeneralUtility::shortMD5($command . $cropscale . basename($imagefile) . $this->alternativeOutputKey .
'[' . $frame .
']');
2267 $theOutputName =
GeneralUtility::shortMD5($command . $cropscale . $imagefile . filemtime($imagefile) .
'[' . $frame .
']');
2269 if ($this->imageMagickConvert_forceFileNameBody) {
2271 $this->imageMagickConvert_forceFileNameBody =
'';
2275 $output = $this->absPrefix . $this->tempPath .
'pics/' . $this->filenamePrefix . $theOutputName .
'.' . $newExt;
2276 if ($this->dontCheckForExistingTempFile || !file_exists($output)) {
2279 if (file_exists($output)) {
2286 if ($info[2] == $this->gifExtension && !$this->dontCompress) {
2288 self::gifCompress($info[3],
'');
2305 preg_match(
'/([^\\.]*)$/', $imageFile, $reg);
2307 if ($returnArr = $this->getCachedImageDimensions($imageFile)) {
2310 if ($temp = @getimagesize($imageFile)) {
2311 $returnArr = array($temp[0], $temp[1], strtolower($reg[0]), $imageFile);
2316 $this->cacheImageDimensions($returnArr);
2331 public function cacheImageDimensions(array $identifyResult)
2333 $filePath = $identifyResult[3];
2339 $imageDimensions = array(
2340 'hash' => $statusHash,
2341 'imagewidth' => $identifyResult[0],
2342 'imageheight' => $identifyResult[1],
2344 $cache->set($identifier, $imageDimensions);
2357 public function getCachedImageDimensions($filePath)
2363 $cachedImageDimensions = $cache->get($identifier);
2364 if (!isset($cachedImageDimensions[
'hash'])) {
2368 if ($cachedImageDimensions[
'hash'] !== $statusHash) {
2370 $cache->remove($identifier);
2373 preg_match(
'/([^\\.]*)$/', $filePath, $imageExtension);
2375 (
int)$cachedImageDimensions[
'imagewidth'],
2376 (
int)$cachedImageDimensions[
'imageheight'],
2377 strtolower($imageExtension[0]),
2396 return sha1($filePath);
2408 $fileStatus = stat($filePath);
2410 return sha1($fileStatus[
'mtime'] . $fileStatus[
'size']);
2426 if (strstr($w . $h,
'm')) {
2431 if (strstr($w . $h,
'c')) {
2432 $out[
'cropH'] = (int)substr(strstr($w,
'c'), 1);
2433 $out[
'cropV'] = (int)substr(strstr($h,
'c'), 1);
2442 if (!empty($options[
'maxW'])) {
2445 if ($w > $options[
'maxW']) {
2446 $w = $options[
'maxW'];
2451 if ($info[0] > $options[
'maxW']) {
2452 $w = $options[
'maxW'];
2458 if (!empty($options[
'maxH'])) {
2461 if ($h > $options[
'maxH']) {
2462 $h = $options[
'maxH'];
2468 if ($info[1] > $options[
'maxH']) {
2469 $h = $options[
'maxH'];
2478 if (!$this->mayScaleUp) {
2479 if ($w > $info[0]) {
2482 if ($h > $info[1]) {
2489 $info[1] = ceil($info[1] * ($w / $info[0]));
2493 $info[0] = ceil($info[0] * ($h / $info[1]));
2498 $ratio = $info[0] / $info[1];
2499 if ($h * $ratio > $w) {
2500 $h = round($w / $ratio);
2502 $w = round($h * $ratio);
2506 $ratio = $info[0] / $info[1];
2507 if ($h * $ratio < $w) {
2508 $h = round($w / $ratio);
2510 $w = round($h * $ratio);
2520 if (isset($options[
'minW']) && $out[0] < $options[
'minW']) {
2521 if (($max || $crs) && $out[0]) {
2522 $out[1] = round($out[1] * $options[
'minW'] / $out[0]);
2524 $out[0] = $options[
'minW'];
2526 if (isset($options[
'minH']) && $out[1] < $options[
'minH']) {
2527 if (($max || $crs) && $out[1]) {
2528 $out[0] = round($out[0] * $options[
'minH'] / $out[1]);
2530 $out[1] = $options[
'minH'];
2549 if (!$this->NO_IMAGE_MAGICK) {
2550 $frame = $this->noFramePrepended ?
'' :
'[0]';
2552 $returnVal = array();
2553 \TYPO3\CMS\Core\Utility\CommandUtility::exec($cmd, $returnVal);
2554 $splitstring = array_pop($returnVal);
2555 $this->IM_commands[] = array(
'identify', $cmd, $splitstring);
2557 preg_match(
'/([^\\.]*)$/', $imagefile, $reg);
2558 $splitinfo = explode(
' ', $splitstring);
2559 foreach ($splitinfo as $key => $val) {
2562 $temp = explode(
'x', $val);
2564 if ((
int)$temp[0] && (
int)$temp[1]) {
2569 if ($dim[0] && $dim[1]) {
2570 return array($dim[0], $dim[1], strtolower($reg[0]), $imagefile);
2588 if (!$this->NO_IMAGE_MAGICK) {
2591 if (!$this->noFramePrepended) {
2592 $frame =
'[' . (int)$frame .
']';
2597 $this->IM_commands[] = array($output, $cmd);
2598 $ret = \TYPO3\CMS\Core\Utility\CommandUtility::exec($cmd);
2616 public function combineExec($input, $overlay, $mask, $output, $handleNegation =
false)
2618 if (!$this->NO_IMAGE_MAGICK) {
2619 $params =
'-colorspace GRAY +matte';
2624 $this->IM_commands[] = array($output, $cmd);
2625 $ret = \TYPO3\CMS\Core\Utility\CommandUtility::exec($cmd);
2628 if (is_file($theMask)) {
2655 $gfxConf =
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'];
2656 if (!$gfxConf[
'gif_compress'] || strtolower(substr($theFile, -4, 4)) !==
'.gif') {
2660 if (($type ===
'IM' || !$type) && $gfxConf[
'im'] && $gfxConf[
'im_path_lzw']) {
2662 $temporaryName = dirname($theFile) .
'/' . md5(uniqid(
'',
true)) .
'.gif';
2664 if (@rename($theFile, $temporaryName)) {
2667 unlink($temporaryName);
2670 if (@is_file($theFile)) {
2673 }
elseif (($type ===
'GD' || !$type) && $gfxConf[
'gdlib'] && !$gfxConf[
'gdlib_png']) {
2674 $tempImage = imageCreateFromGif($theFile);
2675 imageGif($tempImage, $theFile);
2676 imageDestroy($tempImage);
2678 if (@is_file($theFile)) {
2712 if (!
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'im'] || !@is_file($theFile)) {
2716 $ext = strtolower(substr($theFile, -4, 4));
2717 if ((
string)$ext ==
'.png' && $output_png || (
string)$ext ==
'.gif' && !$output_png) {
2721 if (!@is_dir(PATH_site .
'typo3temp/GraphicalResources/')) {
2724 $newFile = PATH_site .
'typo3temp/GraphicalResources/' . md5($theFile .
'|' . filemtime($theFile)) . ($output_png ?
'.png' :
'.gif');
2726 'convert',
'"' . $theFile .
'" "' . $newFile .
'"',
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'im_path']
2729 if (@is_file($newFile)) {
2749 if (@is_file($file)) {
2771 if (!@is_dir(($tmpPath . $dirName))) {
2793 $this->w = imagesx($im);
2794 $this->h = imagesy($im);
2796 if (!$this->dontUnlinkTempFiles) {
2812 if ($type ==
'ai' || $w * $h < $this->pixelLimitGif) {
2832 preg_match(
'/([^\\.]*)$/', $file, $reg);
2833 $ext = strtolower($reg[0]);
2840 if ($this->setup[
'reduceColors'] || !$this->png_truecolor) {
2843 @copy($reduced, $file);
2849 self::gifCompress($file,
'IM');
2857 if ($this->setup[
'quality']) {
2860 if ($this->
ImageWrite($this->im, $file, $quality)) {
2876 ImageDestroy($this->im);
2887 return '<img src="' . $imgInfo[3] .
'" width="' . $imgInfo[0] .
'" height="' . $imgInfo[1] .
'" border="0" alt="" />';
2901 imageinterlace($destImg, 0);
2902 $ext = strtolower(substr($theImage, strrpos($theImage,
'.') + 1));
2908 if (function_exists(
'imageJpeg')) {
2909 if ($quality == 0) {
2910 $quality = $this->jpegQuality;
2912 $result = imageJpeg($destImg, $theImage, $quality);
2916 if (function_exists(
'imageGif')) {
2917 imagetruecolortopalette($destImg,
true, 256);
2918 $result = imageGif($destImg, $theImage);
2922 if (function_exists(
'imagePng')) {
2923 $result = ImagePng($destImg, $theImage);
2942 $imgInf = pathinfo($sourceImg);
2943 $ext = strtolower($imgInf[
'extension']);
2946 if (function_exists(
'imagecreatefromgif')) {
2947 return imageCreateFromGif($sourceImg);
2951 if (function_exists(
'imagecreatefrompng')) {
2952 $imageHandle = imageCreateFromPng($sourceImg);
2953 if ($this->saveAlphaLayer) {
2954 imagesavealpha($imageHandle,
true);
2956 return $imageHandle;
2962 if (function_exists(
'imagecreatefromjpeg')) {
2963 return imageCreateFromJpeg($sourceImg);
2968 $i = @getimagesize($sourceImg);
2969 $im = imagecreatetruecolor($i[0], $i[1]);
2970 $Bcolor = ImageColorAllocate($im, 128, 128, 128);
2971 ImageFilledRectangle($im, 0, 0, $i[0], $i[1], $Bcolor);
2983 $r = dechex($col[0]);
2984 if (strlen($r) < 2) {
2987 $g = dechex($col[1]);
2988 if (strlen($g) < 2) {
2991 $b = dechex($col[2]);
2992 if (strlen($b) < 2) {
2995 return '#' . $r . $g . $b;
3009 if (is_array($colArr) && !empty($colArr) && function_exists(
'imagepng') && function_exists(
'imagecreatefrompng')) {
3010 $firstCol = array_shift($colArr);
3012 if (count($colArr) > 1) {
3013 $origName = ($preName = $this->
randomName() .
'.png');
3015 $this->imageWrite($img, $preName);
3016 $firstCol = $this->
hexColor($firstColArr);
3017 foreach ($colArr as $transparentColor) {
3018 $transparentColor = $this->
convertColor($transparentColor);
3019 $transparentColor = $this->
hexColor($transparentColor);
3020 $cmd =
'-fill "' . $firstCol .
'" -opaque "' . $transparentColor .
'"';
3022 $preName = $postName;
3025 if (@is_file($origName)) {
3034 $retCol = ImageColorClosest($img, $firstColArr[0], $firstColArr[1], $firstColArr[2]);
3036 $retCol = ImageColorExact($img, $firstColArr[0], $firstColArr[1], $firstColArr[2]);
3040 if (!$this->dontUnlinkTempFiles) {
3066 if (empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'gdlib'])) {
3067 throw new \RuntimeException(
'TYPO3 Fatal Error: No gdlib. ' . $textline1 .
' ' . $textline2 .
' ' . $textline3, 1270853952);
3070 $basePath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(
'core') .
'Resources/Public/Images/';
3071 if (!empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'gdlib_png'])) {
3072 $im = imagecreatefrompng($basePath .
'NotFound.png');
3074 $im = imagecreatefromgif($basePath .
'NotFound.gif');
3077 $white = imageColorAllocate($im, 255, 255, 255);
3078 $black = imageColorAllocate($im, 0, 0, 0);
3083 imagefilledrectangle($im, $x, 9, 56, 16, $white);
3084 imageString($im, $font, $x, 9, $textline1, $black);
3087 imagefilledrectangle($im, $x, 19, 56, 26, $white);
3088 imageString($im, $font, $x, 19, $textline2, $black);
3091 imagefilledrectangle($im, $x, 29, 56, 36, $white);
3092 imageString($im, $font, $x, 29, substr($textline3, -14), $black);
3095 if (!empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'gdlib_png'])) {