Menu

Where to put a GIF size budget check in an asset pipeline
📰

Where to put a GIF size budget check in an asset pipeline

DEV Community: javascript·Lank_M·14 days ago
#JQRv3CmK
#devtojavascript#devto#dev#budget#file
Reading 0:00
15s threshold

Put the GIF size check on the finished file, after every encoder setting has been applied, and make it fail the build with a number. A rule on the settings ("max 64 colors, dither off") looks cheaper to write, but it cannot predict bytes.

I ran into this while measuring how colour count and dithering change GIF size. The sample is one 10-frame animation, 675×599, 3,003,893 bytes (MORPH.gif, by Kowloonese, Wikimedia Commons, CC BY-SA 3.0, resized and re-encoded for the tests). Everything below is that one file, one machine, one run each. Sizes are plain bytes.

The same switch gave 0.7% and 50.4%

In the animation workshop of ImgIng, a browser tool, I exported GIFs at four palette sizes with Floyd–Steinberg dithering off and on. At 32 colours the file was 811,310 bytes with dithering off and 1,110,431 with it on, which is +36.9%. At 256 colours it was 1,525,126 against 1,535,115, which is +0.7%. My guess is that the source is already close to a 256-colour image, so there is little error left to spread.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.