Sign in to follow this  
CRACK123

Reducing a file's size

Recommended Posts

CRACK123    235
Hi, I am trying to take an image file and reduce its size in bytes to maximum amount possible. I tried stripping all unecessary info out and only saving the info like width, height, data. But when I did this to a GIF it increased to 47 kb while the filesize is 32kb on disk. However with a BMP I could get it down to 4kb from 192 kb. So is there something I am doing wrong ? I am even converting the width and height to char to save some bytes. Thanks

Share this post


Link to post
Share on other sites
Oxyd    1162
Quote:
Original post by CRACK123
That neither answers my question nor solves the purpose.


If your question is not about compressing size of file and purpose isn't saving space, then you'll have to explain it cleaner.

Oxyd

Share this post


Link to post
Share on other sites
Drakonite    215
While his answer itself might not have been the solution you wanted, the general idea of his post is the best advice you can get.

Make the filesize smaller by using a format that is smaller. i.e. one that holds only as much detail as you need (8bpp instead of 24bpp perhaps) or is perhaps compressed. Finding the right algorythm makes a much bigger difference than cutting a couple bytes out of a file.

And when you get to as small as you are getting, you'll see a pretty good benefit by combining all your small files into one big resource file so you aren't wasting a bunch of space due to the allocation size of the filesystem.

Share this post


Link to post
Share on other sites
Feidias    92
GIF is already packed while BMP isn't. So using a packer may actually grow the file size of gif. I think the standard packers like pkzip will notice that and leave the file unpacked.

Share this post


Link to post
Share on other sites
iMalc    2466
The gif will be larger because the original was compressed (it uses LZW I believe) and the tools you are using either do not write compressed gif's or were not set up to do so.

Are you trying to achieve lossless compression btw?

Share this post


Link to post
Share on other sites
smart_idiot    1298
You want to reduce the size of an image. If you want to compress it, you're out of luck - all the useful image formats are already compressed. Their data contains virtually no patterns that a file compresser could take advantage of. Your only hope is to use a better file format in the first place. So, to restate my original advice:

Use PNG. (or, if you don't need a perfect 1:1 copy, use jpeg)

And if that wasn't what you were asking, then you did a terrible job of conveying your problem.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this