标签: resemblejs

将图像src传递给函数而不是文件

所以我有一个包含两个图像元素的网页.它基本上是一个上传图像的网站,它使用隐写术加密秘密按摩.我想展示其他方面看不到的区别,我发现了Resemble.js,它是一个比较图像的库.它获取两个文件作为参数,我想使用我的图像源而不是文件,因为我不想保存生成的图像.

总而言之,我想摆脱请求并通过HTML中的源获取我的图像,但我不知道如何使用Resemble.js,因为它只接受文件.

如何生成第二个图像:

cover.src = steg.encode(textarea.value, img, { 
  "width": img.width, 
  "height": img.height
});
Run Code Online (Sandbox Code Playgroud)

使用文件的JavaScript:

(function () {
  var xhr = new XMLHttpRequest();
  var xhr2 = new XMLHttpRequest();
  var done = $.Deferred();
  var dtwo = $.Deferred();

  try {
    xhr.open('GET', 'static/original.png', true);
    xhr.responseType = 'blob';
    xhr.onload = function (e) { done.resolve(this.response); };
    xhr.send();

    xhr2.open('GET', 'static/encoded.png', true);
    xhr2.responseType = 'blob';
    xhr2.onload = function (e) { dtwo.resolve(this.response); };
    xhr2.send();
  } catch (err) {
    alert(err);
  }

  $('#example-images').click(function () {
    $.when(done, dtwo).done(function (file, file1) …
Run Code Online (Sandbox Code Playgroud)

html javascript resemblejs

6
推荐指数
0
解决办法
402
查看次数

标签 统计

html ×1

javascript ×1

resemblejs ×1