Created
April 22, 2020 03:07
-
-
Save Jagathishrex/b58db65193c71d8f85d6b5e20b94495c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // image as dataURL | |
| let jpeg = canvas.toDataURL('image/jpg'); // 0.92 | |
| let webp = canvas.toDataURL('image/webp', 0.5); | |
| //zip | |
| let jsZip = new JSZip(); | |
| let folder = jsZip.folder("images"); | |
| let baseString = getBase64String(jpeg); | |
| folder.file("image1.jpeg", baseString, {base64 : true}); | |
| let baseString2 = getBase64String(webp); | |
| folder.file("image2.webp", baseString2, {base64 : true}); | |
| Generate the zip file | |
| zip.generateAsync({type:"blob"}).then(function (content) { | |
| content = URL.createObjectURL(content); | |
| let name = `JSJeep.zip`; | |
| download(content, name); // already written above | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment