You are here

public function JfifRemove::applyToImage in Image Optimize Binaries 8

Overrides ImageAPIOptimizeProcessorBinaryBase::applyToImage

File

src/Plugin/ImageAPIOptimizeProcessor/JfifRemove.php, line 25

Class

JfifRemove
Uses the JfifRemove binary to optimize images.

Namespace

Drupal\imageapi_optimize_binaries\Plugin\ImageAPIOptimizeProcessor

Code

public function applyToImage($image_uri) {
  if ($cmd = $this
    ->getFullPathToBinary()) {
    if ($this
      ->getMimeType($image_uri) == 'image/jpeg') {
      $dst = $this
        ->sanitizeFilename($image_uri);
      $options = array();
      $arguments = array(
        $dst,
      );
      $option_string = implode(' ', $options);
      $argument_string = implode(' ', array_map('escapeshellarg', $arguments));
      return $this
        ->saveCommandStdoutToFile(escapeshellarg($cmd) . ' ' . $option_string . ' < ' . $argument_string, $dst);
    }
  }
  return FALSE;
}