You are here

function imageapi_optimize_binaries_pngcrush in Image Optimize (or ImageAPI Optimize) 7

Pngcrush ImageAPI Optimize binary callback.

File

binaries/pngcrush.inc, line 23
Pngcrush integration.

Code

function imageapi_optimize_binaries_pngcrush($image, $dst, $cmd, $settings) {
  if ($image->info['mime_type'] == 'image/png') {
    $temp = drupal_realpath(drupal_tempnam('temporary://', 'file'));
    exec("{$cmd} -rem alla -reduce -brute -q " . escapeshellarg($dst) . " " . escapeshellarg($temp) . " && mv " . escapeshellarg($temp) . " " . escapeshellarg($dst));
  }
  if (file_exists($temp)) {
    unlink($temp);
  }
}