protected function _renderImageByFormat($format, $filename, $quality)
{
if (!$this->_image) {
throw new Exception('Image resource not defined');
}
$format = $format ?: $this->_mime;
$result = false;
if (Helper::isJpeg($format)) {
if ($this->_saveJpeg($filename, $quality)) {
$result = 'image/jpeg';
}
} elseif (Helper::isPng($format)) {
if ($this->_savePng($filename, $quality)) {
$result = 'image/png';
}
} elseif (Helper::isGif($format)) {
if ($this->_saveGif($filename)) {
$result = 'image/gif';
}
} else {
throw new Exception('Undefined format: ' . $format);
}
return $result;
}