Created
June 19, 2013 09:32
-
-
Save addorange/5813017 to your computer and use it in GitHub Desktop.
draw image on canvas and deliver result as base64 to a textarea
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<canvas width='400' height='450' id='canvas'>Ihre Browser ist nicht HTML5-tauglich. Bitte nutzen Sie einen aktuellen Browser.</canvas> | |
<textarea cols="40" rows="8" name="img" id="result"></textarea> | |
<script type="text/javascript"> | |
var canvas = document.getElementById('canvas'); | |
var ctxCanvas = canvas.getContext('2d'); | |
var myImage = new Image(); | |
myImage.src = 'path/to/image'; | |
myImage.onload = function(){ | |
ctxCanvas.drawImage(myImage, 100, 100); | |
document.getElementById('result').innerHTML = canvas.toDataURL(); | |
} | |
</script> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment