The aim of this code is to transfer a web image into webMathematica for image manipulation. Since the question here failed to resolve direct URL loading, I tried a different method of extraction involving converting the image to a Base-64 string and passing the data directly to the webMathematica jsp.
Attempting to import a canvas image element Base-64 string into Mathematica fails, with it giving the error
Import::fmterr:
Cannot import data as PNG format
The base-64 text string was exported using the Javascript function:
function convertImageToCanvas(image) {
var canvas = document.createElement("canvas");
canvas.width = image.width;
canvas.height = image.height;
canvas.getContext("2d").drawImage(image, 0, 0);
return canvas;
}
var canv = convertImageToCanvas(document.getElementById("image"));
var dataUrl = canv.toDataURL();
The beginning segment of the data imported is shown:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAAA6CAYAAAD1AhaMAAAgAElEQVR4nKydd3hUZf63n/SemWTSe0iFACGUAIGQMqEjrl3sq64uurqru/7cn1ssYKdKUVBAUVB670iVjrQgINLSe51Mn3Pu948zmZkkoLvv+851fa5hgmZmzjn3+Xzb8yBubv0D1K4DuZ5ff0jd5PqwgmyCul3odxfD7mhFeyJhb4RTh