图片base64转base30

Convert image base64 to base30

我想在数据库中保存签名,但图像 base64 字符串很长(大约 15 000 个字符)有没有将 base64 转换为 base30 的简单解决方案?

这是我的示例,我尝试添加 signaturePad.toDataURL("image/jSignature;base30"); 但无法正常工作。

    var wrapper = document.getElementById("signature-pad"),
    clearButton = wrapper.querySelector("[data-action=clear]"),
    saveButton = wrapper.querySelector("[data-action=save]"),
    canvas = wrapper.querySelector("canvas"),
    signaturePad;

function resizeCanvas() {
    var ratio =  Math.max(window.devicePixelRatio || 1, 1);
    canvas.width = canvas.offsetWidth * ratio;
    canvas.height = canvas.offsetHeight * ratio;
    canvas.getContext("2d").scale(ratio, ratio);
}

window.onresize = resizeCanvas;
resizeCanvas();
alert(canvas);
signaturePad = new SignaturePad(canvas);

//Here get base64 string

saveButton.addEventListener("click", function (event) {

        document.getElementById("signatureDiv").value = signaturePad.toDataURL();
        saveToDB(signaturePad.toDataURL);
    }
});

你想做的是不合格

查看此 link on line toDataURL() method of <\canvas> that mean that the toDataUrlis the canvas method and the first param of the toDataUrl get in witch format to convert to base64 位图。