christophlehmann / imageoptimizer

TYPO3 Extension for lossless image optimization with binaries of your choice.
43 stars 22 forks source link

extension not working on typo3 8.6 #9

Closed matin73 closed 7 years ago

matin73 commented 7 years ago

hi,

i installed extension on new typo3 8.6.1 but the extension class are not loaded. so i found 2 bugs:

file ext_conf_templates.txt basic configuration is missing - if optimizeOnUpload = 1 and optimizeAfterProcessing = 1 are not set, $signalSlotDispatcher->connect.... in ext_localconf.php is not running:

cat=basic/Enable Features/300; type=boolean; label=Optimize files on upload: This is useful when you reference original files from fileadmin which don't need to be processed

optimizeOnUpload = 1

cat=basic/Enable Features/400; type=boolean; label=Optimize files after processing: Optimize files which are processed (cropped, scaled, ...).

optimizeAfterProcessing = 1

file ext_localconf.php following seems missing, because an error "connect on null" is shown without: $signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class);

martin

christophlehmann commented 7 years ago

Thanks Martin! it will work in v1.0.3

christophlehmann commented 7 years ago

I uploaded v1.0.3 to TER

matin73 commented 7 years ago

thanks. $signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class); is still missing ... 👍 $configuration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['imageoptimizer']);

if ((isset($configuration['jpgOnUpload']) && (bool)$configuration['jpgOnUpload'] === TRUE) || (isset($configuration['pngOnUpload']) && (bool)$configuration['pngOnUpload'] === TRUE) || (isset($configuration['gifOnUpload']) && (bool)$configuration['gifOnUpload'] === TRUE) || (isset($configuration['svgOnUpload']) && (bool)$configuration['svgOnUpload'] === TRUE)) { $signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class); $signalSlotDispatcher->connect( 'TYPO3\CMS\Core\Resource\ResourceStorage', \TYPO3\CMS\Core\Resource\ResourceStorage::SIGNAL_PreFileAdd, 'Lemming\Imageoptimizer\FileAspects', 'addFile' );

$signalSlotDispatcher->connect(
    'TYPO3\\CMS\\Core\\Resource\\ResourceStorage',
    \TYPO3\CMS\Core\Resource\ResourceStorage::SIGNAL_PreFileReplace,
    'Lemming\\Imageoptimizer\\FileAspects',
    'replaceFile'
);

}

if ((isset($configuration['jpgOnProcessing']) && (bool)$configuration['jpgOnProcessing'] === TRUE) || (isset($configuration['pngOnProcessing']) && (bool)$configuration['pngOnProcessing'] === TRUE) || (isset($configuration['gifOnProcessing']) && (bool)$configuration['gifOnProcessing'] === TRUE)) { $signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class); $signalSlotDispatcher->connect( 'TYPO3\CMS\Core\Resource\ResourceStorage', \TYPO3\CMS\Core\Resource\Service\FileProcessingService::SIGNAL_PostFileProcess, 'Lemming\Imageoptimizer\FileAspects', 'processFile' ); }

if (TYPO3_MODE === 'BE') { $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports']['tx_reports']['status']['providers']['ImageOptimizer'][] = \Lemming\Imageoptimizer\StatusReport::class; }

matin73 commented 7 years ago

i am not shure if there is another bug too in 8.6. extension is writing log: /usr/bin/jpegoptim --strip-all /var/www/vhosts/xxx.at/httpdocs/fileadmin/processed/4/d/csm_wechsler-4_d2c7854842.jpg 2>&1 exited with 0. Output was: /var/www/vhosts/xxx.at/httpdocs/fileadmin/processed/4/d/csm_wechsler-4_d2c7854842.jpg 1815x563 24bit N JFIF [OK] 1696099 --> 1696099 bytes (0.00, skipped. (msg#4.0.32767)

but images are note optimized. if i run shell commands: find . -iname '.png' -print0 | xargs -0 optipng -o7 -preserve find . -iname '.jpg' -print0 | \ xargs -0 jpegoptim --max=90 --strip-all --preserve --totals

images are optimized in avage 60% ...

christophlehmann commented 7 years ago

I fixed the signalSlotDispatcher issue in v1.0.4

I don't see another bug. JPGs in processed folder are not optimized with jpegoptim --strip-all because it is already done by TYPO3 with graphicsmagick/imagemagick.

christophlehmann commented 7 years ago

Thanks for your bug reports. It's now working in 8.6

matin73 commented 7 years ago

so if images are not optimized with jpegoptim --strip-all what is correct parameter for optimize images?

matin73 commented 7 years ago

ah ... i see --max=90 --strip-all %s is working ...