38 $actionMessages = array();
39 if (isset($this->postValues[
'set'][
'testMail'])) {
40 $actionMessages[] = $this->sendTestMail();
43 if (isset($this->postValues[
'set'][
'testTrueTypeFontDpi'])) {
44 $this->view->assign(
'trueTypeFontDpiTested', TRUE);
45 $actionMessages[] = $this->createTrueTypeFontDpiTestImage();
48 if (isset($this->postValues[
'set'][
'testConvertImageFormatsToJpg'])) {
49 $this->view->assign(
'convertImageFormatsToJpgTested', TRUE);
51 $actionMessages[] = $this->convertImageFormatsToJpg();
53 $actionMessages[] = $this->imageMagickDisabledMessage();
57 if (isset($this->postValues[
'set'][
'testWriteGifAndPng'])) {
58 $this->view->assign(
'writeGifAndPngTested', TRUE);
60 $actionMessages[] = $this->writeGifAndPng();
62 $actionMessages[] = $this->imageMagickDisabledMessage();
66 if (isset($this->postValues[
'set'][
'testScalingImages'])) {
67 $this->view->assign(
'scalingImagesTested', TRUE);
71 $actionMessages[] = $this->imageMagickDisabledMessage();
75 if (isset($this->postValues[
'set'][
'testCombiningImages'])) {
76 $this->view->assign(
'combiningImagesTested', TRUE);
80 $actionMessages[] = $this->imageMagickDisabledMessage();
84 if (isset($this->postValues[
'set'][
'testGdlib'])) {
85 $this->view->assign(
'gdlibTested', TRUE);
86 $actionMessages[] = $this->gdlib();
89 $this->view->assign(
'actionMessages', $actionMessages);
93 return $this->view->render();
101 protected function sendTestMail() {
103 !isset($this->postValues[
'values'][
'testEmailRecipient'])
107 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
108 $message->setTitle(
'Mail not sent');
109 $message->setMessage(
'Given address is not a valid email address.');
111 $recipient = $this->postValues[
'values'][
'testEmailRecipient'];
113 $mailMessage = $this->objectManager->get(
'TYPO3\\CMS\\Core\\Mail\\MailMessage');
117 ->setSubject(
'Test TYPO3 CMS mail delivery')
118 ->setBody(
'<html><body>html test content</body></html>',
'text/html')
119 ->addPart(
'TEST CONTENT')
121 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\OkStatus');
122 $message->setTitle(
'Test mail sent');
123 $message->setMessage(
'Recipient: ' . $recipient);
136 return !empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'MAIL'][
'defaultMailFromAddress'])
137 ?
$GLOBALS[
'TYPO3_CONF_VARS'][
'MAIL'][
'defaultMailFromAddress']
138 :
'no-reply@example.com';
149 return !empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'MAIL'][
'defaultMailFromName'])
150 ?
$GLOBALS[
'TYPO3_CONF_VARS'][
'MAIL'][
'defaultMailFromName']
151 :
'TYPO3 CMS install tool';
159 protected function createTrueTypeFontDpiTestImage() {
162 $image = @imagecreate(200, 50);
163 imagecolorallocate($image, 255, 255, 55);
164 $textColor = imagecolorallocate($image, 233, 14, 91);
172 \
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(
'install') .
'Resources/Private/Font/vera.ttf',
175 $outputFile = PATH_site .
'typo3temp/installTool-' . uniqid(
'createTrueTypeFontDpiTestImage', TRUE) .
'.gif';
176 imagegif($image, $outputFile);
179 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\InfoStatus');
180 $message->setTitle(
'True type font DPI settings');
181 $message->setMessage(
182 'If the two images below do not look the same, set $TYPO3_CONF_VARS[GFX][TTFdpi] to a value of 72.' 185 $testResults = array();
186 $testResults[
'ttf'] = array();
187 $testResults[
'ttf'][
'message'] = $message;
188 $testResults[
'ttf'][
'title'] =
'';
189 $testResults[
'ttf'][
'outputFile'] = $outputFile;
190 $testResults[
'ttf'][
'referenceFile'] = $this->imageBasePath .
'TestReference/Font.gif';
192 $this->view->assign(
'testResults', $testResults);
201 protected function convertImageFormatsToJpg() {
203 $imageProcessor = $this->initializeImageProcessor();
206 $inputFormatsToTest = array(
'jpg',
'gif',
'png',
'tif',
'bmp',
'pcx',
'tga',
'pdf',
'ai');
208 $testResults = array();
209 foreach ($inputFormatsToTest as $formatToTest) {
213 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\WarningStatus');
214 $message->setTitle(
'Skipped test');
215 $message->setMessage(
'Handling format ' . $formatToTest .
' must be enabled in TYPO3_CONF_VARS[\'GFX\'][\'imagefile_ext\']');
218 $imageProcessor->IM_commands = array();
219 $inputFile = $this->imageBasePath .
'TestInput/Test.' . $formatToTest;
220 $imageProcessor->imageMagickConvert_forceFileNameBody = uniqid(
'read', TRUE) .
'-' . $formatToTest;
221 $imResult = $imageProcessor->imageMagickConvert($inputFile,
'jpg',
'170',
'',
'',
'', array(), TRUE);
222 $result[
'title'] =
'Read ' . $formatToTest;
223 if ($imResult !== NULL) {
224 $result[
'outputFile'] = $imResult[3];
225 $result[
'referenceFile'] = $this->imageBasePath .
'TestReference/Read-' . $formatToTest .
'.jpg';
226 $result[
'command'] = $imageProcessor->IM_commands;
228 $result[
'error'] = $this->imageGenerationFailedMessage();
235 $this->view->assign(
'testResults', $testResults);
244 protected function writeGifAndPng() {
246 $imageProcessor = $this->initializeImageProcessor();
249 $testResults = array(
255 $inputFile = $this->imageBasePath .
'TestInput/Test.gif';
256 $imageProcessor->imageMagickConvert_forceFileNameBody = uniqid(
'write-gif', TRUE);
257 $imResult = $imageProcessor->imageMagickConvert($inputFile,
'gif',
'',
'',
'',
'', array(), TRUE);
258 if ($imResult !== NULL && is_file($imResult[3])) {
259 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'gif_compress']) {
266 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\InfoStatus');
267 $message->setTitle(
'Compressed gif');
268 $message->setMessage(
269 'Method used by compress: ' . $methodUsed . LF
270 .
' Previous filesize: ' . $previousSize .
'. Current filesize:' . $compressedSize
274 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\InfoStatus');
275 $message->setTitle(
'Gif compression not enabled by [GFX][gif_compress]');
277 $testResults[
'gif'][
'message'] = $message;
278 $testResults[
'gif'][
'title'] =
'Write gif';
279 $testResults[
'gif'][
'outputFile'] = $imResult[3];
280 $testResults[
'gif'][
'referenceFile'] = $this->imageBasePath .
'TestReference/Write-gif.gif';
281 $testResults[
'gif'][
'command'] = $imageProcessor->IM_commands;
283 $testResults[
'gif'][
'error'] = $this->imageGenerationFailedMessage();
287 $inputFile = $this->imageBasePath .
'TestInput/Test.png';
288 $imageProcessor->IM_commands = array();
289 $imageProcessor->imageMagickConvert_forceFileNameBody = uniqid(
'write-png', TRUE);
290 $imResult = $imageProcessor->imageMagickConvert($inputFile,
'png',
'',
'',
'',
'', array(), TRUE);
291 if ($imResult !== NULL) {
292 $testResults[
'png'][
'title'] =
'Write png';
293 $testResults[
'png'][
'outputFile'] = $imResult[3];
294 $testResults[
'png'][
'referenceFile'] = $this->imageBasePath .
'TestReference/Write-png.png';
295 $testResults[
'png'][
'command'] = $imageProcessor->IM_commands;
297 $testResults[
'png'][
'error'] = $this->imageGenerationFailedMessage();
300 $this->view->assign(
'testResults', $testResults);
311 $imageProcessor = $this->initializeImageProcessor();
314 $testResults = array(
315 'gif-to-gif' => array(),
316 'png-to-png' => array(),
317 'gif-to-jpg' => array(),
320 $imageProcessor->IM_commands = array();
321 $inputFile = $this->imageBasePath .
'TestInput/Transparent.gif';
322 $imageProcessor->imageMagickConvert_forceFileNameBody = uniqid(
'scale-gif', TRUE);
323 $imResult = $imageProcessor->imageMagickConvert($inputFile,
'gif',
'150',
'',
'',
'', array(), TRUE);
324 if ($imResult !== NULL) {
325 $testResults[
'gif-to-gif'][
'title'] =
'gif to gif';
326 $testResults[
'gif-to-gif'][
'outputFile'] = $imResult[3];
327 $testResults[
'gif-to-gif'][
'referenceFile'] = $this->imageBasePath .
'TestReference/Scale-gif.gif';
328 $testResults[
'gif-to-gif'][
'command'] = $imageProcessor->IM_commands;
330 $testResults[
'gif-to-gif'][
'error'] = $this->imageGenerationFailedMessage();
333 $imageProcessor->IM_commands = array();
334 $inputFile = $this->imageBasePath .
'TestInput/Transparent.png';
335 $imageProcessor->imageMagickConvert_forceFileNameBody = uniqid(
'scale-png', TRUE);
336 $imResult = $imageProcessor->imageMagickConvert($inputFile,
'png',
'150',
'',
'',
'', array(), TRUE);
337 if ($imResult !== NULL) {
338 $testResults[
'png-to-png'][
'title'] =
'png to png';
339 $testResults[
'png-to-png'][
'outputFile'] = $imResult[3];
340 $testResults[
'png-to-png'][
'referenceFile'] = $this->imageBasePath .
'TestReference/Scale-png.png';
341 $testResults[
'png-to-png'][
'command'] = $imageProcessor->IM_commands;
343 $testResults[
'png-to-png'][
'error'] = $this->imageGenerationFailedMessage();
346 $imageProcessor->IM_commands = array();
347 $inputFile = $this->imageBasePath .
'TestInput/Transparent.gif';
348 $imageProcessor->imageMagickConvert_forceFileNameBody = uniqid(
'scale-jpg', TRUE);
349 $imResult = $imageProcessor->imageMagickConvert($inputFile,
'jpg',
'150',
'',
'-opaque white -background white -flatten',
'', array(), TRUE);
350 if ($imResult !== NULL) {
351 $testResults[
'gif-to-jpg'][
'title'] =
'gif to jpg';
352 $testResults[
'gif-to-jpg'][
'outputFile'] = $imResult[3];
353 $testResults[
'gif-to-jpg'][
'referenceFile'] = $this->imageBasePath .
'TestReference/Scale-jpg.jpg';
354 $testResults[
'gif-to-jpg'][
'command'] = $imageProcessor->IM_commands;
356 $testResults[
'gif-to-jpg'][
'error'] = $this->imageGenerationFailedMessage();
359 $this->view->assign(
'testResults', $testResults);
370 $imageProcessor = $this->initializeImageProcessor();
373 $testResults = array(
374 'combine1' => array(),
375 'combine2' => array(),
378 $inputFile = $this->imageBasePath .
'TestInput/BackgroundGreen.gif';
379 $overlayFile = $this->imageBasePath .
'TestInput/Test.jpg';
380 $maskFile = $this->imageBasePath .
'TestInput/MaskBlackWhite.gif';
381 $resultFile = $imageProcessor->tempPath . $imageProcessor->filenamePrefix
382 . uniqid($imageProcessor->alternativeOutputKey .
'combine1', TRUE) .
'.jpg';
383 $imageProcessor->combineExec($inputFile, $overlayFile, $maskFile, $resultFile, TRUE);
384 $result = $imageProcessor->getImageDimensions($resultFile);
386 $testResults[
'combine1'][
'title'] =
'Combine using a GIF mask with only black and white';
387 $testResults[
'combine1'][
'outputFile'] =
$result[3];
388 $testResults[
'combine1'][
'referenceFile'] = $this->imageBasePath .
'TestReference/Combine-1.jpg';
389 $testResults[
'combine1'][
'command'] = $imageProcessor->IM_commands;
391 $testResults[
'combine1'][
'error'] = $this->imageGenerationFailedMessage();
394 $imageProcessor->IM_commands = array();
395 $inputFile = $this->imageBasePath .
'TestInput/BackgroundCombine.jpg';
396 $overlayFile = $this->imageBasePath .
'TestInput/Test.jpg';
397 $maskFile = $this->imageBasePath .
'TestInput/MaskCombine.jpg';
398 $resultFile = $imageProcessor->tempPath . $imageProcessor->filenamePrefix
399 . uniqid($imageProcessor->alternativeOutputKey .
'combine2', TRUE) .
'.jpg';
400 $imageProcessor->combineExec($inputFile, $overlayFile, $maskFile, $resultFile, TRUE);
401 $result = $imageProcessor->getImageDimensions($resultFile);
403 $testResults[
'combine2'][
'title'] =
'Combine using a JPG mask with graylevels';
404 $testResults[
'combine2'][
'outputFile'] =
$result[3];
405 $testResults[
'combine2'][
'referenceFile'] = $this->imageBasePath .
'TestReference/Combine-2.jpg';
406 $testResults[
'combine2'][
'command'] = $imageProcessor->IM_commands;
408 $testResults[
'combine2'][
'error'] = $this->imageGenerationFailedMessage();
411 $this->view->assign(
'testResults', $testResults);
420 protected function gdlib() {
422 $imageProcessor = $this->initializeImageProcessor();
424 $gifOrPng = $imageProcessor->gifExtension;
425 $testResults = array();
428 $imageProcessor->IM_commands = array();
429 $image = imagecreatetruecolor(170, 136);
430 $backgroundColor = imagecolorallocate($image, 0, 0, 0);
431 imagefilledrectangle($image, 0, 0, 170, 136, $backgroundColor);
432 $workArea = array(0, 0, 170, 136);
434 'dimensions' =>
'10,50,150,36',
437 $imageProcessor->makeBox($image, $conf, $workArea);
438 $outputFile = $imageProcessor->tempPath . $imageProcessor->filenamePrefix . uniqid(
'gdSimple', TRUE) .
'.' . $gifOrPng;
439 $imageProcessor->ImageWrite($image, $outputFile);
440 $result = $imageProcessor->getImageDimensions($outputFile);
441 $testResults[
'simple'] = array();
442 $testResults[
'simple'][
'title'] =
'Create simple image';
443 $testResults[
'simple'][
'outputFile'] =
$result[3];
444 $testResults[
'simple'][
'referenceFile'] = $this->imageBasePath .
'TestReference/Gdlib-simple.' . $gifOrPng;
447 $imageProcessor->IM_commands = array();
448 $inputFile = $this->imageBasePath .
'TestInput/Test.' . $gifOrPng;
449 $image = $imageProcessor->imageCreateFromFile($inputFile);
450 $workArea = array(0, 0, 170, 136);
452 'dimensions' =>
'10,50,150,36',
455 $imageProcessor->makeBox($image, $conf, $workArea);
456 $outputFile = $imageProcessor->tempPath . $imageProcessor->filenamePrefix . uniqid(
'gdBox', TRUE) .
'.' . $gifOrPng;
457 $imageProcessor->ImageWrite($image, $outputFile);
458 $result = $imageProcessor->getImageDimensions($outputFile);
459 $testResults[
'box'] = array();
460 $testResults[
'box'][
'title'] =
'Create image from file';
461 $testResults[
'box'][
'outputFile'] =
$result[3];
462 $testResults[
'box'][
'referenceFile'] = $this->imageBasePath .
'TestReference/Gdlib-box.' . $gifOrPng;
465 $imageProcessor->IM_commands = array();
466 $image = imagecreatetruecolor(170, 136);
467 $backgroundColor = imagecolorallocate($image, 128, 128, 150);
468 imagefilledrectangle($image, 0, 0, 170, 136, $backgroundColor);
469 $workArea = array(0, 0, 170, 136);
474 'text' =>
'HELLO WORLD',
475 'fontColor' =>
'#003366',
477 'fontFile' => \
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath(
'install') .
'Resources/Private/Font/vera.ttf',
480 $conf[
'BBOX'] = $imageProcessor->calcBBox($conf);
481 $imageProcessor->makeText($image, $conf, $workArea);
482 $outputFile = $imageProcessor->tempPath . $imageProcessor->filenamePrefix . uniqid(
'gdText', TRUE) .
'.' . $gifOrPng;
483 $imageProcessor->ImageWrite($image, $outputFile);
484 $result = $imageProcessor->getImageDimensions($outputFile);
485 $testResults[
'text'] = array();
486 $testResults[
'text'][
'title'] =
'Render text with TrueType font';
487 $testResults[
'text'][
'outputFile'] =
$result[3];
488 $testResults[
'text'][
'referenceFile'] = $this->imageBasePath .
'TestReference/Gdlib-text.' . $gifOrPng;
491 $testResults[
'niceText'] = array();
494 $conf[
'offset'] =
'17,65';
495 $conf[
'niceText'] = 1;
496 $imageProcessor->makeText($image, $conf, $workArea);
497 $outputFile = $imageProcessor->tempPath . $imageProcessor->filenamePrefix . uniqid(
'gdNiceText', TRUE) .
'.' . $gifOrPng;
498 $imageProcessor->ImageWrite($image, $outputFile);
499 $result = $imageProcessor->getImageDimensions($outputFile);
500 $testResults[
'niceText'][
'title'] =
'Render text with TrueType font using \'niceText\' option';
501 $testResults[
'niceText'][
'outputFile'] =
$result[3];
502 $testResults[
'niceText'][
'referenceFile'] = $this->imageBasePath .
'TestReference/Gdlib-niceText.' . $gifOrPng;
503 $testResults[
'niceText'][
'command'] = $imageProcessor->IM_commands;
505 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\InfoStatus');
506 $message->setTitle(
'Note on \'niceText\'');
507 $message->setMessage(
508 '\'niceText\
' is a concept that tries to improve the antialiasing of the rendered type by' 509 .
' actually rendering the textstring in double size on a black/white mask, downscaling the mask' 510 .
' and masking the text onto the image through this mask. This involves' 511 .
' ImageMagick \'combine\'/\'composite\' and \'convert\'.' 513 $testResults[
'niceText'][
'message'] = $message;
515 $result[
'niceText'][
'error'] = $this->imageGenerationFailedMessage();
519 $testResults[
'shadow'] = array();
522 $conf[
'offset'] =
'17,90';
523 $conf[
'niceText'] = 1;
524 $conf[
'shadow.'] = array(
526 'blur' => $imageProcessor->V5_EFFECTS ?
'20' :
'90',
531 $imageProcessor->makeShadow($image, $conf[
'shadow.'], $workArea, $conf);
532 $imageProcessor->makeText($image, $conf, $workArea);
533 $outputFile = $imageProcessor->tempPath . $imageProcessor->filenamePrefix . uniqid(
'GDwithText-niceText-shadow', TRUE) .
'.' . $gifOrPng;
534 $imageProcessor->ImageWrite($image, $outputFile);
535 $result = $imageProcessor->getImageDimensions($outputFile);
536 $testResults[
'shadow'][
'title'] =
'Render \'niceText\' with a shadow under';
537 $testResults[
'shadow'][
'outputFile'] =
$result[3];
538 $testResults[
'shadow'][
'referenceFile'] = $this->imageBasePath .
'TestReference/Gdlib-shadow.' . $gifOrPng;
539 $testResults[
'shadow'][
'command'] = $imageProcessor->IM_commands;
541 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\InfoStatus');
542 $message->setTitle(
'Note on \'shadow\'');
543 $message->setMessage(
544 'This test makes sense only if the above test had a correct output. But if so, you may not see' 545 .
' a soft dropshadow from the third text string as you should. In that case you are most likely' 546 .
' using ImageMagick 5 and should set the flag TYPO3_CONF_VARS[GFX][im_v5effects].' 548 $testResults[
'shadow'][
'message'] = $message;
550 $result[
'shadow'][
'error'] = $this->imageGenerationFailedMessage();
553 $this->view->assign(
'testResults', $testResults);
563 protected function imageTestDoneMessage($parseTime = 0) {
565 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\OkStatus');
566 $message->setTitle(
'Executed image tests');
567 $message->setMessage(
'Parse time: ' . $parseTime .
' ms');
576 protected function imageMagickDisabledMessage() {
578 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
579 $message->setTitle(
'Tests not executed');
580 $message->setMessage(
'ImageMagick / GraphicsMagick handling is disabled or not configured correctly.');
589 protected function imageGenerationFailedMessage() {
591 $message = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus');
592 $message->setTitle(
'Image generation failed');
593 $message->setMessage(
594 'ImageMagick / GraphicsMagick handling is enabled, but the execute' 595 .
' command returned an error. Please check your settings, especially' 596 .
' [\'GFX\'][\'im_path\'] and [\'GFX\'][\'im_path_lzw\'] and ensure Ghostscript is installed on your server.' 608 $result[
'imageMagickOrGraphicsMagick'] =
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'im_version_5'] ===
'gm' ?
'gm' :
'im';
609 $result[
'imageMagickEnabled'] =
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'im'];
610 $result[
'imageMagickPath'] =
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'im_path'];
612 $result[
'imageMagick5Effects'] =
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'im_v5effects'];
616 $result[
'fileFormats'] =
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'imagefile_ext'];
625 protected function initializeImageProcessor() {
627 $imageProcessor = $this->objectManager->get(
'TYPO3\\CMS\\Core\\Imaging\\GraphicalFunctions');
628 $imageProcessor->init();
629 $imageProcessor->tempPath = PATH_site .
'typo3temp/';
630 $imageProcessor->dontCheckForExistingTempFile = 1;
631 $imageProcessor->enable_typo3temp_db_tracking = 0;
632 $imageProcessor->filenamePrefix =
'installTool-';
633 $imageProcessor->dontCompress = 1;
634 $imageProcessor->alternativeOutputKey =
'typo3InstallTest';
635 $imageProcessor->noFramePrepended =
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'im_noFramePrepended'];
636 return $imageProcessor;
645 $enabled =
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'im'];
646 $path =
$GLOBALS[
'TYPO3_CONF_VARS'][
'GFX'][
'im_path'];
647 return $enabled && $path;
659 list(, $version) = explode(
'Magick', $string);
660 list($version) = explode(
' ', trim($version));
661 return trim($version);
671 $database = $this->objectManager->get(
'TYPO3\\CMS\\Install\\Database\\DatabaseConnectionMock');
static extPath($key, $script='')
static validEmail($email)
static imageMagickCommand($command, $parameters, $path='')
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
static gif_compress($theFile, $type)
static formatSize($sizeInBytes, $labels='')
static freetypeDpiComp($font_size)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static inList($list, $item)
static exec($command, &$output=NULL, &$returnValue=0)