-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
compress .gif file error #89
Comments
What would happen if you make the following replacements:
The idea is to pass options as an object, like Node.js API docs currently say. |
On the second thought, just |
@Mithgol I think the reason is "DEFLATE" compression error. because if I don't use Thanks! |
Okay, wait a bit. |
I've tested with the following code: var fs = require('fs');
var jsZIP = require('../../');
var zip = new jsZIP();
var fileContent = fs.readFileSync('animated.gif', {encoding: 'base64'});
zip.file('animated.gif', fileContent, {base64: true});
var data = zip.generate({type: 'nodebuffer', compression: 'DEFLATE'});
fs.writeFileSync('animated.zip', data); The file |
I also had a Travis CI test. See the JavaScript code of the test, and animated GIF file, and ZIP archive in my repository, branch See also the Travis CI log where the test passes (lines 898—907). |
The test verifies that the generated ZIP file (on Travis) would be equal (if written) to the contents of the existing file @qlqllu Can you checkout my branch |
Same as @Mithgol, I can't reproduce the issue (using the |
@Mithgol However, I can't use This is the error message:
|
I have an idea of a workaround. Try adding The error messages you've seen ( |
On the second thought, use |
Thank you for your quick response and professional knowledge! My problem is solved! Another small issue:
This code doesn't work:
The error is:
|
That error is caused by JavaScript's operator precedence. The operator It can be worked around by regrouping the operators: var jsZIP = new (require('jszip'))() A more elegant way would be eliminating the need for the Let me see if I can make a pull request for that. |
I've opened the corresponding pull request: #93. You should be able to use |
Looks like this issue is solved. Thanks everyone :) |
Nice to see that your issue has been resolved @qlqllu ! var fileContent = fs.readFileSync("loading.gif");
zip.file('loading.gif', fileContent);
var data = zip.generate({type: 'nodebuffer', compression: 'DEFLATE'});
fs.writeFileSync( 'loading.zip', data); will work and should be faster :) |
@dduponchel |
I've deleted my above mentioned branch: it's no longer necessary after the issue is closed. |
I want to compress a .gif file by using jszip in node js, the code is like this:
The code can run and the zip file can be generated. However, the .gif file can't be decompressed correctly.

The text was updated successfully, but these errors were encountered: