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;
    }