You Don't Know GIF – An analysis of a GIF file and some weird GIF features
blog.darrien.dev
blog.darrien.dev
>Amazing! Stupendous! Wonderful! As of the time of this writing, it’s just a perfectly black square. And this is the case in every single renderer I’ve tried. Gimp, Chrome, Firefox, Preview, gifiddle, you name it.
Funnily enough in my browser (Firefox on Ubuntu) it's transparent, but it's level of transparency I have never seen before - I can see the window below.
[1] https://developer.mozilla.org/en-US/docs/Web/API/CanvasRende... [2] https://developer.mozilla.org/en-US/docs/Web/API/CanvasRende...
However screen-sharing API like getDisplayMedia() will screencopy at the compositor level, so they will include those pixels depending on what you choose to share.
I wonder if this could be used for some sort of phishing attack by tricking the user into thinking it is some OS trusted dialog or just showing that you know something secret so you should be trusted (would be hard to set up to work with any sort of probability though).
It's even funnier when I open the dev tools, the transparent image is replaced by a violet rectangle, blinks a few times then stay violet[1]!
[0]: https://up.l3m.in/file/1646929301.png [1]: https://up.l3m.in/file/1646929762-a.webm
Mozregression looks amazing: https://mozilla.github.io/mozregression/
I do have amusement when the author says it's a black square on every renderer he's tried, but we trivially trigger something else :)
Seems like he's on Mac OS X and so I guess it's down to platform quirks.
My favorite part of gif is the hack to embed XMP metadata into gif files. XMP is supposed to be valid xml (it is adobe's rdf based image metadata standard), and should be readable even by format unaware readers. However gif metadata is supposed to be split into (up to) 255 byte blocks where you do 1 byte length, followed by that many bytes of data, another length byte + data, until you terminate with a null byte for a zero length data segment.
This of course is incompatible with making valid xml. However nulls are invalid in xml, so what the spec makers did instead was to ignore these length bytes, just put the xml in without changing it, but end the section with <FF>, <FE>, .... <01>, <00> as a sort of NOP slide-esque thing, in order to make sure everything is well formed acording to the gif standard. If your parsing the file like a normal gif eventually you will jump into the end segment, and everything will be well formed. Its just such an interesting hack to meet all requirements.
Of course, i'm not sure anyone actually creates gif files with metadata so may be a bit moot in practice.
I had a massive bug however and I couldn't for the life of me figure out the issue up until two weeks ago.
Turns out, once you've reached a code size of 12 bits, I was "assuming" you should reset to the root code size, however, you should not. Instead of resetting, you should ignore either increasing or resetting the code size, but just keep reading 12 bits codes from the bit stream because from that point on, all codes read from the stream will be in the dictionary. The encoder will have inserted a Clear Code to reset and start from scratch.
It was a difficult thing to debug but once I wrapped my head around it, it made total sense. It was very satisfying to throw a large collection of GIFs at my decoder and see them being displayed.
You can load a GIF in it that it has previously saved and re-render the Fractal.
It's only 65536x1.
This hedgewars map is 262144x512 https://m8y.org/hw/WTF/Maps/WTF/
Limitations on ginormous hedgewars maps being documented here: https://hedgewars.org/kb/PresetMaps#Basic_files
(an additional limitation encountered in Hedgewars was SDL being incapable of painting very long or very tall maps - this was worked around by removing the SDL function and using direct byte copy)
Unfortunately a GIF is a set of tagged records. They can theoretically occur in any order. But these amateur decoders would pick out fields where they 'knew' they would be.
Upshot: different tools have very different success rates decoding anything even slightly off-normal. So even though a GIF is a set of tagged records, you write them that way at your peril.
In other news, I wrote a GIF renderer that added features like sprites, animation and scripting. It was for a PocketPC game called Lexicon. Fun!
I'd completely forgotten about it, but remembered it as soon as I saw it. Crazy to think that was "full screen" and seemed hi-res.
For those that are curious, here's what it looks like when viewed with an era-appropriate viewer like CompuShow:
https://news.ycombinator.com/item?id=5748439
https://bits.blogs.nytimes.com/2013/05/21/an-honor-for-the-c...
I thought the browser was gonna use some sort of default color table. Or generate a new table with random colors every time it loaded the image. Wouldn't that be fun? Maybe even let me save the generated color table hard-coded into a new GIF.