首页 > 解决方案 > 如何下载使用 GIF.js 创建的 GIF?

问题描述

我有一个GIF.js GIF,如果我.render()在新窗口中调用 opens,但我找不到有关如何拥有一个允许客户端下载 .gif 文件的简单按钮的文档。有人可以向我解释它是如何工作的吗?

假设我想下载示例 GIF。我该怎么办?

var gif = new GIF({
  workers: 2,
  quality: 10
});

// add a image element
gif.addFrame(imageElement);

// or a canvas element
gif.addFrame(canvasElement, {delay: 200});

// or copy the pixels from a canvas context
gif.addFrame(ctx, {copy: true});

gif.on('finished', function(blob) {
  window.open(URL.createObjectURL(blob));
});

gif.render();

标签: javascriptdownloadgif

解决方案


推荐阅读