TYPO3 CMS  TYPO3_6-2
TestSetup.php
Go to the documentation of this file.
1 <?php
3 
19 
24 
28  protected $imageBasePath = '';
29 
35  protected function executeAction() {
36  $this->imageBasePath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('install') . 'Resources/Public/Images/';
37 
38  $actionMessages = array();
39  if (isset($this->postValues['set']['testMail'])) {
40  $actionMessages[] = $this->sendTestMail();
41  }
42 
43  if (isset($this->postValues['set']['testTrueTypeFontDpi'])) {
44  $this->view->assign('trueTypeFontDpiTested', TRUE);
45  $actionMessages[] = $this->createTrueTypeFontDpiTestImage();
46  }
47 
48  if (isset($this->postValues['set']['testConvertImageFormatsToJpg'])) {
49  $this->view->assign('convertImageFormatsToJpgTested', TRUE);
50  if ($this->isImageMagickEnabledAndConfigured()) {
51  $actionMessages[] = $this->convertImageFormatsToJpg();
52  } else {
53  $actionMessages[] = $this->imageMagickDisabledMessage();
54  }
55  }
56 
57  if (isset($this->postValues['set']['testWriteGifAndPng'])) {
58  $this->view->assign('writeGifAndPngTested', TRUE);
59  if ($this->isImageMagickEnabledAndConfigured()) {
60  $actionMessages[] = $this->writeGifAndPng();
61  } else {
62  $actionMessages[] = $this->imageMagickDisabledMessage();
63  }
64  }
65 
66  if (isset($this->postValues['set']['testScalingImages'])) {
67  $this->view->assign('scalingImagesTested', TRUE);
68  if ($this->isImageMagickEnabledAndConfigured()) {
69  $actionMessages[] = $this->scaleImages();
70  } else {
71  $actionMessages[] = $this->imageMagickDisabledMessage();
72  }
73  }
74 
75  if (isset($this->postValues['set']['testCombiningImages'])) {
76  $this->view->assign('combiningImagesTested', TRUE);
77  if ($this->isImageMagickEnabledAndConfigured()) {
78  $actionMessages[] = $this->combineImages();
79  } else {
80  $actionMessages[] = $this->imageMagickDisabledMessage();
81  }
82  }
83 
84  if (isset($this->postValues['set']['testGdlib'])) {
85  $this->view->assign('gdlibTested', TRUE);
86  $actionMessages[] = $this->gdlib();
87  }
88 
89  $this->view->assign('actionMessages', $actionMessages);
90  $this->view->assign('senderEmailAddress', $this->getSenderEmailAddress());
91  $this->view->assign('imageConfiguration', $this->getImageConfiguration());
92 
93  return $this->view->render();
94  }
95 
101  protected function sendTestMail() {
102  if (
103  !isset($this->postValues['values']['testEmailRecipient'])
104  || !GeneralUtility::validEmail($this->postValues['values']['testEmailRecipient'])
105  ) {
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.');
110  } else {
111  $recipient = $this->postValues['values']['testEmailRecipient'];
113  $mailMessage = $this->objectManager->get('TYPO3\\CMS\\Core\\Mail\\MailMessage');
114  $mailMessage
115  ->addTo($recipient)
116  ->addFrom($this->getSenderEmailAddress(), $this->getSenderEmailName())
117  ->setSubject('Test TYPO3 CMS mail delivery')
118  ->setBody('<html><body>html test content</body></html>', 'text/html')
119  ->addPart('TEST CONTENT')
120  ->send();
121  $message = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\OkStatus');
122  $message->setTitle('Test mail sent');
123  $message->setMessage('Recipient: ' . $recipient);
124  }
125  return $message;
126  }
127 
135  protected function getSenderEmailAddress() {
136  return !empty($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'])
137  ? $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress']
138  : 'no-reply@example.com';
139  }
140 
148  protected function getSenderEmailName() {
149  return !empty($GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName'])
150  ? $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName']
151  : 'TYPO3 CMS install tool';
152  }
153 
159  protected function createTrueTypeFontDpiTestImage() {
160  $parseTimeStart = GeneralUtility::milliseconds();
161 
162  $image = @imagecreate(200, 50);
163  imagecolorallocate($image, 255, 255, 55);
164  $textColor = imagecolorallocate($image, 233, 14, 91);
165  @imagettftext(
166  $image,
168  0,
169  10,
170  20,
171  $textColor,
172  \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('install') . 'Resources/Private/Font/vera.ttf',
173  'Testing true type'
174  );
175  $outputFile = PATH_site . 'typo3temp/installTool-' . uniqid('createTrueTypeFontDpiTestImage', TRUE) . '.gif';
176  imagegif($image, $outputFile);
177 
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.'
183  );
184 
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';
191 
192  $this->view->assign('testResults', $testResults);
193  return $this->imageTestDoneMessage(GeneralUtility::milliseconds() - $parseTimeStart);
194  }
195 
201  protected function convertImageFormatsToJpg() {
203  $imageProcessor = $this->initializeImageProcessor();
204  $parseTimeStart = GeneralUtility::milliseconds();
205 
206  $inputFormatsToTest = array('jpg', 'gif', 'png', 'tif', 'bmp', 'pcx', 'tga', 'pdf', 'ai');
207 
208  $testResults = array();
209  foreach ($inputFormatsToTest as $formatToTest) {
210  $result = array();
211  if (!GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $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\']');
216  $result['error'] = $message;
217  } else {
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;
227  } else {
228  $result['error'] = $this->imageGenerationFailedMessage();
229  }
230 
231  }
232  $testResults[] = $result;
233  }
234 
235  $this->view->assign('testResults', $testResults);
236  return $this->imageTestDoneMessage(GeneralUtility::milliseconds() - $parseTimeStart);
237  }
238 
244  protected function writeGifAndPng() {
246  $imageProcessor = $this->initializeImageProcessor();
247  $parseTimeStart = GeneralUtility::milliseconds();
248 
249  $testResults = array(
250  'gif' => array(),
251  'png' => array(),
252  );
253 
254  // Gif
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']) {
260  clearstatcache();
261  $previousSize = GeneralUtility::formatSize(filesize($imResult[3]));
262  $methodUsed = GeneralUtility::gif_compress($imResult[3], '');
263  clearstatcache();
264  $compressedSize = GeneralUtility::formatSize(filesize($imResult[3]));
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
271  );
272  } else {
274  $message = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\InfoStatus');
275  $message->setTitle('Gif compression not enabled by [GFX][gif_compress]');
276  }
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;
282  } else {
283  $testResults['gif']['error'] = $this->imageGenerationFailedMessage();
284  }
285 
286  // Png
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;
296  } else {
297  $testResults['png']['error'] = $this->imageGenerationFailedMessage();
298  }
299 
300  $this->view->assign('testResults', $testResults);
301  return $this->imageTestDoneMessage(GeneralUtility::milliseconds() - $parseTimeStart);
302  }
303 
309  protected function scaleImages() {
311  $imageProcessor = $this->initializeImageProcessor();
312  $parseTimeStart = GeneralUtility::milliseconds();
313 
314  $testResults = array(
315  'gif-to-gif' => array(),
316  'png-to-png' => array(),
317  'gif-to-jpg' => array(),
318  );
319 
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;
329  } else {
330  $testResults['gif-to-gif']['error'] = $this->imageGenerationFailedMessage();
331  }
332 
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;
342  } else {
343  $testResults['png-to-png']['error'] = $this->imageGenerationFailedMessage();
344  }
345 
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;
355  } else {
356  $testResults['gif-to-jpg']['error'] = $this->imageGenerationFailedMessage();
357  }
358 
359  $this->view->assign('testResults', $testResults);
360  return $this->imageTestDoneMessage(GeneralUtility::milliseconds() - $parseTimeStart);
361  }
362 
368  protected function combineImages() {
370  $imageProcessor = $this->initializeImageProcessor();
371  $parseTimeStart = GeneralUtility::milliseconds();
372 
373  $testResults = array(
374  'combine1' => array(),
375  'combine2' => array(),
376  );
377 
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);
385  if ($result) {
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;
390  } else {
391  $testResults['combine1']['error'] = $this->imageGenerationFailedMessage();
392  }
393 
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);
402  if ($result) {
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;
407  } else {
408  $testResults['combine2']['error'] = $this->imageGenerationFailedMessage();
409  }
410 
411  $this->view->assign('testResults', $testResults);
412  return $this->imageTestDoneMessage(GeneralUtility::milliseconds() - $parseTimeStart);
413  }
414 
420  protected function gdlib() {
422  $imageProcessor = $this->initializeImageProcessor();
423  $parseTimeStart = GeneralUtility::milliseconds();
424  $gifOrPng = $imageProcessor->gifExtension;
425  $testResults = array();
426 
427  // GD with simple box
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);
433  $conf = array(
434  'dimensions' => '10,50,150,36',
435  'color' => 'olive',
436  );
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;
445 
446  // GD from image with box
447  $imageProcessor->IM_commands = array();
448  $inputFile = $this->imageBasePath . 'TestInput/Test.' . $gifOrPng;
449  $image = $imageProcessor->imageCreateFromFile($inputFile);
450  $workArea = array(0, 0, 170, 136);
451  $conf = array(
452  'dimensions' => '10,50,150,36',
453  'color' => 'olive',
454  );
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;
463 
464  // GD with text
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);
470  $conf = array(
471  'iterations' => 1,
472  'angle' => 0,
473  'antiAlias' => 1,
474  'text' => 'HELLO WORLD',
475  'fontColor' => '#003366',
476  'fontSize' => 18,
477  'fontFile' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('install') . 'Resources/Private/Font/vera.ttf',
478  'offset' => '17,40',
479  );
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;
489 
490  // GD with text, niceText
491  $testResults['niceText'] = array();
492  if ($this->isImageMagickEnabledAndConfigured()) {
493  // Warning: Re-uses $conf from above!
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\'.'
512  );
513  $testResults['niceText']['message'] = $message;
514  } else {
515  $result['niceText']['error'] = $this->imageGenerationFailedMessage();
516  }
517 
518  // GD with text, niceText, shadow
519  $testResults['shadow'] = array();
520  if ($this->isImageMagickEnabledAndConfigured()) {
521  // Warning: Re-uses $conf from above!
522  $conf['offset'] = '17,90';
523  $conf['niceText'] = 1;
524  $conf['shadow.'] = array(
525  'offset' => '2,2',
526  'blur' => $imageProcessor->V5_EFFECTS ? '20' : '90',
527  'opacity' => '50',
528  'color' => 'black'
529  );
530  // Warning: Re-uses $image from above!
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].'
547  );
548  $testResults['shadow']['message'] = $message;
549  } else {
550  $result['shadow']['error'] = $this->imageGenerationFailedMessage();
551  }
552 
553  $this->view->assign('testResults', $testResults);
554  return $this->imageTestDoneMessage(GeneralUtility::milliseconds() - $parseTimeStart);
555  }
556 
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');
568  return $message;
569  }
570 
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.');
581  return $message;
582  }
583 
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.'
597  );
598  return $message;
599  }
600 
606  protected function getImageConfiguration() {
607  $result = array();
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'];
611  $result['imageMagickVersion'] = $this->determineImageMagickVersion();
612  $result['imageMagick5Effects'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_v5effects'];
613  $result['gdlibEnabled'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'];
614  $result['gdlibPng'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png'];
615  $result['freeTypeDpi'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['TTFdpi'];
616  $result['fileFormats'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'];
617  return $result;
618  }
619 
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;
637  }
638 
644  protected function isImageMagickEnabledAndConfigured() {
645  $enabled = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im'];
646  $path = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path'];
647  return $enabled && $path;
648  }
649 
655  protected function determineImageMagickVersion() {
656  $command = \TYPO3\CMS\Core\Utility\CommandUtility::imageMagickCommand('identify', '-version');
658  $string = $result[0];
659  list(, $version) = explode('Magick', $string);
660  list($version) = explode(' ', trim($version));
661  return trim($version);
662  }
663 
670  protected function setUpDatabaseConnectionMock() {
671  $database = $this->objectManager->get('TYPO3\\CMS\\Install\\Database\\DatabaseConnectionMock');
672  $GLOBALS['TYPO3_DB'] = $database;
673  }
674 }
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&#39;t numeric.
static gif_compress($theFile, $type)
static formatSize($sizeInBytes, $labels='')
$database
Definition: server.php:38
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static exec($command, &$output=NULL, &$returnValue=0)