b3ta.com board
You are not logged in. Login or Signup
Home » Messageboard » Message 4209908 (Thread)

# Hehe..it works!
(do the scan lines optimise it that much?..just wondering)
(, Sun 30 Jan 2005, 22:53, archived)
# from way over a meg to 200 i think so in this case
(, Sun 30 Jan 2005, 22:53, archived)
# Cool!
..will have to try that next time I'm facing producing a monster gif!
(, Sun 30 Jan 2005, 22:55, archived)
# gifs compress by counting the number of identical pixels of a colour in a horizontal line
so a solid line of black takes up very very little space

edit: to quote claws of doom

A GIF is mostly used on the web for logos, lines and one pixel images. It is the only image format that can handle animations on the internet (not discussed here). GIFs are limited (by their definition) to be able to handle at most 256 colours. This means that they cannot accurately display photographic images (which need 256 colours in each base colour: Red, Green and Blue).

To store an image as a GIF, the following steps are taken.

1. The image is analyzed to see which set of colours (up to 256 different ones) will best describe the colours present.
2. The colours are defined and each tagged with a different key (colour a, b, c etc. if you will)
3. The lines of the picture are placed end to end, with the topmost line first.
4. Each individual pixel is then described. This generates a line of data which could appear as "a,b,a,a,a,c,b,a,a,b,b,b,b,c,a" etc.
5. This is compressed to: "a,b,3a,c,b,2a,4b,c,a" etc.

From this you can see that a large swathe of the same colour takes up very little space – imagine the section compressed by "2478a". These large swathes of colour occur mostly in logos and blocks of colour. Even the slightest change of shade between pixels will render the compression useless.

Given the original picture dimensions the image can be worked out again, by merely reading the list of data and laying each pixel down – much like a mosaic. If the image had less than 256 colours in it at the start, you wouldn't have lost any detail in your image by storing it as a gif.
(, Sun 30 Jan 2005, 22:57, archived)
# Of course!
But what a superb explaination! (Thank you!)
(, Sun 30 Jan 2005, 23:01, archived)
# yep... i'm mighty glad he took the time to write that
it's much better than the one i wrote
(, Sun 30 Jan 2005, 23:03, archived)
# it's called Run Length Encoding
although it's possible to RLE optimize your image in a very lossy way so that near duplicatable colours are made identical,
however unlike the squares that appear in wavelet compression (jpeg), this optimization loss is highly noticable
(, Sun 30 Jan 2005, 23:25, archived)