4

Sorry in advance for the anime gif...
So I want to make the below GIF's background transparent, but I feel like I've tried it all, but to no avail.
OG Gif
I am fairly new to GIMP, so after trying everything I could think of, I resorted to the top solution on THIS page, but only produced the three following GIFs.
bad1 bad2 bad3
Though the last one doesn't look far from what I want it to be, it has a white trail everywhere that the character moves, which conflicts terribly with the place I'm trying to put this image (I'm trying to create my first website)bgw
I've honestly no idea what I could try now, so any help would be GREATLY appreciated. Thanks in advance

  • btw who's the original author of those animation '__')? it's so cute – Kokizzu May 26 at 23:56
4

Difficult image, for several reasons:

  1. it has been "optimized". In a GIF, you can go from one frame to the next in two ways:

    • (replace): the whole image is replaced by the contents of the new frame
    • (combine): the frame contains only the changes from the previous one, and just overlays the image. Since there is no way to make pixels transparent again, this mode cannot work with a moving object on a transparent background.

Some of the processors you tried don't look at this and assume that the image is not optimized (the first you tried above, for instance). You can unoptimize the image using Filters>Animations>Unoptimize.

  1. Your background is not uniform. It is made of at least 3 colors. To spot them

    • Windows>Dockable dialogs>Color map: this shows you all the colors used in the GIF (256 max).
    • Your background is made of the last two colors, with some pixels from a third one (antepenultimate), but that one is also used in the face of the character. This makes color-based removal difficult.
  2. There are many "closed" background areas:

    • between tail and hair
    • around the knees
    • around the face/arm/bottle

    These makes contiguity-based removal complex.

  3. Even after unoptimization, there are nearly empty frames, that may translate into image jerks.

Things to try:

  1. Try your processors above with the unoptimized image
  2. Do it yourself. You can make it quite fast by avoiding processing each of the 169 frames in turn:

    • Install the ofn-layer-tiles script
    • After unoptimization, use it transform your 169 layers into a single layer (500x86866)
    • Remove the background with fuzzy-select. Check each image in turn for closed areas and remove them
    • Once done use the "split" operation of the script to rebuild the stack of frames.
    • Export as animation again (replace) mode of course

Edit: did it myself before dinner.

  • As above flatten the frames into a single ribbon
  • Edit the colormap so that the two main colors of the background becomes the same color.
  • Convert the image to RGB mode
  • Fuzzy select the background
  • Moderately labor intensive: check all 169 images for closed (and therefore un-selected) areas and add them to the selection (3-4 areas per frame). You can use Select>Save to channel from time to time to save your current selection
  • Used the ofn-erase-background script to remove the selected background (this is basically Select>Grow and Colors>Color to alpha with a few niceties).
  • Split the frames and export to GIF
  • For kicks, make a "slow" version with a green background to see if there are any left-overs (warning:optimized):

enter image description here

Plain GIF is here

  • This worked great after I figured out how to use the script properly, thanks! Much better than any of the results I had achieved so far! – Outcahst Apr 13 at 16:28
2

I agree with everything @xenoid has said. It's going to be difficult! However there is another problem which hasn't been addressed, even if you do manage to remove the background.

Although the last version is close to what you want, except it looks like you forgot to set the frames to replace, it's never going to look quite right against a dark blue background unless you edit all those surrounding light coloured pixels to dark blue. This is called "matting". However since you don't have the original layered RGBA XCF file to work with, but only an Indexed Colour GIF, it's going to be difficult to fix automatically.

There is a tedious work around:

Assuming you manage to remove the background, and the image is now unoptimized, and already converted to RGB mode, then for each individual frame you could make a selection from alpha, invert the selection, grow the selection 1px, engage the pixel lock. The do Edit > Fill with FG color (assuming you first selected a dark blue foreground colour)

Example: Before (left) and after (right)

enter image description here

  • Sorry if I'm missing something here, but wouldn't it make more sense to replace the light pixels with the alpha channel instead of a fill color? Thanks for your response, I was just hoping for a little clarification on yours before I started on it. – Outcahst Apr 13 at 16:30
  • Nope. There is no Alpha channel for GIFs. The format doesn't support it. There is transparency, but it's either fully transparent or fully opaque. If you just delete the pixels right up to the edge of the line, you will get a jagged pixel edge. Filling with dark blue instead is less noticeable and will make it blend into the background. – Billy Kerr Apr 13 at 17:31
  • Pixellated edges aren't that much of a problem for an animation, but even a remaining halo could be hardly noticeable if the image is going to be transplanted over a light background. Edited my post above to show the results with an appropriate method to handle the edges. – xenoid Apr 13 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.