Premesso che è mille volte meglio farlo con php...
codice:
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Esempio per il forum di HTML.it</title>
<script type="text/javascript">
var oCanvas = document.createElement("canvas"), oCtx = oCanvas.getContext("2d");
function loadImage (sURL, fCallback) {
var oImage = new Image();
oImage.src = sURL;
oImage.onload = function () {
document.body.appendChild(this);
oCanvas.width = this.offsetWidth;
oCanvas.height = this.offsetHeight;
oCtx.drawImage(this, 0, 0);
document.body.removeChild(this);
fCallback.call(this, oCanvas.toDataURL());
};
}
</script>
</head>
<body onload="loadImage('dopo_la_manovra.jpg', function(stringa) { alert(stringa) });">
</body>
</html>
N.B. Può darsi che non ti funzioni in locale, ma solo se messa online!