1
votes

I know that I can compress using PHP

gzcompress($contents, 9);

But I don't like the results. Even with last version of zlib I get bigger file that output of the 7zip(deflate, of course).

So how to replace gzip headers with zlib headers (with ADLER32 checksum)

1

1 Answers

1
votes

Your question is not clear, but I think you're asking how to take the gzip output of 7zip and convert it to zlib.

You would need to decode the gzip header and strip it off. (It is likely 10 bytes, but it could be longer if it has a file name in it.) RFC 1952 describes the header format. Then you would prepend a two-byte zlib header, e.g. 0x78 0xda.

Then strip the last eight bytes from the end and append a four-byte Adler-32 sum of the uncompressed data in big-endian order. You will need to compute that yourself, where it is described in RFC 1950, or you can adapt the zlib implementation.