class ImageAPIOptimizeProcessorPngCrush in Image Optimize (or ImageAPI Optimize) 7.2
Hierarchy
- class \ImageAPIOptimizeProcessorBinary implements ImageAPIOptimizeProcessorConfigurableInterface
- class \ImageAPIOptimizeProcessorPngCrush implements ImageAPIOptimizeProcessorInterface
Expanded class hierarchy of ImageAPIOptimizeProcessorPngCrush
1 string reference to 'ImageAPIOptimizeProcessorPngCrush'
- imageapi_optimize_imageapi_optimize_processor_info in ./
imageapi_optimize.imageapi_optimize.inc - Implements hook_imageapi_optimize_processor_info().
File
- plugins/
imageapi_optimize/ ImageAPIOptimizeProcessorPngCrush.inc, line 3
View source
class ImageAPIOptimizeProcessorPngCrush extends ImageAPIOptimizeProcessorBinary implements ImageAPIOptimizeProcessorInterface {
protected function executableName() {
return 'pngcrush';
}
public function process($image, $destination) {
$cmd = $this
->getFullPathToBinary();
if (empty($cmd)) {
return FALSE;
}
$dst = $this
->sanitizeFilename($destination);
if ($image->info['mime_type'] == 'image/png') {
$temp = drupal_realpath(drupal_tempnam('temporary://', 'file'));
$options = array(
'-rem alla',
'-reduce',
'-brute',
'-q',
);
$arguments = array(
$dst,
$temp,
);
$option_string = implode(' ', $options);
$argument_string = implode(' ', array_map('escapeshellarg', $arguments));
exec("{$cmd} " . $option_string . ' ' . $argument_string . ' && mv ' . escapeshellarg($temp) . ' ' . escapeshellarg($dst), $output, $return_val);
if ($return_val == 0) {
return TRUE;
}
}
return;
}
}