jszip icon indicating copy to clipboard operation
jszip copied to clipboard

zipped file with same size of original file

Open mikeiasNS opened this issue 7 years ago • 5 comments

my code: var zip = new JSZip(); zip.file('test.wav', blob); zip.generateAsync({type:"base64"}).then(function (base64) { window.location = "data:application/zip;base64," + base64; }, function (err) { console.log(err); });

mikeiasNS avatar Feb 09 '18 19:02 mikeiasNS

WAV files are a wrapper file type that can encompass different audio formats that include compression. Most likely the test.wav file is already compressed to a point where zip cannot make much headway on compressing the data any further. See: https://en.wikipedia.org/wiki/WAV

colbygk avatar Feb 13 '18 15:02 colbygk

test.wav is a recorded audio that originally was a PCM and then the wav header is added to... so, i'm sure that it is not compressed yet.

mikeiasNS avatar Feb 13 '18 15:02 mikeiasNS

zip.generateAsync({ type: "blob", compression: "DEFLATE", compressionOptions: { level: 9 } })

No?

PS with WAV no chances

dvdobrovolskiy avatar Mar 25 '18 23:03 dvdobrovolskiy

@dvdobrovolskiy thanks a lot! That is what actually does compression. The examples on the website just create zip and no compression at all.

chinchang avatar Jun 29 '18 07:06 chinchang

I would suggest changing the examples to default to compression, if not the API itself.

I think most users would expect creating a zip file to do compression by default, as they would when creating a zip file through something like windows or 7zip does.

With such ease of integration, I suspect many users make this same mistake and never actually check the size of the file to ensure it is compresed. Here is an example of another user who had the same issue on stack overflow: https://stackoverflow.com/questions/57866209/compressed-file-in-jszip-is-bigger-than-uncompressed-content/

I think having the examples on the website use compression would make users more likely to do what they want, and it is also more clear what is happening, since it clearly specifies that it is compresing. So if a user DOESN'T want compression they could remove or change the params.

tigger0jk avatar Sep 10 '19 13:09 tigger0jk