コード例 #1
0
ファイル: Image.php プロジェクト: grrr-amsterdam/garp3
 /**
  * Optimize images
  *
  * @param array $args
  * @return bool success
  */
 public function optimize($args)
 {
     $imageModel = new Model_Image();
     $pngs = $imageModel->fetchAll($imageModel->select()->from($imageModel->getName(), array('filename'))->where('filename LIKE ?', '%.png'));
     $pngQuant = new Garp_Image_PngQuant();
     if (!$pngQuant->isAvailable()) {
         Garp_Cli::errorOut('I have no business here: pngquant is not available.');
     }
     $gif = new Garp_Image_File();
     foreach ($pngs as $png) {
         $data = $gif->fetch($png->filename);
         $data = $pngQuant->optimizeData($data);
         $gif->store($png->filename, $data, true);
         Garp_Cli::lineOut('Optimized ' . $png->filename);
     }
     Garp_Cli::lineOut('Done.');
 }