You are here

public function AdvPng::applyToImage in Image Optimize Binaries 8

Overrides ImageAPIOptimizeProcessorBinaryBase::applyToImage

File

src/Plugin/ImageAPIOptimizeProcessor/AdvPng.php, line 26

Class

AdvPng
Uses the AdvPng 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/png') {
      $options = array(
        '--quiet',
      );
      $arguments = array(
        $this
          ->sanitizeFilename($image_uri),
      );
      if ($this->configuration['recompress']) {
        $options[] = '--recompress';
      }
      $options[] = '-' . $this->configuration['mode'];
      return $this
        ->execShellCommand($cmd, $options, $arguments);
    }
  }
  return FALSE;
}