hello,
I have developed a file compression tool using zlib compression library. As the zlib use the deflate and inflate process, does the size of the file effect compression ratio?
If it has effect, what is the reason?
Thank you.
hello,
I have developed a file compression tool using zlib compression library. As the zlib use the deflate and inflate process, does the size of the file effect compression ratio?
If it has effect, what is the reason?
Thank you.
not really, no.
Of course you need enough data in the original file to be able to compress it at all.
A 1 byte file for example can't be compressed.
Apart from that, the compression algorithm might add more overhead in markers and stuff to the compressed file than it removes by compressing the orignal data.
That however is independent of file size, can happen with any size input (but might be more readily apparent with small input files than with large ones on average).
According to your opinion, It means that as the file size increase the compression ratio will also increase(A common understanding).
I don't know zlib, but most compression algorithms have these properties:
(Const+Ratio*Length)/Length
approaches Ratio
from above as Length
increases.According to your opinion, It means that as the file size increase the compression ratio will also increase(A common understanding).
No, you read me wrong.
And that "common understanding" (if it exists) is also wrong.
While most algorithms may become more efficient with more data to handle, that's only up to a point.
For the first few kilobytes of data for example they might become slightly more efficient, then reach their limit.
But that doesn't mean all larger files compress better than all smaller files given the same algorithm (or even in general).
A 1kb file containing plain text and all the same ASCII code for example will compress very well using most algorithms. A 1kb JPEG image otoh will likely not compress at all (and may even expand in size) when compression is attempted (this of course due to the fact that it's already compressed as part of the JFIF algorithm that created the file content).
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.