Ad

TYPO3 V10 Image Processing In Backend Environment

- 1 answer

We recently started our first TYPO3 10 project and are currently struggling with a custom import script that moves data to Algolia. Basically, everything works fine, but there is an issue with FAL images, specifically, when they need to be processed.

From the logs, I could find something called DeferredBackendImageProcessor, but the docs are not mentioning this, or I am not looking for the right thing. I'm not sure.

Apparently, images within the backend environment are not just processed anymore. There is something called "processingUrl" which has to be called once for the image to be processed.

I tried calling that url with CURL, but it does not work. The thing is, when I open that "processingUrl" in the browser, it has not effect - but if I open that link in a browser, where I am logged into the TYPO3 backend, then the image is processed.

I'm kind of lost here, as I need the images to be processed within the import script that runs via the scheduler from the backend (manual, not via cron).

That is the function where the problem occurs, the curl part has no effect here, sadly.

protected function processImage($image, $imageProcessingConfiguration)
{
    if ($image) {
        $scalingOptions = array (
            'width' => 170
        );
                
        $result = $this->contentObject->getImgResource('fileadmin/'.$image, $scalingOptions);
                
        if (isset($result[3]) && $result[3]) {
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $result[3]);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            $output = curl_exec($ch);
            curl_close($ch);
                    
            return '/fileadmin'.$result['processedFile']->getIdentifier();
        }
    }
            
    return '';
}

$result[3] being the processing url. Example of the url:

domain.com/typo3/index.phproute=%2Fimage%2Fprocess&token=6cbf8275c13623a0d90f15165b9ea1672fe5ad74&id=141

So my question is, how can I process the image from that import script?

Ad

Answer

I am not sure if there is a more elegant solution but you could disable the deferred processing during your jobs:

$processorConfiguration = $GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['processors']
unset ($GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['processors']['DeferredBackendImageProcessor'])

// ... LocalImageProcessor will be used

$GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['processors'] = $processorConfiguration;

References:

Ad
source: stackoverflow.com
Ad