You are here

class PngOut in Image Optimize Binaries 8

Uses the PngOut binary to optimize images.

Plugin annotation


@ImageAPIOptimizeProcessor(
  id = "pngout",
  label = @Translation("PngOut"),
  description = @Translation("Uses the PngOut binary to optimize images.")
)

Hierarchy

  • class \Drupal\imageapi_optimize_binaries\ImageAPIOptimizeProcessorBinaryBase extends \Drupal\imageapi_optimize\ConfigurableImageAPIOptimizeProcessorBase
    • class \Drupal\imageapi_optimize_binaries\Plugin\ImageAPIOptimizeProcessor\PngOut

Expanded class hierarchy of PngOut

File

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

Namespace

Drupal\imageapi_optimize_binaries\Plugin\ImageAPIOptimizeProcessor
View source
class PngOut extends ImageAPIOptimizeProcessorBinaryBase {

  /**
   * {@inheritdoc}
   */
  protected function executableName() {
    return 'pngout';
  }
  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;
  }

}

Members