public function render($filename = null, $format = 'png')
{
$this->create();
if ($format == 'jpg') {
$format = 'jpeg';
}
if (!in_array($format, $this->image_types_available)) {
$format = $this->image_type;
}
if (!function_exists('image' . $format)) {
throw new ImageFunctionUnknownException('QRCode: function image' . $format . ' does not exists.');
}
if ($filename === null) {
$success = call_user_func('image' . $format, $this->image);
} else {
$success = call_user_func_array('image' . $format, array($this->image, $filename));
}
if ($success === false) {
throw new ImageFunctionFailedException('QRCode: function image' . $format . ' failed.');
}
return $this;
}