Re: estimate zlib compression ratio?
- From: Ben Rudiak-Gould <br276deleteme@xxxxxxxxx>
- Date: Tue, 24 Apr 2007 18:58:35 +0100
tim.weiler@xxxxxxxxx wrote:
For example, I need to send files over a socket, and some files are
jpegs, which don't compress that well, but other files are large text
documents with good compression ratios. I'd like to selectively
compress the files based on an estimated compression ratio.
Depending on why exactly you want to do this, zlib may already do it for you. If a chunk of data fails to compress, it copies it uncompressed into the output stream (with a short header that says that it's uncompressed). The only reason this wouldn't be good enough is if you need to cut down on CPU usage on the sending side. In that case, aside from what Phil Carmody already suggested, you might do well by simply looking at the file extension, or, if that's not available, the first few bytes of the file. If it starts FF D8 then it's almost certainly a JPEG image.
-- Ben
.
- References:
- estimate zlib compression ratio?
- From: tim . weiler
- estimate zlib compression ratio?
- Prev by Date: Re: Compression test on permutations
- Next by Date: Re: estimate zlib compression ratio?
- Previous by thread: Re: estimate zlib compression ratio?
- Next by thread: Re: estimate zlib compression ratio?
- Index(es):
Relevant Pages
|
|