Classes/Task/BatchResizeTask.php
protected function batchResizePictures($directory)
    {
        $directory = GeneralUtility::getFileAbsFileName($directory);
        // Check if given directory exists
        if (!@is_dir($directory)) {
            throw new \RuntimeException('Given directory "' . $directory . '" does not exist', 1384102984);
        }

        $allFileTypes = $this->imageResizer->getAllFileTypes();

        // We do not want to pass any backend user, even if manually running the task as administrator from
        // the Backend as images may be resized based on usergroup rule sets and this should only happen when
        // actually resizing the image while uploading, not during a batch processing (it's simply "too late").
        $backendUser = null;

        if ($GLOBALS['BE_USER']->isAdmin()) {
            // As the scheduler user should never be an administrator, if current user is an administrator
            // the task is most probably run manually from the Scheduler module, so just show notifications
            $callbackNotification = [$this, 'notify'];
        } else {
            $callbackNotification = [$this, 'syslog'];
        }

        $excludeDirectories = GeneralUtility::trimExplode(LF, $this->excludeDirectories, true);

        $directoryContent = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory));
        foreach ($directoryContent as $fileName => $file) {
            $filePath = $file->getPath();
            $name = substr($fileName, strlen($filePath) + 1);

            // Skip files in recycler directory or whose type should not be processed
            $skip = $name{0} === '.' || substr($filePath, -10) === '_recycler_';
            // Skip exclude directories
            foreach ($excludeDirectories as $excludeDirectory) {
                $excludeDirectory = GeneralUtility::getFileAbsFileName($excludeDirectory);
                if (GeneralUtility::isFirstPartOfStr($filePath, $excludeDirectory) ||
                    rtrim($excludeDirectory, '/') === $filePath
                ) {
                    $skip = true;
                    continue;
                }
            }

            if (!$skip) {
                if (($dotPosition = strrpos($name, '.')) !== false) {
                    $fileExtension = strtolower(substr($name, $dotPosition + 1));
                    if (in_array($fileExtension, $allFileTypes)) {
                        $this->imageResizer->processFile(
                            $fileName,
                            '',    // target file name
                            '',    // target directory
                            null,
                            $backendUser,
                            $callbackNotification
                        );
                    }
                }
            }
        }

        return true;
    }
protected function batchResizePictures($directory)
    {
        $directory = GeneralUtility::getFileAbsFileName($directory);
        // Check if given directory exists
        if (!@is_dir($directory)) {
            throw new \RuntimeException('Given directory "' . $directory . '" does not exist', 1384102984);
        }

        $allFileTypes = $this->imageResizer->getAllFileTypes();

        // We do not want to pass any backend user, even if manually running the task as administrator from
        // the Backend as images may be resized based on usergroup rule sets and this should only happen when
        // actually resizing the image while uploading, not during a batch processing (it's simply "too late").
        $backendUser = null;

        if ($GLOBALS['BE_USER']->isAdmin()) {
            // As the scheduler user should never be an administrator, if current user is an administrator
            // the task is most probably run manually from the Scheduler module, so just show notifications
            $callbackNotification = [$this, 'notify'];
        } else {
            $callbackNotification = [$this, 'syslog'];
        }

        $excludeDirectories = GeneralUtility::trimExplode(LF, $this->excludeDirectories, true);

        $directoryContent = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory));
        foreach ($directoryContent as $fileName => $file) {
            $filePath = $file->getPath();
            $name = substr($fileName, strlen($filePath) + 1);

            // Skip files in recycler directory or whose type should not be processed
            $skip = $name{0} === '.' || substr($filePath, -10) === '_recycler_';
            // Skip exclude directories
            foreach ($excludeDirectories as $excludeDirectory) {
                $excludeDirectory = GeneralUtility::getFileAbsFileName($excludeDirectory);
                if (GeneralUtility::isFirstPartOfStr($filePath, $excludeDirectory) ||
                    rtrim($excludeDirectory, '/') === $filePath
                ) {
                    $skip = true;
                    continue;
                }
            }

            if (!$skip) {
                if (($dotPosition = strrpos($name, '.')) !== false) {
                    $fileExtension = strtolower(substr($name, $dotPosition + 1));
                    if (in_array($fileExtension, $allFileTypes)) {
                        $this->imageResizer->processFile(
                            $fileName,
                            '',    // target file name
                            '',    // target directory
                            null,
                            $backendUser,
                            $callbackNotification
                        );
                    }
                }
            }
        }

        return true;
    }
Batch resizes pictures in a given parent directory (including all subdirectories
recursively).

@param string $directory
@return boolean true if run was successful
@throws \RuntimeException