【发布时间】:2019-12-14 08:48:32
【问题描述】:
我正在使用 Typescript 使用 Angular2 v4 应用程序,我需要一种将许多图像(base64 格式)下载到 Zip 文件中的方法。
例如: 我有一个这样的数组(例如假 base64 图像)
data = [
'data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA ...',
'data:image/png;base64, iVBTYu0KGgoBBBBNSUhYUgJJJJUA ...',
'data:image/png;base64, CGBHHFGY0goAAAANSUhEUgAAAAUA ...',
...
]
我需要一种方法来下载它,首先将每个图像转换为 .jpg 或 .png 图像,然后编译所有图像并下载为 zip 文件。像这样的东西(我不知道代码,我只需要这样的东西)
downloadZip() {
const arrayAsJPG = [];
this.data.forEach(i => {
const imageInJpg = i.convertToJPGfile(); // this is not code, this is a function that converts the base64 to a jpg file
arrayAsJPG.push(imageInJpg);
});
ZipFileSaver.save(arrayAsJPG, 'myImageReport.zip'); // this isn't code neither, just and interpretation of what I need
}
有什么办法吗?
【问题讨论】:
-
在浏览器中还是在从您的 Angular 应用程序调用的基于 node.js 的服务器函数中?
标签: angular image typescript download zip