I'm working in a Angular2 v4 app with Typescript and I need a way to download many images (in base64 format) into a Zip file.
For example: I have an array like this (fake base64 images just for example)
data = [
'data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUA ...',
'data:image/png;base64, iVBTYu0KGgoBBBBNSUhYUgJJJJUA ...',
'data:image/png;base64, CGBHHFGY0goAAAANSUhEUgAAAAUA ...',
...
]
I need a way to download it converting each image to a .jpg or .png image first and then compile all images and dowload as a zip file. Something like this (I dont know the code, I just need something like this)
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
}
There is any way to make that?
from Angular 4 Download array of base64 images as ZIP file
No comments:
Post a Comment