Skip to main content
Remove backgrounds in seconds — no signup for your first free image.
Back to Resources
background-removaltutorials

How to Remove the Background From a GIF (Frame or Animation)

Remove a GIF background with ShotBG: cut one frame to a transparent PNG, or rebuild an animation frame by frame with tested ffmpeg steps for GIF, APNG and WebP.

8 min read
Written by Jack Shi
How to Remove the Background From a GIF (Frame or Animation)
Try ShotBG on your own photo
AI background removal · Free · No signup needed
Upload Image

To remove the background from a GIF with ShotBG, export the frame you want as a PNG or JPEG, upload it, and download the transparent PNG. ShotBG works on one still image at a time (PNG, JPEG or WebP, up to 10 MB) and always exports a still image, so it does not accept a .gif file and cannot return an animated GIF. If you need the whole animation cut out, you have two honest options: a video or animation tool that masks every frame for you, or a frame-by-frame workflow where you split the GIF, cut each frame, and rebuild it. This guide gives the commands for both, with the arithmetic that tells you how big the job is.

Pick your route first

What you wantRouteWhere ShotBG fits
One clean still from the GIF (a sticker, thumbnail or product shot)Export one frame, cut it outThe whole job
A short loop with a transparent backgroundFrame by frame: split, cut each frame, rebuildCuts each frame, one upload at a time
A long animation or many GIFsA video or animation tool that masks across framesNot suited: no batch, no animation
A GIF that was made from a video you still haveWork from the video, not the GIFCut one frame, or see how to remove a video background

The sections below cover the first two routes. For the product page, see the GIF background remover.

Route 1: cut out a single frame

  1. Find the frame. Open the GIF in a browser, viewer or video editor, pause on the frame you want and save it as PNG or JPEG.

  2. Or pull it out with ffmpeg. Frame numbers in this filter start at 0, so n=4 is the fifth frame:

    ffmpeg -i input.gif -vf "select=eq(n\,4)" -frames:v 1 -fps_mode passthrough frame.png

    A time-based grab also works, for example ffmpeg -ss 0.4 -i input.gif -frames:v 1 frame.png. On a test GIF running at 10 frames per second, both commands returned the same fifth frame.

  3. Upload frame.png to the ShotBG background remover and download the transparent PNG.

  4. Check the edges on both a dark and a light background before using it. Hair, fur and semi-transparent props are where cutouts fail; the transparent image guide explains what to inspect.

Got a product photo that needs a clean background?

ShotBG removes backgrounds in seconds with AI. Free for your first image — no signup required.

Remove Background Free

Route 2: rebuild a whole animation frame by frame

This works for a short loop. It is manual, because ShotBG has no batch or folder upload.

Step 1: count the frames

ffprobe -v error -select_streams v:0 -count_frames -show_entries stream=nb_read_frames,r_frame_rate -of default=nw=1 input.gif

On the test GIF used for this guide (a 200 × 200 pixel clip, 2 seconds at 10 frames per second) this reported 20 frames, which is simply frames = seconds × frame rate.

Step 2: split it into PNG frames

mkdir frames
ffmpeg -i input.gif -fps_mode passthrough frames/frame_%04d.png

-fps_mode passthrough keeps one output file per source frame, which matters for GIFs whose frame timing is not constant. The %04d numbering keeps the frames in order, so do not rename them.

Step 3: cut each frame

Upload frame_0001.png, download the result, and save it into a second folder under the same name. Repeat for every frame. Keep the numbering identical, or the rebuild will shuffle the animation.

Step 4: rebuild the animation

Pick the format your destination accepts.

# Animated GIF with transparency (1-bit)
ffmpeg -framerate 10 -i cut/frame_%04d.png -vf "split[a][b];[a]palettegen=reserve_transparent=1[p];[b][p]paletteuse=alpha_threshold=128" -loop 0 output.gif

# Animated PNG (APNG), keeps an alpha channel
ffmpeg -framerate 10 -i cut/frame_%04d.png -plays 0 -f apng output.apng

# Animated WebP, keeps an alpha channel
ffmpeg -framerate 10 -i cut/frame_%04d.png -c:v libwebp_anim -lossless 1 -loop 0 output.webp

All three commands were tested on 20 synthetic PNG frames whose background had been made transparent with ffmpeg (not with ShotBG output). Each output had 20 frames, and the share of opaque pixels matched the source frames (9 percent in the first frame). ffmpeg 8.0.1 could not decode the animated WebP back, so that file was checked with ImageMagick instead; if your ffmpeg lacks the libwebp_anim encoder, use the GIF or APNG command.

How big is the job?

Frames = seconds × frames per second. The time column is an assumed example: it supposes about 40 seconds per frame to upload, wait, download and rename, which is not a ShotBG measurement.

GIF length at 10 fpsFramesManual time at an assumed 40 s per frame
1 second10about 6.7 minutes
2 seconds20about 13.3 minutes
5 seconds50about 33.3 minutes
10 seconds100about 66.7 minutes

If your own time per frame is different, multiply it by the frame count. Past a few dozen frames, a tool that masks across frames is the better route.

Why the transparent GIF looks rough

  • GIF transparency is on or off. A pixel is fully visible or fully hidden. In the test, ImageMagick reported the rebuilt GIF as having 1-bit alpha. The soft edge of a PNG cutout therefore has to be rounded to one side: alpha_threshold=128 makes pixels above that alpha value opaque and the rest transparent.
  • GIF has at most 256 colours per frame. Gradients and photographic detail get flattened. See the transparent background images guide for the format comparison.
  • Halos. Edge pixels that were blended with the old background can show as a light or dark rim once the background is fully transparent. Preview the result on the background colour it will actually sit on.
  • APNG and WebP keep partial transparency, so edges stay smoother, if the place you publish them supports those formats.
Skip Photoshop — try the faster version.

Upload your image and get a transparent PNG instantly. Works for products, portraits, and graphics.

Try It Now Free

Frame delay changes the speed

GIF stores each frame's delay in hundredths of a second, as a whole number. The delays below are what ffmpeg 8.0.1 wrote when one-second test GIFs were generated at each rate; the effective rate is 100 divided by the delay.

Requested fpsDelay written (1/100 s)Effective fps
101010.0
12812.5
15714.3
20520.0
24425.0
25425.0
30333.3
50250.0

So a 24 fps source plays at 25 fps as a GIF, and a 30 fps source at 33.3 fps. Use the original frame rate in -framerate and expect that rounding, or choose a rate that divides 100 evenly (10, 20, 25, 50).

Common mistakes

  • Uploading the .gif itself. The uploader accepts PNG, JPEG and WebP, so export a frame first.
  • Cutting frames independently and expecting a smooth edge. Each frame is a separate cutout, so the outline can wobble from frame to frame; check the loop at full speed before publishing.
  • Renaming or skipping frames, which breaks the order in the rebuild.
  • Saving the result as GIF and judging the edge on the PNG preview instead of the finished GIF.
  • Treating a cutout of a GIF that contains text or a logo as an eraser job. Background removal separates the subject from its background; it does not erase objects that overlap the subject. See background remover vs object eraser.

What ShotBG does and does not do

  • Does: remove the background from one PNG, JPEG or WebP image up to 10 MB and download a transparent PNG.
  • Does not: accept animated GIF or video files, process frames automatically, batch-process folders, or export an animation.

For the general still-image job, see how to remove a background from an image.

FAQ

Can ShotBG remove the background from an animated GIF and keep it moving?

No. ShotBG takes one still image and returns a transparent PNG. To keep the animation, cut each frame and rebuild it with the commands above, or use a tool that masks every frame.

How do I turn a GIF into a transparent GIF?

Split it into frames, remove the background from each frame, and rebuild with ffmpeg using palettegen=reserve_transparent=1 and paletteuse. Expect hard edges, because GIF transparency has no partial levels.

Why does my transparent GIF have a white or dark outline?

The edge pixels still contain colour from the old background, and GIF cannot blend them. Preview on the real background colour, and consider APNG or WebP if the platform allows it.

How many frames does my GIF have?

Run ffprobe -v error -select_streams v:0 -count_frames -show_entries stream=nb_read_frames -of default=nw=1 input.gif. The number is also roughly the duration in seconds times the frame rate.

Is it practical to do this for a long GIF?

Only for a short loop. Because every frame is a separate upload, the work grows linearly with the frame count, as the table above shows. For long animations, use a video or animation tool.

Ready to Transform Your Product Photos?

Try ShotBG's AI-powered background removal tool for free. No signup required for your first image.

Try ShotBG Free