public function getProcessedFileName($fileName, \TYPO3\CMS\Core\Authentication\BackendUserAuthentication $backendUser = null, array $ruleset = null)
    {
        if ($ruleset === null) {
            $ruleset = $this->getRuleset($fileName, $fileName, $backendUser);
        }

        if (count($ruleset) === 0) {
            // File does not match any rule set
            return null;
        }

        if ($backendUser === null && count($ruleset['usergroup']) > 0) {
            // Rule set is targeting some user group but we have no backend user (scheduler task)
            // so we should skip this file altogether
            return null;
        }

        // Extract the extension
        if (($dotPosition = strrpos($fileName, '.')) === false) {
            // File has no extension
            return null;
        }
        $fileExtension = strtolower(substr($fileName, $dotPosition + 1));

        if ($fileExtension === 'png' && !$ruleset['resize_png_with_alpha']) {
            if (file_exists($fileName) && ImageUtility::isTransparentPng($fileName)) {
                return null;
            }
        }

        if ($fileExtension === 'gif' && file_exists($fileName) && ImageUtility::isAnimatedGif($fileName)) {
            return null;
        }

        if (isset($ruleset['conversion_mapping'][$fileExtension])) {
            // File format will be converted
            $destExtension = $ruleset['conversion_mapping'][$fileExtension];
            $destDirectory = PathUtility::dirname($fileName);
            $destFileName = PathUtility::basename(substr($fileName, 0, strlen($fileName) - strlen($fileExtension)) . $destExtension);

            $fileName = $destDirectory . '/' . $destFileName;
        }

        return $fileName;
    }
public function getProcessedFileName($fileName, \TYPO3\CMS\Core\Authentication\BackendUserAuthentication $backendUser = null, array $ruleset = null)
    {
        if ($ruleset === null) {
            $ruleset = $this->getRuleset($fileName, $fileName, $backendUser);
        }

        if (count($ruleset) === 0) {
            // File does not match any rule set
            return null;
        }

        if ($backendUser === null && count($ruleset['usergroup']) > 0) {
            // Rule set is targeting some user group but we have no backend user (scheduler task)
            // so we should skip this file altogether
            return null;
        }

        // Extract the extension
        if (($dotPosition = strrpos($fileName, '.')) === false) {
            // File has no extension
            return null;
        }
        $fileExtension = strtolower(substr($fileName, $dotPosition + 1));

        if ($fileExtension === 'png' && !$ruleset['resize_png_with_alpha']) {
            if (file_exists($fileName) && ImageUtility::isTransparentPng($fileName)) {
                return null;
            }
        }

        if ($fileExtension === 'gif' && file_exists($fileName) && ImageUtility::isAnimatedGif($fileName)) {
            return null;
        }

        if (isset($ruleset['conversion_mapping'][$fileExtension])) {
            // File format will be converted
            $destExtension = $ruleset['conversion_mapping'][$fileExtension];
            $destDirectory = PathUtility::dirname($fileName);
            $destFileName = PathUtility::basename(substr($fileName, 0, strlen($fileName) - strlen($fileExtension)) . $destExtension);

            $fileName = $destDirectory . '/' . $destFileName;
        }

        return $fileName;
    }
Returns the resized/converted file name (no actual processing).

@param string $fileName
@param \TYPO3\CMS\Core\Authentication\BackendUserAuthentication|null $backendUser
@param array $ruleset The optional ruleset to use
@return string|null Eiter null if no resize/conversion should take place or the resized/converted file name