Hacker News new | ask | show | jobs
by jradd 2108 days ago
I wonder if there are any real programmers out there who have decoded GIF by hand. The IETF is clear that the header should be 6 7bit bytes (GIF##a), and the ends with `\x00\x3b`.

without LZW, it should be trivial to append a frame to an image. its so hard... instead of downvoting me, does anyone know of a good/simple example of this in C/python or anything? array2gif[1] is pretty close.

1: https://github.com/tanyaschlusser/array2gif

1 comments

Don't know a simple example: when I did trivial encoding[1], it was by reading the spec. Dim memories for keeping it simple: choose an advantageous bit depth and palette so your non-lzw'd data can trivially be written out bytewise per pixel. If you can control width to avoid line padding, even better.

(Yet dimmer, possibly false, memories: by taking advantage of LZW literals, I think it's possible to unencodedly write supposedly encoded blocks?)

[1] 10-50 lines of python, depending upon fanciness, IIRC