99 * LICENSE.txt file that was distributed with this source code.
1010 */
1111
12- use TYPO3 \CMS \Core \Configuration \Features ;
1312use TYPO3 \CMS \Core \SingletonInterface ;
13+ use TYPO3 \CMS \Core \Utility \ExtensionManagementUtility ;
1414use TYPO3 \CMS \Core \Utility \GeneralUtility ;
15+ use TYPO3 \CMS \Core \Utility \StringUtility ;
1516use WapplerSystems \ZabbixClient \Attribute \MonitoringOperation ;
17+ use WapplerSystems \ZabbixClient \Imaging \GraphicalFunctions ;
1618use WapplerSystems \ZabbixClient \OperationResult ;
1719
1820
@@ -32,9 +34,38 @@ class HasIPTCPreservation implements IOperation, SingletonInterface
3234 */
3335 public function execute (array $ parameter = []): OperationResult
3436 {
35- if (isset ($ GLOBALS ['TYPO3_CONF_VARS ' ]['GFX ' ]['processor_stripColorProfileParameters ' ])) {
36- return new OperationResult (true , (bool )array_search ('!iptc ' , $ GLOBALS ['TYPO3_CONF_VARS ' ]['GFX ' ]['processor_stripColorProfileParameters ' ] ?? []) !== false );
37+ $ imageBasePath = ExtensionManagementUtility::extPath ('zabbix_client ' ) . 'Resources/Private/TestInput/ ' ;
38+ $ imageProcessor = $ this ->initializeImageProcessor ();
39+ $ inputFile = $ imageBasePath . 'TestIPTC.jpg ' ;
40+ $ imageProcessor ->imageMagickConvert_forceFileNameBody = StringUtility::getUniqueId ('iptc ' );
41+ $ imResult = $ imageProcessor ->imageMagickConvert ($ inputFile , 'jpg ' , '200 ' , '' , '' , '' , [], true );
42+ if ($ imResult !== null && file_exists ($ imResult [3 ])) {
43+ $ metaData = $ imageProcessor ->imageMagickMetadata ($ imResult [3 ]);
44+ unlink ($ imResult [3 ]);
45+ foreach ($ metaData as $ value ) {
46+ if (str_contains ($ value , 'Test-Image ' )) {
47+ return new OperationResult (true , true );
48+ }
49+ }
3750 }
38- return new OperationResult (true , strpos ( $ GLOBALS [ ' TYPO3_CONF_VARS ' ][ ' GFX ' ][ ' processor_stripColorProfileCommand ' ] ?? '' , ' !iptc ' ) !== false );
51+ return new OperationResult (true , false );
3952 }
53+
54+
55+ /**
56+ * Initialize image processor
57+ *
58+ * @return GraphicalFunctions Initialized image processor
59+ */
60+ protected function initializeImageProcessor (): GraphicalFunctions
61+ {
62+ $ imageProcessor = GeneralUtility::makeInstance (GraphicalFunctions::class);
63+ $ imageProcessor ->dontCheckForExistingTempFile = true ;
64+ $ imageProcessor ->filenamePrefix = 'zabbixClient- ' ;
65+ $ imageProcessor ->dontCompress = true ;
66+ $ imageProcessor ->alternativeOutputKey = 'zabbixClienTest ' ;
67+ $ imageProcessor ->setImageFileExt (['gif ' , 'jpg ' , 'png ' , 'tif ' , 'ai ' , 'pdf ' , 'webp ' ]);
68+ return $ imageProcessor ;
69+ }
70+
4071}
0 commit comments