I have Monitor with resolution 1920 * 1080.
I am trying this very basic canvas drawimage() code on my PC.
<!DOCTYPE html>
<html>
<body>
<p>Image to use:</p>
<img id="scream" width="220" height="277"
src="test.jpg" alt="The Scream">
<p>Canvas:</p>
<canvas id="myCanvas" width="240" height="297"
style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.
</canvas>
<script>
window.onload = function() {
var canvas = document.getElementById("myCanvas");
var ctx = canvas.getContext("2d");
var img = document.getElementById("scream");
ctx.drawImage(img, 10, 10);
};
</script>
</body>
</html>
So I am getting output like this:
Actually output should be same as original image, but it's not.
After going through similar questions on stackoverflow and http://developer.mozilla.org, I understood that it has something to do with height and width.
How to use drawimage() properly for any screen size or device?
Edit: The test image dimensions are 3024 * 4032
I am trying to implement crop and save functionality using following plugin : http://odyniec.net/projects/imgareaselect/
So whatever height and width coordinates will be returned from there, I will crop that image from original and will draw on canvas.
Therefore the cropped image must be with actual resolution but displayed in smaller preview container.