Jump to content
  • Advertisement
Sign in to follow this  
Wutalife37

File Compression

This topic is 4392 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey everyone. I'm working on a 2D game that is about 10MB in size so far. About 8MB of that is hundreds of 3KB GIF graphics for the animations. When I tried to compress the 10MB using winzip, I only got it down to about 8MB. I'm hoping to get it much smaller than that. I did some searching online and found out that PNG is a better choice than GIF (particularly since I'm not using animated GIF's). But I don't think that alone will get my file size any smaller. Is there a better way to losslessly compress my files? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Have you looked at the individual compression ratios? Have you considered joining the individual gif files into a single atlas? That would compress better.

Share this post


Link to post
Share on other sites
The problem here is that your image formats are already compressed.

It is rather difficult to compress what has already been compressed.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Ximmer
The problem here is that your image formats are already compressed.

It is rather difficult to compress what has already been compressed.


Quite true, as a book I have just read put it
Quote:
"Why is it that an already compressed file cannot be compressed further?" The answer, of course, is that such a file has little to no redundancy, so there is nothing to remove. ....Another answer is that if it were possible to compress an already compressed file, then successive compressions would reduce the size of the file until it becomes a single byte, or even a single bit, This, of course, is rediculous since a single byte cannot contain the information present in an arbitrarily large file.


This quote is reffering to lossless compression,such as zip.

Share this post


Link to post
Share on other sites
Quote:
Original post by Fruny
Have you looked at the individual compression ratios? Have you considered joining the individual gif files into a single atlas? That would compress better.


I do believe PNG is superior in general, but I'd like to point out that this advice also holds for PNGs - it can make a *big* difference if your files are all that small.

Also consider variants on zip. A standard zip archive is very wasteful if you have lots of tiny files, even if they aren't pre-compressed files. If making an 'atlas' isn't feasible, consider for example tarring the files first and running gzip on the tar (the .tar.gz combination that is infamous in the Linux world). gzip is perhaps not as sophisticated and it can only archive a single file (hence the *need* to use tar first), but operating on a single file can make a big difference (because files with similar content can be grouped together, more redundancy can be found; zip effectively "restarts" for each file AFAICT). As well, .tar is probably more sparing with metadata than .zip (which IMX adds about 100 bytes plus twice the filename length for each file - and that's if you don't have any folders).

An atlas really is nicer though. Note that you can often reduce the executable size this way too, by removing logic that determines filenames and opens multiple files, replacing it with a little math to find coordinates for each "image". Often this calculation folds into an existing one and costs nothing or almost nothing.

Share this post


Link to post
Share on other sites
RAR compression also offers a mode where all files are effectively concatenated before being compressed.

Share this post


Link to post
Share on other sites
Quote:
Original post by Wutalife37
Is there a better way to losslessly compress my files?

I feel I should point out that GIF encoding is not lossless, in general. Unless the source image is limited to 256 (potentially including the basic 16 colour palette) a new palette will be created (using an optimised median cut) and the image may be dithered.

Original post by Anonymous Poster
Quite true, as a book I have just read put it
Quote:
"Why is it that an already compressed file cannot be compressed further?" The answer, of course, is that such a file has little to no redundancy, so there is nothing to remove. ....Another answer is that if it were possible to compress an already compressed file, then successive compressions would reduce the size of the file until it becomes a single byte, or even a single bit, This, of course, is rediculous since a single byte cannot contain the information present in an arbitrarily large file.
As good as that explanation is, I'm disapointed to read that a published book would propagate such a horrible misspelling of 'ridiculous'. Sorry, I'm a pedant [rolleyes].

Regards
Admiral

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Here's a few tips in making a PNG that contains plenty of animation frames in one: Lay out the animation frames horizontally into the image. Use pngcrush to compress PNG files into smaller, it's a free tool. You could also Google for "gif optimizer" and try out a few of those tools and see if they make a difference for your GIFs.

Share this post


Link to post
Share on other sites
Quote:
Original post by pkelly83
Quote:
Original post by TheAdmiral
I feel I should point out that GIF encoding is not lossless..........


Not entirely correct: True-Color GIF Example. I was suprised to find this out a few weeks ago.
ItsAGIF has been around for years.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!