public function saveAs($filename, $quality = null)
{
if (!$filename) {
throw new Exception('Empty filename to save image');
}
$dir = FS::dirname($filename);
if (is_dir($dir)) {
$this->_save($filename, $quality);
} else {
throw new Exception('Target directory "' . $dir . '" not exists');
}
return $this;
}