AuthorTopic: Graphics Gale (?) GIF Frame Disposal Fixing  (Read 3527 times)

Offline Kasumi

  • 0010
  • *
  • Posts: 275
  • Karma: +1/-0
    • View Profile

Graphics Gale (?) GIF Frame Disposal Fixing

on: June 18, 2016, 07:02:33 am
tl;dr:
Turn this:

Back into this:

(For Duelyst by Atnas)
You may have had that problem before.
The Problem
Graphics Gale gives its users power over choosing "frame disposal" per frame. If it's not set properly and saved this occasionally creates problems on reloading. (One or all frames are now combinations of themselves and the previous frame).
The Solution
Gifsicle lets you do all sorts of things with GIF files, but not everyone is great with command line apps. I made a simple Windows script file you can drag a broken gif to and it will tell gifsicle to create eight variations of the file with different disposal options.

Download the script from here.

To use:
1. Download a Windows build of Gifsicle from here: https://www.lcdf.org/gifsicle/ (Click Windows Ports.)
2. Extract it.
3. Copy "giffix.bat" to the same folder as "gifsicle.exe"
4. Drag your broken .gif file over "giffix.bat"

You'll get eight files ([originalfilename]_0.gif through [originalfilename]_7.gif) one of which may have the frames unmerged.

Disclaimer:
This .bat will overwrite [originalfilename]_0.gif through [originalfilename]_7.gif without asking. If you have files named like that you want to keep, move them before dragging [originalfilename] over the .bat. 

I am not responsible Gifsicle itself, nor the Windows ports. This script is provided as is with no warranty or guarantee of support.

This obviously can't fix everything. If you save your broken gif again, it's possible the broken frame can no longer be separated with frame disposal changes.
Like this one:

(Roll Caskett by Conzeit)

If your GIF actually did require different types of disposal in the same animation, this won't give you a single file you can continue from. It may still split the frames you're looking to split so you can copy them back to your original file.

This .bat doesn't offer you much if you're familiar with command line apps.
The Story
A user came on Slack with a broken GIF. I looked around and didn't find a program that could fix it. (Gifsicle could have, I even looked at Gifsicle, but I missed that it did this.) I quickly researched the GIF format and wrote a standalone program that fixed that GIF. Others have since asked me for the program, but the way it did things wasn't really very smart. Since I've now realized Gifsicle can do it, I may as well just release a script that makes Gifsicle as simple to use for the same purpose.

What is Frame Disposal?
"Frame Disposal" is a feature of the GIF file format. It tells the program displaying the gif what to do with the previous frame when the next one should be displayed. It can erase the previous frame (with a transparent color or the background color), or draw the next frame on top of the old frame.

A practical use of Frame Disposal is to save a bit on filesize (important when gif first appeared).

See this GIF of Shiki Ryougi from Melty Blood:

The bottom portion of the image never changes, so it could be stored only once in the first frame. The other six would just draw the new head on top of the old head.

Frame Disposal can also be used to do totally impractical things. A single GIF "frame" can only have 256 unique colors. This GIF:

(from wikipedia)
Takes advantage of not erasing the previous frame so that it can draw more than 256 colors. You can even have what appears to be a non animated gif contain way more than 256 colors (every frame has no delay, draws on top of the previous frame with a new group of colors each time, and doesn't loop).
Thanks
Eddie Kohler for making Gifsicle which this requires.
Yaomon who originally showed there was a need for this.
Conzeit who went above and beyond with breaking files to test the original standalone.
Atnas who made me post this thread.

Yaomon AGAIN because he made me realize this gif which I'd had on my computer for like years:

had a disposal issue:

I always assumed it was supposed to be like that. And maybe it is, but it's cool to see it the other way regardless. I never would have written the standalone program, or even thought about it if not for Yaomon.

If anyone knows the source of that anime gif, please let me know!
Edit: Probable source: http://kwgtms.tumblr.com/post/39562447806/%E6%B0%B8%E9%81%A0-the-liquid-girl
« Last Edit: June 18, 2016, 06:29:30 pm by Kasumi »
I make actual NES games. Thus, I'm the unofficial forum dealer of too much information about the NES

Offline yrizoud

  • 0010
  • *
  • Posts: 330
  • Karma: +0/-0
    • View Profile

Re: Graphics Gale (?) GIF Frame Disposal Fixing

Reply #1 on: June 18, 2016, 01:50:13 pm
Thanks a lot for sharing! This part of the GIF format is actually what I used in Grafx2 to save layered images, so that they can be viewed directly by all image browsers. I don't know if it's frequent to find images broken this way, but before your post I knew no easy way to fix them - only hex editing.

If anyone is curious for more technical information, the GIF specification calls it the Disposal Method. And this article has a lot of explanations on the GIF format and features: "What's in a GIF"

Offline eishiya

  • 0100
  • ***
  • Posts: 1266
  • Karma: +2/-0
    • http://pixeljoint.com/p/28889.htm
    • View Profile
    • Website

Re: Graphics Gale (?) GIF Frame Disposal Fixing

Reply #2 on: June 18, 2016, 02:24:40 pm
Huh, I'm surprised there's such a lack of ways to fix this in the "good" programs. I've been using Microsoft's ancient little program GIF Animator (which you can download for free now) to do it for years. You just select all the frames (select the first frame, scroll down, shift+click the last frame), and set their undraw method as "Restore Background." I assumed if this thing could do it, anything that can edit GIFs can. Apparently not!
« Last Edit: June 18, 2016, 02:44:30 pm by eishiya »

Offline yrizoud

  • 0010
  • *
  • Posts: 330
  • Karma: +0/-0
    • View Profile

Re: Graphics Gale (?) GIF Frame Disposal Fixing

Reply #3 on: June 18, 2016, 05:14:18 pm
Very few programs are so low-level, because this is extremely technical and specific to the GIF format. Modern animation programs should let the user draw over the entire canvas, and change what he wants on each frame - let the saving algorithm determine the most efficient way to encode the resulting GIF (like, for example, "what is the smallest rectangle which has changed since last frame" : It's better to keep the current image displayed, and redraw only this smaller image).

Offline Kasumi

  • 0010
  • *
  • Posts: 275
  • Karma: +1/-0
    • View Profile

Re: Graphics Gale (?) GIF Frame Disposal Fixing

Reply #4 on: June 18, 2016, 06:22:18 pm
yrizoud: At a quick glance, that appears to be a much better file format specification than the one I found when I wrote the standalone version of this. Another program I made because of Slack is a parallax maker. It might be cool to try to make that export an animated gif instead of 9000 pngs.

I mostly agree that programs shouldn't leave it up to the user, but since some do there's at least a safety net here. It's unlikely you'll encounter a random gif like the anime one, but it's less uncommon that you might end up accidentally making one. The old standalone helped at least a couple of people in the slack, and it's better to have the thing "out there" than slack exclusive even if I guess it's a solved problem in a lot of ways.

eishiya: Wow, Microsoft GIF animator totally does do it! I used to use that to make still images into gifs before I started using a pixel program that supports animation. This+gifsicle is maybe faster, but it's true it's not something you'd be doing that often.

I found the likely source of that anime gif with a google image search: http://kwgtms.tumblr.com/

I swear I tried that before and didn't find it. I'll edit it into the first post. I did try to source everything.
« Last Edit: June 18, 2016, 06:38:43 pm by Kasumi »
I make actual NES games. Thus, I'm the unofficial forum dealer of too much information about the NES