Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The file size isn't too bad, but in Safari the rendering time is terrible. You can see it render each block, and it takes about 10 seconds to render the whole thing.

I assume this is because it's not a commonly used feature, so the code paths are only implemented for compliance rather than performance.



It's actually more of a hack to deal with malformed GIFs and goes directly against spec. To address GIFs where each frame has a 0 frame delay, most GIF decoders implement a minimum frame delay value.

See: http://nullsleep.tumblr.com/post/16524517190/animated-gif-mi...

Edit: This is what it looks like with all frame delays set to 2 centiseconds: http://i.imgur.com/24xpZEd.gif

On Chrome and Firefox, you should see it animate more quickly.


GIF performance seems improved in safari, at least in 6.x, though this is just anecdotal evidence. The GIFs with 0.02 second frames (the actual ones, not just the "here's what it looks like under x browser" ones) seem to render with the same frame rate for me in Safari and Chrome now.


I figured that that was the issue. Thanks for the link!


Interesting, thanks for the details


That's just the animation -- the gif is constructed to animate displaying each block.


I find it very weird that the author of the page did not display this information on the page.


He uses mechanism that is inherent in GIF specification and can be used for animation, more than 256 color images or images that do not store image data for empty areas (or any combination). GIF stores sequence of rectangular blocks of image data each with its specified position in resulting image, own palette and optional delay before start of drawing (for animation). Browsers tend to assume that GIFs with multiple blocks with zero delay between them are broken animated GIFs (and enforce some minimum delay), because such files do exist and are certainly more common than GIFs with holes or large numbers of colors.



It may be possible to work around that: the trick they use to get full color is that each animation frame is allowed to have its own 256 color palette. So for each block of 256 colors, you have a single animation frame "played" which colors in only that block (the rest is transparent). Hypothetically, the only reason it renders so slowly is that there's a pause between playing each frame.


Yes, but it seems that delay may not be avoidable. http://nullsleep.tumblr.com/post/16524517190/animated-gif-mi... says Safari does 16 frames per second max. Drawing 32k colors at 256 colors per frame takes 128 frames. At 16 fps, those would take 8 seconds to draw.


I think it would be cool if the gif gradually enhanced the colors, starting out with the 256 colors and filling in details in subsequent passes. The user would just notice the color fidelity increasing. The trouble is that I don't know if gif implements non-looping animation.


It does support non looping animations. The problem is that I am not sure how you would calculate the 'tween frames. I get the first frame, it's just the final image dithered to 255 colors, but what would one of the intermediate frames look like. A small box with a more restrained palate, or would you break the final image into frames based on spectrum?


I would try to maximize the delta(PSNR) per frame, as a first cut. There are also good perceptual difference metrics. I don't know what algorithm to use. Maybe just the absolute difference on each pixel. Or, you could think of groups of colors to enhance if you're willing to grow the size of the image.


Can you not specify that the next frame's colours should be added to the current one's? Then you could do it in only 3 frames total - one for the red, green and blue channels.


I think it's just binary transparency as is widely mentioned by commenters around the web. I found this in the spec:

"viii) Transparency Index - The Transparency Index is such that when encountered, the corresponding pixel of the display device is not modified and processing goes on to the next pixel. The index is present if and only if the Transparency Flag is set to 1."

http://www.w3.org/Graphics/GIF/spec-gif89a.txt


yes, something like this. http://www.peda.com/iag/


> The file size isn't too bad

184,565 bytes for the GIF versus 34,991 for a PNG of the same or 7,692 for a JPEG with no visible artifacts.

I'd say the file size is unusably huge.


Convert it to true-color (24-bit) Windows BMP, and it's 141,538 bytes. So the GIF is even larger than the raw RGB values of each and every pixel concatenated together.


Same thing in Firefox.


Same in Chrome 26 (Win7)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: