Page 1 of 1

6 KB Avitar

Posted: Wed Mar 25, 2015 10:44 pm
by RaptorCIP
How do you compress a picture down to 6 KB to use for an avitar? I reduced the size of mine to 40 x 40 pixels, and can't get a JPEG below 7 KB.

Re: 6 KB Avitar

Posted: Wed Mar 25, 2015 10:53 pm
by AndyD
How are you saving your image. What program are you using? There was a similar question recently on the forum.

Short answer reduce the quality setting until the resulting file is small enough.

Re: 6 KB Avitar

Posted: Wed Mar 25, 2015 11:27 pm
by xoopha
Maybe you can post the image you want as avatar here and see if someone can do anything about it. FWIW I had to save mine as a 128-color GIF for it to drop below 6KB.

Re: 6 KB Avitar

Posted: Wed Mar 25, 2015 11:31 pm
by AndyD
xoopha wrote:FWIW I had to save mine as a 128-color GIF for it to drop below 6KB.
If you are going to indexed colours, you will get better compression from PNG than GIF.

Re: 6 KB Avitar

Posted: Wed Mar 25, 2015 11:40 pm
by xoopha
AndyD wrote:If you are going to indexed colours, you will get better compression from PNG than GIF.
It is generally the case, but not in this one. I used ScriptPNG and ScriptGIF to reduce its size and the gif file was the first one to drop below 6KB with the same color settings, so that's what I used.

Re: 6 KB Avitar

Posted: Wed Mar 25, 2015 11:45 pm
by AndyD
xoopha wrote:
AndyD wrote:If you are going to indexed colours, you will get better compression from PNG than GIF.
It is generally the case, but not in this one. I used ScriptPNG and ScriptGIF to reduce its size and the gif file was the first one to drop below 6KB with the same color settings, so that's what I used.
Have a look at pngcrush.

Re: 6 KB Avitar

Posted: Thu Mar 26, 2015 12:07 am
by xoopha
AndyD wrote:Have a look at pngcrush.
Great, I don't know how the heck did I use ScriptPNG before that it didn't compress the image that much. Now ScriptPNG leaves the image at 4,79KB instead of the 5,55KB of the GIF version. Dunno if I'm using PNGCrush correctly but it leaves it at 4,99KB which is less than the GIF version anyway.

Re: 6 KB Avitar

Posted: Thu Mar 26, 2015 1:52 am
by DavidS
For an small picture like an avatar, there will usualy be less than 64 colors of useful, so simply load it up in !InterGif (in the utilities directory in your RPi RISC OS), and save it out as a 64 color gif using best match pallet, no transparency (unless you want transparent portions).

Does not get any easier than that.

Re: 6 KB Avitar

Posted: Thu Mar 26, 2015 3:20 am
by RaptorCIP
Thanks for the help. The GIF trick got me down to 4500 bytes, but the disk file size on my Mac is still stuck at 8 KB. I'll move the file to my PC and try from there.

Re: 6 KB Avitar

Posted: Thu Mar 26, 2015 4:43 am
by AndyD
xoopha wrote:
AndyD wrote:Have a look at pngcrush.
Great, I don't know how the heck did I use ScriptPNG before that it didn't compress the image that much. Now ScriptPNG leaves the image at 4,79KB instead of the 5,55KB of the GIF version. Dunno if I'm using PNGCrush correctly but it leaves it at 4,99KB which is less than the GIF version anyway.
PNG files are compressed using the DEFLATE algorithm (same as found in zip files and gzip) using zlib. You can choose a compression level in zlib that adjusts the trade-off between time taken and amount of compression (0 - no compression, 9 - use maximum compression). By default the PNG library (libpng) uses compression level 6. The PNG algorithm also has a number of fully reversible filters that may help with the compression of some images. The pngcrush utility can be used to iterate through a number of different filters/compression levels to ascertain which combination give the smallest resulting file.

I am of the opinion that PNG files are (almost) always preferable to GIFs. The PNG specification was born when UNISYS decided to enforce their patent on the LZW compression algorithm as used by GIF, and is superior in almost every way (supports an alpha channel/transparency, not limited to indexed/palette images, supports 16 bits per channel). The only reason to use GIF files at the moment is for simple animation. There are a number of animated avatars on raspberrypi.org that demonstrate this.

Re: 6 KB Avitar

Posted: Thu Mar 26, 2015 7:04 am
by aTao
RaptorCIP wrote:How do you compress a picture down to 6 KB to use for an avitar? I reduced the size of mine to 40 x 40 pixels, and can't get a JPEG below 7 KB.
Sorry, but all I can think is WTF??!?!?!!!!

40 * 40 * 3 = 4800 = 4.7KB

Tried using .bmp ?

Re: 6 KB Avitar

Posted: Thu Mar 26, 2015 10:27 am
by DavidS
RaptorCIP wrote:Thanks for the help. The GIF trick got me down to 4500 bytes, but the disk file size on my Mac is still stuck at 8 KB. I'll move the file to my PC and try from there.
8KB would be the cluster size in your HFS or HFS+ formatted drive then.

Re: 6 KB Avitar

Posted: Thu Mar 26, 2015 10:31 am
by DavidS
aTao wrote:
RaptorCIP wrote:How do you compress a picture down to 6 KB to use for an avitar? I reduced the size of mine to 40 x 40 pixels, and can't get a JPEG below 7 KB.
Sorry, but all I can think is WTF??!?!?!!!!

40 * 40 * 3 = 4800 = 4.7KB

Tried using .bmp ?
I have seen the issue with JPG, some times it is 4 bytes per pixal (32bpp), and there is the header, and it can be multi layer. Though if done for an avatar 8 bpp should be the highest color depth, that could help the OP as well, also flattening it would likely help (if it is multi layer), and geting rid of the extra metadata.