July 26th, 2002


couldn't sleep

I was stuck on something earlier so I decided to sleep on it.

I didn't make it that far .... I couldn't sleep and I figured out what I wanted to do, so I'm back on the computer.

Ever read the GIF spec? So trivial! Funny quotes like:
The logical screen width and height can both be larger than the physical display. How images larger than the physical display are handled is implementation dependent and can take advantage of hardware characteristics (e.g. Macintosh scrolling windows). Otherwise images can be clipped to the edges of the display.

Anyway, I solved what I set out to do... modifying the GIF palette on-the-fly as it leaves the webserver without using something dumb & heavy like ImageMagick decoding its entire raster data into memory first. It was fucking trivial: byte 10 has packed in it a color map flag and the color depth. the palette starts at byte 13 with r, g, b bytes for each entry.

What was bugging me earlier was that I was caring about caching modified versions of the GIFs on the server side, but then I got realizing the GIF spec is probably simple and it'd be less code/disk/stress to just "make it" on the fly all the time. I was thinking making it all the time would be heavy, but it's probably a hundred times lighter than all the db lookups I'd be doing to find the cached version. Rad.

Now to do the same for PNG, though I've skimmed some of that spec and it's a little more daunting. Like, I seem to recall different containers and those containers being checksummed? We'll see.

(or I could sleep......)