You are here

public function PngOut::applyToImage in Image Optimize Binaries 8

Overrides ImageAPIOptimizeProcessorBinaryBase::applyToImage

File

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

Class

PngOut
Uses the PngOut binary to optimize images.

Namespace

Drupal\imageapi_optimize_binaries\Plugin\ImageAPIOptimizeProcessor

Code

public function applyToImage($image_uri) {
  if ($cmd = $this
    ->getFullPathToBinary()) {
    $dst = $this
      ->sanitizeFilename($image_uri);
    if ($this
      ->getMimeType($image_uri) == 'image/png') {
      $options = array();
      $arguments = array(
        $dst,
      );
      return $this
        ->execShellCommand($cmd, $options, $arguments);
    }
  }
  return FALSE;
}