library/Garp/Image/PngQuant.php
public function optimizeData($data) {
        if (!$this->isPngData($data)) {
            return $data;
        }
        
        //  store data in a temporary file to feed pngquant
        $sourcePath = $this->_getNewTempFilePath();
        $this->_store($sourcePath, $data);
        
        //  run pngquant on temporary file
        $this->_createOptimizedFile($sourcePath);
        
        //  retrieve data from optimized file
        $optimizedFilePath  = $this->_getOptimizedFilePath($sourcePath);
        $optimizedData      = $this->_fetchFileData($optimizedFilePath);
        
        //  verify data
        $this->_verifyData($optimizedData);

        unlink($sourcePath);
        unlink($optimizedFilePath);
        
        return $optimizedData;
    }
public function optimizeData($data) {
        if (!$this->isPngData($data)) {
            return $data;
        }
        
        //  store data in a temporary file to feed pngquant
        $sourcePath = $this->_getNewTempFilePath();
        $this->_store($sourcePath, $data);
        
        //  run pngquant on temporary file
        $this->_createOptimizedFile($sourcePath);
        
        //  retrieve data from optimized file
        $optimizedFilePath  = $this->_getOptimizedFilePath($sourcePath);
        $optimizedData      = $this->_fetchFileData($optimizedFilePath);
        
        //  verify data
        $this->_verifyData($optimizedData);

        unlink($sourcePath);
        unlink($optimizedFilePath);
        
        return $optimizedData;
    }
public function optimizeData ( $ data ) { if ( ! $ this -> isPngData ( $ data ) ) { return $ data ; } //  store data in a temporary file to feed pngquant $ sourcePath = $ this -> _getNewTempFilePath ( ) ; $ this -> _store ( $ sourcePath , $ data ) ; //  run pngquant on temporary file $ this -> _createOptimizedFile ( $ sourcePath ) ; //  retrieve data from optimized file $ optimizedFilePath = $ this -> _getOptimizedFilePath ( $ sourcePath ) ; $ optimizedData = $ this -> _fetchFileData ( $ optimizedFilePath ) ; //  verify data $ this -> _verifyData ( $ optimizedData ) ; unlink ( $ sourcePath ) ; unlink ( $ optimizedFilePath ) ; return $ optimizedData ; }
Optimizes PNG data. If this is not a PNG, the original data is returned.
@param   String  $data   Binary image data
@return  String  $data   Optimized binary image data
Optimizes PNG data . If this is not a PNG the original data is returned .