Skip to content
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

How to use zopfli DEFLATE in zip archive? #29

Open
GoogleCodeExporter opened this issue Mar 9, 2015 · 5 comments
Open

How to use zopfli DEFLATE in zip archive? #29

GoogleCodeExporter opened this issue Mar 9, 2015 · 5 comments

Comments

@GoogleCodeExporter
Copy link

Hi!
I was wondering if anyone could lend any guidance for how one could use zopfli 
to (re)compress a zip file? I'd like to use it to repack jar files, but I don't 
know of any way to combine the zopfli raw output with the proper headers.

libarchive's bsdtar can produce zip files and use an external compression 
program, but it expects the program to be able to stream from stdin to stdout I 
think.

I tried creating a wrapper (lets call it zopflinout):

#!/bin/sh
zopfli /dev/stdin --deflate -c

... and using

bsdtar -cv --format zip --use-compress-program zopflinout foo.zip *

... but this quickly segfaults and tells me 'Can't write to filter.'


Also (not really related, but...) here is a patch for the makefile to:

- Allow for environmental overrides for compiler variables.
- Build a static library.
- Build a shared library on Darwin.
- Use LDFLAGS.
- Actually use CXXFLAGS when building zopflipng (you have a variable for it but 
don't use it in the target).

... if you want?

Original issue reported on code.google.com by bathtub...@gmail.com on 1 Nov 2013 at 9:26

Attachments:

@GoogleCodeExporter
Copy link
Author

https://code.google.com/p/zopfli/issues/detail?id=31

Original comment by alex.hel...@gmail.com on 18 Jan 2014 at 3:29

@GoogleCodeExporter
Copy link
Author

I agree that Zopfli ought to have .ZIP file support. Currently, when running it 
as a command-line utility, it says that it can output as Gzip format (default), 
DEFLATE format, or ZLib format. So currently, you can use it to (re)compress 
.tar.gz archives, by decompressing them back to .tar archives and then using 
Zopfli to compress to .tar.gz. However, Zopfli doesn't support outputting in 
.ZIP format (although standard PKzip2/InfoZip compatible .ZIP files do use the 
DEFLATE compression codec). Many other types of files, like .JAR files used by 
Java, the OpenDocument files used by MS Office 2007 and later, and many many 
others, are actually renamed .ZIP files. So adding support for (re)compressing 
.ZIP files would allow (re)compressing Java .JAR files, MS Office OpenDocument 
files, and many others.

So my idea for .ZIP support is to add ZIP as a possible output format, and 
either allow for inputting multiple files and/or directories (which would 
require being able to process wildcards and recursively going through 
subdirectories), or, alternatively, inputting a single .ZIP or .TAR or .TAR.GZ 
or whichever format is easiest, and compressing it into a new .ZIP file as the 
output.

Also I don't quite understand how it is supposed to work on .PNG files (if at 
all). The only files I seem to be able to get it to work on (with the 
command-line version) are .gz files, .tar.gz files, and so on. Anyway, I don't 
have any patches to submit to implement this, this is just a feature 
request/help request that is pretty similar to the above one, which is why I'm 
adding it as a comment instead of as a separate bug report. Any comment by the 
developers of Zopfli on how it can be used to implement .ZIP archive format 
compression would also be appreciated (as would implementing said .ZIP support 
in Zopfli's command-line tool).

Original comment by omi...@gmail.com on 15 Feb 2014 at 7:44

@GoogleCodeExporter
Copy link
Author

Gzip is implemented because it is a header of a few bytes around DEFLATE. The 
.ZIP file format uses DEFLATE too but has a lot of features: multiple files, 
directories, encryption, ... that require a dedicated encoder/decoder.

So to implement .ZIP, an existing or new zip encoder can use Zopfli's DEFLATE 
as its compression backend. It's out of scope to implement it here now though.

For PNG, the same is possible: using Zopfli as the DEFLATE/gzip backend of a 
PNG encoder. This has been done several times, including in the repository of 
Zopfli itself 
(https://code.google.com/p/zopfli/source/browse/#git%2Fsrc%2Fzopflipng) as well 
as projects which use other PNG optimizers combined with Zopfli.

Original comment by lode.van...@gmail.com on 30 Jun 2014 at 4:07

@GoogleCodeExporter
Copy link
Author

afaict pigz supports zopfli for zip files

Original comment by alex.hel...@gmail.com on 1 Jul 2014 at 11:05

@GoogleCodeExporter
Copy link
Author

AdvanceCOMP can recompress ZIP files with Zopfli like this:

# advzip --recompress -4 --iter 100 my.jar

http://advancemame.sourceforge.net/doc-advzip.html

Original comment by dajhorn@vanadac.com on 13 Jul 2014 at 3:36

kornelski pushed a commit to ImageOptim/zopfli that referenced this issue Dec 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant