I have an input
element with type=image
:
<input type="image" src="some/url/that/generates/new/image">
I want to load that image into a canvas element. Usually I would do:
var img = new Image();
img.onLoad = function () {
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('2d');
ctx.drawImage(img, 0, 0);
};
img.src = inputElement.src;
However, in this case I can not use the src
attribute because doing so would generate a new image (the src points to a url that generates a new random image).
Any other ideas how to get to that image once its already loaded? In the chrome devtools I can see the image under the "Sources" tab, so its there...
--- edit
I should have mentioned that the html is not under my control, I am writing a chrome extension and I want to save to that image of the input tag (by attaching it to a post request, that already works. I just dont want to generate a new image by using the src attribute)