'SimpleImage.js cloning uploaded image to second canvas

I've been trying to clone the #preview canvas to #upload1 using various methods. I've removed the code I've tested that didn't work but I'm looking for help on a solution that is simple and perhaps re-uses SimpleImage.js' function.

Somethings I've tried:

  • $("canvas")[0].toDataURL() // to try to set the data to a new image
  • creating a copy of the script and re-using the input with different variable names (I think the fileinput.onchange = upload affects this as it throws an error within the console. Any help would be appreciated!

--

    let imgcanvas = document.getElementById("preview");
    let imgcanvasBooking = document.getElementById("upload1");
    let fileinput = document.getElementById("Top-View");
    //let copy = $("canvas")[0].getContext('2d')
    
    fileinput.onchange = upload;
    
    function upload(e) {
      image = new SimpleImage(fileinput);
      image.drawTo(imgcanvas);
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source