0
votes

I have the following problem: I'm using zlib in C to gzip files. The compressing (using z_stream, deflateInit2...) is no problem, but I need to know the size of the gziped file before I compress it. Is this possible or is the only option I have to count the bytes while compressing? Thanks in advance!

1
Why do you need to know the compressed size before compressing?Mark Adler

1 Answers

2
votes

but I need to know the size of the gziped file before I compress it

If you mean that you need it to compress (perhaps to allocate a buffer to hold the data), then you are mistaking, the whole point of z_stream is to let you compress input chunks in output chunks.

is the only option I have to count the bytes while compressing

Yes, you need to apply the compression algorithm to know the resulting size.