/**
  * @param TaskInterface $task
  * @return array|null
  */
 protected function process(TaskInterface $task)
 {
     $result = NULL;
     $sourceFile = $task->getOriginalProcessedFile() ?: $task->getSourceFile();
     $sourceFilePath = realpath($sourceFile->getForLocalProcessing(FALSE));
     $targetFilePath = realpath(GeneralUtility::tempnam('_processed_/nlx-tempfile-', '.' . $sourceFile->getExtension()));
     switch ($sourceFile->getExtension()) {
         case 'jpg':
         case 'jpeg':
             if ($this->settings['jpg.']['enabled'] === FALSE) {
                 return $result;
             }
             $library = 'jpegtran';
             $arguments = sprintf('-copy none -optimize %s -outfile %s %s', $this->settings['jpg.']['progressive'] === TRUE ? '-progressive' : '', escapeshellarg($targetFilePath), escapeshellarg($sourceFilePath));
             break;
         case 'png':
             if ($this->settings['png.']['enabled'] === FALSE) {
                 return $result;
             }
             $library = 'optipng';
             $arguments = sprintf('-o%u -strip all -fix -clobber -force -out %s %s', $this->settings['png.']['optimizationLevel'], escapeshellarg($targetFilePath), escapeshellarg($sourceFilePath));
             break;
         case 'gif':
             if ($this->settings['gif.']['enabled'] === FALSE) {
                 return $result;
             }
             $library = 'gifsicle';
             $arguments = sprintf('--batch -O%u -o %s %s', $this->settings['gif.']['optimizationLevel'], escapeshellarg($targetFilePath), escapeshellarg($sourceFilePath));
             break;
         case 'svg':
             if ($this->settings['svg.']['enabled'] === FALSE) {
                 return $result;
             }
             $library = 'svgo';
             $arguments = sprintf('%s %s', escapeshellarg($sourceFilePath), escapeshellarg($targetFilePath));
             break;
         default:
             return $result;
     }
     $cmd = escapeshellcmd($library) . ' ' . $arguments;
     $output = [];
     exec($cmd, $output, $return);
     if ($return === 0) {
         $result = array('filePath' => $targetFilePath);
     }
     return $result;
 }