public function encode()
    {
        if (empty($this->image) === true) {
            throw new \RuntimeException('No source image has been specified.');
        }
        $str = '<img src="data:' . $this->mimeType . ';base64,' . base64_encode($this->image) . '"';
        if (empty($this->extraHtml) === false) {
            $str .= ' ' . trim($this->extraHtml);
        }
        $str .= ' />';
        return $str;
    }