N
N
Nikita //2017-03-13 20:57:44
JavaScript
Nikita //, 2017-03-13 20:57:44

How to load third party image in canvas?

It is necessary that the image from input[type='file'] is loaded into the canvas. You can make it so that the first loading occurs in the img tag, and already from img to canvas, no difference.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Peter, 2017-03-13
@thystruby

input - on change
you have a URL in ev.target.result
And then:

var img = new Image;
img.onload = function(){
  canvas.drawImage(img,0,0); 
};
img.src = ev.target.result;

T
trunovalex, 2017-03-13
@trunovalex

as far as i know no

I
Ivan Kuznetsov, 2017-03-13
@meam

https://www.w3schools.com/tags/canvas_drawimage.asp
+
stackoverflow.com/questions/18457340/how-to-previe...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question