title: Create HTML image from data in Javascript variable
body: <p>I have image data (either JPEG or PNG) in a Javascript variable. How do I display the image in an HTML document? These are very large images and code like this doesn't work because the URI is too long:</p>
  
  <pre><code>// doesn't work because the URI is too long
  $('img#target').attr('src', 'data:...');
  </code></pre>
  
  <p>Using canvas is probably the answer but I cannot figure out how to load it with the image data.</p>
  
  <p>In case you are wondering: no, I cannot just download the image data directly to the img tag. It came from the server encrypted and was decrypted within the browser using Javascript.</p>
  
  <p>Thanks,<br>
  -- Art Z.</p>