|
The tar format itself doesn't include compression. It's just a way to get a filesystem in a file (historically, a file suitable for efficient access by non-random access devices such as tape drives - "tar" is a contraction of tape archive).
The GNU tar tool implementation includes the option to compress an archive in the same invocation which makes the .tar file, which results in the same output as making the tar file without compression, and then passing the resultant file though gzip or bzip2 or old-school unix compress.
The degree to which you can compress a tar file with a non-lossy algorithm is dependent on how much redundant data is in the file. For example, if there are lots of repeat characters, or patterns in the file, these can be replaced with descriptions on how to make those chunks of data, which may be shorter than the data itself. For a given data set, there's a minimum size to which you can compress it.
As you can imagine, files which have already been compressed, don't have as much redundant data as those which have not yet been compressed. It turns out that there is a trade off between the amount of processing power and memory you throw at compressing some data and the degree to which you can approach this theoretical limit of compression for the data set. Thus different compression algorithms compress by different amounts - older ones taking the trade-off of using less CPU and memory, but accepting worse compression.
Most image files are already compressed. Some, like PNG or GIF, use lossless compression. Some, like JPG use lossy compression, where some of the data is actually thrown away (bits we hope the human eye doesn't notice so much, like detail in low-contrast areas). In either case, image files are usually compressed already, and so compressing them again doesn't yield much benefit. You might get a few % compression by using a modern algorithm like bzip2 on PNGs or maybe even JPGs, but you're not likely to get more than that.
Basically, the bottom line is that if your tar file contains only pictures, it's probably nor worth compressing it.
It's worthwhile to note here that if you have a tar file which contains compressed files like mo3, ogg, jpg, png, mpg, wmv etc. AND uncompressed data (.txt and so on), compressing the whole tar file will only really yield a benefit for those parts of the file which don't contain pre-compressed data. However, you can't choose to just zip parts of the file, unless you pre-compress it, and don't compress the resultant file. For this, and other reasons, different archiving formats, like dar, can exclude compression for individual files, based on a filename extension.
|