so I have a large image that I'm drawing onto my canvas.
context.drawImage(img, 0, 0, img.width, img.height, 0, 0, canvas.width / 2, canvas.height / 2);
I'm trying to use the images height and width to center it within the canvas, but when I do that, it does not work because img.naturalHeight, clientHeight, and height all give me the original pictures height of more than 5000 pixels. But I instead need the height of the image after its drawn onto the canvas otherwise when I position with 5000 pixels from the left or the top it goes way out of the canvas' viewport.
If anyone has any insight they could share I would be very grateful. Thanks guys!
.drawImage(), the drawn width and height arecanvas.width / 2andcanvas.height / 2because that's what you told the function to size it to.