RaptorCIP
Posts: 4
Joined: Tue Mar 24, 2015 8:46 pm
Location: USA

6 KB Avitar

Wed Mar 25, 2015 10:44 pm

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.

User avatar
AndyD
Posts: 2333
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

Re: 6 KB Avitar

Wed Mar 25, 2015 10:53 pm

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.

User avatar
xoopha
Posts: 106
Joined: Mon Feb 09, 2015 9:52 pm

Re: 6 KB Avitar

Wed Mar 25, 2015 11:27 pm

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.

User avatar
AndyD
Posts: 2333
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

Re: 6 KB Avitar

Wed Mar 25, 2015 11:31 pm

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.

User avatar
xoopha
Posts: 106
Joined: Mon Feb 09, 2015 9:52 pm

Re: 6 KB Avitar

Wed Mar 25, 2015 11:40 pm

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.

User avatar
AndyD
Posts: 2333
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

Re: 6 KB Avitar

Wed Mar 25, 2015 11:45 pm

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.

User avatar
xoopha
Posts: 106
Joined: Mon Feb 09, 2015 9:52 pm

Re: 6 KB Avitar

Thu Mar 26, 2015 12:07 am

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.

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: 6 KB Avitar

Thu Mar 26, 2015 1:52 am

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.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

RaptorCIP
Posts: 4
Joined: Tue Mar 24, 2015 8:46 pm
Location: USA

Re: 6 KB Avitar

Thu Mar 26, 2015 3:20 am

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.

User avatar
AndyD
Posts: 2333
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

Re: 6 KB Avitar

Thu Mar 26, 2015 4:43 am

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.

User avatar
aTao
Posts: 1087
Joined: Wed Dec 12, 2012 10:41 am
Location: Howlin Eigg

Re: 6 KB Avitar

Thu Mar 26, 2015 7:04 am

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 ?
>)))'><'(((<

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: 6 KB Avitar

Thu Mar 26, 2015 10:27 am

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.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

User avatar
DavidS
Posts: 4334
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: 6 KB Avitar

Thu Mar 26, 2015 10:31 am

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.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

Return to “Off topic discussion”