title: HTML5 - scaled image is blurry when drawn on canvas in chrome & opera
body: <p>When i draw scaled image on canvas using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawImage" rel="nofollow noreferrer">drawImage()</a> function it looks slightly blurry in Chrome &amp; Opera, but if i draw the full size image first and then the scaled one it looks crisp. What causes the blurriness and how can i fix it?</p>
  
  <p>Here is the original image:
  <a href="https://i.stack.imgur.com/eWDSw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eWDSw.png" alt="enter image description here"></a></p>
  
  <p>Here is the result in Chrome &amp; Opera:
  <a href="https://i.stack.imgur.com/zuLup.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zuLup.png" alt="enter image description here"></a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const img = new Image();
  
  const crisptCanvas = document.getElementById('crisp-canvas');
  const crispContext = crisptCanvas.getContext('2d');
  
  const blurryCanvas = document.getElementById('blurry-canvas');
  const blurryContext = blurryCanvas.getContext('2d');
  
  const sx = 0, sy = 0, sWidth = 1980, sHeight = 1251;
  const dx = 0, dy = 0;
  const scaleFactor = 0.4762626262626263;
  
  // Draw an image on canvas
  function scaleImage(scale, context)
  {
   const dWidth = (sWidth*scale);
   const dHeight = (sHeight*scale);
   context.drawImage(img, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
  };
          
  // When image is loaded draw it on both canvases
  img.onload = function(){
  
   // First draw the source image in full scale and then using the -scaleFactor
   setTimeout(()=&gt; {
    scaleImage(1, crispContext);
    scaleImage(scaleFactor, crispContext);
   }, 0);
  
   // Draw the image using the -scaleFactor
   scaleImage(scaleFactor, blurryContext); 
  }
  
  img.src = "https://i.stack.imgur.com/eWDSw.png"</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;canvas width="944" height="596" id="crisp-canvas" &gt;&lt;/canvas&gt;
  &lt;canvas width="944" height="596" id="blurry-canvas" &gt;&lt;/canvas&gt;</code></pre>
  </div>
  </div>
  </p>