【问题标题】:phantomjs and chrome return different data when calling canvas.toDataURLphantomjs 和 chrome 在调用 canvas.toDataURL 时返回不同的数据
【发布时间】:2014-01-03 23:39:30
【问题描述】:

我正在使用画布裁剪图像

function crop(img) {
    var canvas = document.createElement("canvas");
    canvas.width = 20;
    canvas.height = 20;
    var context = canvas.getContext('2d');
    context.drawImage(img, 0, 0, 20, 20, 0, 0, 20, 20);
    return canvas.toDataURL();
}

但是,当我比较 Chrome 和 PhantomJs 返回的 base64 数据时,我注意到它们是不同的。有谁知道这是为什么?

【问题讨论】:

  • img 设置在哪里?
  • 在这种情况下我使用 gif(输入也是 base64)

标签: javascript google-chrome canvas base64 phantomjs


【解决方案1】:

这是一个 Phantomjs 问题,并且有一个可行的解决方案。看看这个: https://github.com/ariya/phantomjs/issues/10455

【讨论】:

    猜你喜欢
    • 2015-07-16
    • 2020-11-24
    • 2019-07-31
    • 1970-01-01
    • 2019-10-31
    • 2021-06-30
    • 2018-02-11
    • 1970-01-01
    相关资源
    最近更新 更多