Is there a way to read HTML Canvas content as binary data?
At the moment, I have the following HTML to show the input file and the canvas below it:
<p><button id="myButton" type="button">Get Image Content</button></p> <p>Input:<input id="fileInput" type="file"/></p> <p>Canvas<canvas id="myCanvas" width="578" height="200"/></p>
Then I installed my input file to set the canvas correctly, which works fine:
$('#fileInput').on('change', function() { $.each(this.files, function() { var image = new Image(); image.src = window.URL.createObjectURL(this); image.onload = function() { $("canvas").drawImage({ source: image, x: 50, y: 50, width: 100, fromCenter: false }); }; }); });
Now I need to get the binary data (Base64 encoded) from Canvas when the button is pressed so that it moves the data to the server ...
The end result is that I need to give the user the ability to select a file, crop / resize it, and then click the button, after which the edited image will be uploaded to the server (I cannot do server cropping / resizing due to server-side restrictions ...)
Any help would be great! Greetings
javascript html5 html5-canvas fileapi
Jamz_2010 Mar 28 '13 at 15:22 2013-03-28 15:22
source share