Problem
I've placed the same image (Netflix) using simple HTML vs using Canvas, and the Canvas version is a lot more pixelated that the simple tag version.
What I've tried
- I've tried changing the scale of the Canvas and setting the
window.pixelDeviceRatio = 2
and it does improve it slightly, but still seems pixelated. - I've also tried setting
context.imageSmoothingEnabled= false
, but that didn't change anything. - Setting the
context.smoothImageQuality = high
, check the photo below to see how that looks
Please let me know if you have any idea how I could fit it!
window.onload = () => {
var dpi = window.devicePixelRatio;
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
var imgLogo = document.getElementById("logo");
context.imageSmoothingEnabled = false;
context.drawImage(imgLogo, 0, 0, 175, 98.438);
}
.hidden {
display: none;
}
<img class = "hidden" id = "logo" src = "https://assets.stickpng.com/images/580b57fcd9996e24bc43c529.png" width="200"/>
<canvas id = "myCanvas" height = "150" width = "500">
</canvas>
<div class="blend1">
<div id="logoContainer">
<img src="https://assets.stickpng.com/images/580b57fcd9996e24bc43c529.png" width="175" />
</div>
</div>