469,612 Members | 1,616 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,612 developers. It's quick & easy.

GZipStream - compressed files end up larger, sometimes...

KJ
I am using the System.Compression.GZipStream class, and I noticed that
in certain cases, the resultant compressed file is actually larger than
the original. This is almost a constant when compressing
already-compressed formats such as jpeg.

Another less-consistent example of this behavior is found in the case
of compressing TIFFs, wherein some files end up greatly compressed (the
larger ones up to 93% compression ratio) and others end up larger than
the originals.

I have 2 questions:

a) Is there some way to know whether a file will actually compress
*before* perfoming the compression routine (aside from using its file
extension)?

b) Is there a way to gzip a file without doing compression when I know
that performing the compression routine will end up in a larger file?
It seems WinZip is able to do this by adding files to archives without
compressing them.

Thanks in advance.
-KJ

May 30 '06 #1
1 3141


--
William Stacey [MVP]

"KJ" <n_**********@mail.com> wrote in message
news:11**********************@r44g2000cwb.googlegr oups.com...
|I am using the System.Compression.GZipStream class, and I noticed that
| in certain cases, the resultant compressed file is actually larger than
| the original. This is almost a constant when compressing
| already-compressed formats such as jpeg.
|
| Another less-consistent example of this behavior is found in the case
| of compressing TIFFs, wherein some files end up greatly compressed (the
| larger ones up to 93% compression ratio) and others end up larger than
| the originals.
|
| I have 2 questions:
|
| a) Is there some way to know whether a file will actually compress
| *before* perfoming the compression routine (aside from using its file
| extension)?

AFAIK, the algo can't know until the algo actually runs over the data.

| b) Is there a way to gzip a file without doing compression when I know
| that performing the compression routine will end up in a larger file?
| It seems WinZip is able to do this by adding files to archives without
| compressing them.

You could just check the file size, and if bigger, just send the file
instead of adding to a single gz. I don't think you can just do an add
without compression.
--
wjs
May 30 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Craig Buchanan | last post: by
1 post views Thread by Robinson | last post: by
1 post views Thread by hakan.thornqvist | last post: by
2 posts views Thread by DR | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.