图片流是jiif格式的,直接用a标签会强制打开。
var image = new Image();
image.src =url+"?t=" + new Date().getTime();
image.crossOrigin = "*";
image.onload = function () {
var canvas = document.createElement("canvas");
canvas.width = image.width;
canvas.height = image.height;
var ctx = canvas.getContext("2d");
ctx.drawImage(image, 0, 0, image.width, image.height);
var base64 = canvas.toDataURL("image/png");
var elink = document.createElement("a");
elink.style.display = "none";
elink.download = "";
elink.href = base64;
document.body.appendChild(elink);
elink.click();
URL.revokeObjectURL(elink.href);
document.body.removeChild(elink);
};
|