Animated GIF Cropper: Crop Every Frame, Keep the Loop

What an animated GIF cropper has to do · Why a crop can freeze, smear or speed up an animation · Prerequisites, versions and the 12-step plan · Steps 1 to 3: build a test GIF, inspect it, choose the rectangle · Step 4: crop in a browser with Ezgif · Steps 5 and 6: crop with FFmpeg and gifsicle · Step 7: crop with ImageMagick · Steps 8 and 9: crop with GIMP and Photoshop · Steps 10 to 12: verify, optimize and export · The complete working project · Batch cropping a folder · Common pitfalls · Troubleshooting · Advanced tips · Common questions
An animated GIF cropper does one job. It applies the same crop rectangle to every frame, then writes the file back with the original delays and loop count. A tool that crops only the first frame hands you a still image. A tool that crops frames at the wrong offset hands you a smeared one.
This tutorial covers five ways to crop an animated GIF and keep it moving: a browser tool, FFmpeg, gifsicle, ImageMagick, and GIMP or Photoshop. It ends with a short Python project you can run on any GIF, plus a check script that proves the timing survived. For reference, the current desktop builds are Photoshop 2027 (version 28.0, shipped November 10, 2026), GIMP 3.2.8, ImageMagick 7.1.2-36 and FFmpeg 9.1 “Gauss”.
If the GIF also needs a transparent background, crop first and cut out second, because the cutout job shrinks with the canvas. Our ranking of tools that remove the background from an animated GIF covers that second step.
What an animated GIF cropper has to do
Short answer: rebuild every full frame, cut one rectangle from all of them, and keep the timing data. A GIF is a stack of frames. Each frame carries its own delay (counted in hundredths of a second), a disposal method that says what to do with the frame before the next one draws, and a palette of up to 256 colors.
Many files are also frame-optimized. Every frame after the first stores only the rectangle of pixels that changed, plus an offset. The demo GIF used later in this tutorial shows it clearly. Its canvas is 320×180, yet frame 1 is stored as 63×111 pixels at offset +20,+10, and frame 3 is 82×111 at +45,+10. A cropper that treats those small patches as full frames cuts the wrong pixels.
A correct cropper first rebuilds each full frame. The jargon for that step is coalescing. It then cuts one rectangle from every frame, and finally re-optimizes so the file does not balloon. Four things have to survive the trip: frame count, per-frame delay, loop count and transparency. The table below shows which route handles each one, and what it costs.
| Method | Version in current use (checked Nov 28, 2026) | Cost | Keeps delays and loop | Best for |
|---|---|---|---|---|
| Ezgif, Crop animated images | Web service, no version | Free (its Terms say the service is provided free of charge) | Yes, if the crop option you pick behaves | One-off crops, no install |
| FFmpeg | 9.1 “Gauss”, November 20, 2026 | Free | Yes, with palette filters and a timing check | Exact pixels, scripts |
| gifsicle | Run gifsicle –version on your machine | Free | Yes, built for GIF frames | Fast crops and optimization |
| ImageMagick | 7.1.2-36 | Free | Yes, with -coalesce and +repage | Crops mixed with other edits |
| GIMP | 3.2.8 | Free | Yes, if layer names keep their delay hints | Hand-placed rectangles, per-frame fixes |
| Photoshop | 2027, version 28.0 | Paid subscription | Yes, via Timeline and Save for Web (Legacy) | Teams that already pay for it |
| Python script (project below) | Python 3 with Pillow | Free | Yes, and a script verifies it | Repeatable crops, batches |
Pick by job. If you crop one GIF once, use the browser tool. If you crop the same shape every week, use the Python project or a gifsicle one-liner. If the crop is part of a bigger edit with per-frame retouching, open GIMP or Photoshop.
Cropping also gets confused with three neighboring jobs. Resizing scales every pixel and keeps the shape. Trimming removes frames from the start or end and changes the length. Changing the canvas size adds or removes empty space around the picture. A crop removes pixels from the edges and leaves the rest at full size, which is the right move when a subject sits off-center or a platform wants a square. Many online tools bundle all four on one page, so read the button label before you press it. When this article says animated GIF cropper, it means a tool that does the crop and leaves the timing alone.
Why a crop can freeze, smear or speed up an animation
Every failure has a mechanical cause, and knowing them makes the fixes in the later sections obvious.

First-frame crops. Some tools crop only the active layer or the first frame, then export whatever is left. You get a single still image with a .gif extension. A Mac-focused guide reports that Preview does not preserve the animation when you crop an animated GIF, so treat it as a still-image tool.
Offset errors. In an optimized GIF, frame 1 is a small patch at +20,+10. If a tool crops that patch as though it were a full frame, the crop box lands on the wrong pixels. The symptoms are blank frames, jumping content or a subject that slides sideways.
Disposal smears. The disposal method tells the player whether to keep or wipe the previous frame. Drop that data and moving objects leave trails, while transparent GIFs stack old frames on top of new ones.
Lost delays. Each frame has its own delay. A tool that rewrites the file with a single default delay turns a hand-timed loop into a metronome. The demo GIF here uses 60 ms for six frames and 100 ms for the rest, so a flattened delay is easy to spot.
Lost loop count. A GIF stores its loop count in a small extension block. Lose it and an endless loop plays once and stops, or the other way round.
Palette damage. Each save re-quantizes colors to 256 or fewer. One pass is fine. Three passes through three tools add visible banding and noise.
Subject leaving the box. This one is yours to catch, not the tool’s. A crop box drawn on frame 1 can slice a character in half at frame 40. Scrub the whole loop before you commit to a rectangle.
Ezgif’s own crop page advises trying a different crop-processing option when the output shows missing frames, flickering or artifacts. That advice confirms the optimized-frame issue is real even for dedicated tools.
Prerequisites, versions and the 12-step plan
You need a computer and one GIF you can afford to experiment on. Every command below works on Linux, macOS and Windows, with small differences in how you install things.
- FFmpeg 9.1 “Gauss” or any recent release. The official release page dates it November 20, 2026.
- gifsicle, latest version. Distro packages often lag behind the newest release, so check what you actually have.
- ImageMagick 7.1.2-36, the current stable release on the official homepage. ImageMagick 6 still gets legacy maintenance and uses
convertwhere version 7 usesmagick. - GIMP 3.2.8, announced on the GIMP site on November 2, 2026.
- Photoshop 2027 (28.0) if you already subscribe. Adobe lists Photoshop 2026 (27.x) as still supported for technical support and security fixes. A prepaid annual plan is listed at US$263.88 per year.
- Python 3 with Pillow, for the project. Install Pillow with pip. The scripts use nothing exotic, so any recent Python 3 works.
Install the free command-line tools like this:
# Debian and Ubuntu
sudo apt install ffmpeg gifsicle imagemagick
# macOS with Homebrew
brew install ffmpeg gifsicle imagemagick
# Windows (winget and scoop)
winget install Gyan.FFmpeg
winget install ImageMagick.ImageMagick
scoop install gifsicle
# All platforms, for the Python project
python3 -m pip install --upgrade pillow
Then check what landed on your machine. Package managers often ship an older ImageMagick 6, so the version line matters:
ffmpeg -version | head -n 1
gifsicle --version | head -n 1
magick -version | head -n 1 # ImageMagick 7
convert -version | head -n 1 # ImageMagick 6 installs
python3 -c "import PIL; print('Pillow', PIL.__version__)"
Here is the plan the rest of the article follows:
- Copy your GIF (or build the test GIF) so the original stays untouched.
- Inspect the canvas size, frame count, delays and loop count.
- Choose the crop rectangle in source pixels.
- Crop in the browser with Ezgif.
- Crop with FFmpeg.
- Crop with gifsicle.
- Crop with ImageMagick.
- Crop with GIMP.
- Crop with Photoshop.
- Verify frames, delays and loop count.
- Optimize the file size.
- Export, name the file and test it where it will play.
You only need one of steps 4 to 9. The rest apply to every route.
Steps 1 to 3: build a test GIF, inspect it, choose the rectangle
Step 1: get a safe working copy. Copy your real GIF into a scratch folder and never crop the original. If you want a file that behaves like the awkward ones in the wild, generate one. The script below draws a 320×180 clip with a bouncing ball, 12 frames, a 60 ms delay on the first six and 100 ms on the last six, and an infinite loop. Pillow saves it frame-optimized, so it makes a good stress test.
from PIL import Image, ImageDraw
W, H = 320, 180
frames, delays = [], []
for i in range(12):
im = Image.new("RGB", (W, H), (24, 28, 44))
d = ImageDraw.Draw(im)
d.rectangle([0, H - 30, W, H], fill=(40, 90, 70))
x = 20 + i * 22
y = 60 + (20 if i % 2 else 0)
d.ellipse([x, y, x + 40, y + 40], fill=(240, 180, 40))
d.text((10, 8), f"frame {i:02d}", fill=(255, 255, 255))
frames.append(im)
delays.append(60 if i < 6 else 100)
frames[0].save("demo.gif", save_all=True, append_images=frames[1:], duration=delays, loop=0)
print("wrote demo.gif")
Run it with python3 make_test_gif.py and you get demo.gif. Every example in this article uses that file.
Step 2: inspect the GIF. You need four facts before you crop: canvas size, frame count, per-frame delays and loop count. ImageMagick can print the raw frame data, which shows the optimized patches. This works in both ImageMagick 6 (convert) and 7 (magick):
magick demo.gif -format "%s frame=%wx%h offset=%X,%Y delay=%Tcs\n" info:
Example output for the demo file, trimmed to the interesting rows:
0 frame=320x180 offset=+0,+0 delay=6cs
1 frame=63x111 offset=+20,+10 delay=6cs
2 frame=63x111 offset=+42,+10 delay=6cs
3 frame=82x111 offset=+45,+10 delay=6cs
...
11 frame=258x111 offset=+45,+10 delay=10cs
Read that output closely. Frame 0 is the full 320×180 canvas, and everything after it is a smaller patch. That is the trap. The delay column shows centiseconds, so 6cs equals 60 ms. Add -coalesce before -format and every row becomes 320×180 at +0,+0, which is what a cropper needs to see.
If you prefer other tools, gifsicle --info demo.gif prints the logical screen size and frame list, and ffprobe demo.gif reports the stream size and frame rate.
Step 3: choose the rectangle in source pixels. Crop rectangles are written as x and y (the top-left corner) plus width and height, all measured on the original canvas. Browser tools show a scaled preview, so always confirm the numbers in the input fields rather than trusting the drag handles.
GIF has no even-number rule, so odd sizes such as 101×180 are legal. That changes if you later convert the file to a video format, where many encoders want even dimensions. Here is the math for common targets on the 320×180 demo, which the Python project produces:
| Target ratio | Anchor | Rectangle (x, y, w, h) | Output size | Note |
|---|---|---|---|---|
| 1:1 | Center | 70, 0, 180, 180 | 180×180 | Avatar or emote frame |
| 1:1 | Left | 0, 0, 180, 180 | 180×180 | Subject sits on the left |
| 4:3 | Center | 40, 0, 240, 180 | 240×180 | Trims 40 px each side |
| 9:16 | Center | 109, 0, 101, 180 | 101×180 | Vertical, narrow strip |
| 16:9 | Any | 0, 0, 320, 180 | 320×180 | Already 16:9, no crop |
Leave a margin when you pick the rectangle. Motion in a GIF rarely stays inside the box you drew on frame 1, and a ball that bounces or a logo that overshoots its final position will touch the edge on some frame. A margin of 8 to 10 pixels around the subject at its furthest reach costs almost nothing and saves a re-crop. Step through the loop frame by frame in GIMP, or watch the Ezgif preview at least twice, and note the furthest point the subject reaches before you commit to numbers.
Notice how little of a 16:9 source survives a 9:16 crop. If the subject needs more room, crop the source video before it becomes a GIF, or accept that a vertical version needs a different shot.
Step 4: crop in a browser with Ezgif
The browser route is the fastest for a single file. Ezgif lists the tool as Crop animated images, and its crop page accepts GIF, APNG, WebP and AVIF inputs. Its Terms of Service, last dated November 18, 2026, describe the whole toolkit as free and provided as is. They also put server-side uploads at 200 MB and animations at 2,000 frames, and other Ezgif pages say animated output is limited to 1,920 px in either dimension. Check those limits before you upload a large screen capture.

Follow these steps:
- Open the Ezgif crop page and choose your file (or paste a URL), then press the upload button.
- Draw the crop box on the preview, or type the left, top, width and height values by hand. Typing is better for repeatable work because the numbers match your plan from Step 3.
- Use an aspect ratio preset such as 1:1, 4:3, 16:9 or 9:16 if you only care about shape. Typical browser croppers offer those four.
- Press the crop button and wait for the result to render below the preview.
- Play the result. Scrub the whole loop and watch the edges.
- If frames are missing or flicker, go back and pick a different crop-processing option, as Ezgif’s own page suggests, then crop again from the original upload.
- Save the file. Run the verify script from Step 10 if the timing matters.
Two cautions apply. First, your file goes to a server, so skip this route for anything private. Second, treat the output like any other generation. Do not crop, resize, optimize and then crop again through the same site, because every save re-quantizes the palette. Plan the rectangle, crop once, and optimize last.
Ezgif’s Terms also say something useful for later in this tutorial. For heavy scripted or batch work, the site recommends running ImageMagick, FFmpeg or Gifsicle locally, since it offers no paid or guaranteed public API. We follow that advice in the batch section.
Steps 5 and 6: crop with FFmpeg and gifsicle
Both tools are free and scriptable, which makes them the usual pick for anyone who crops GIFs more than once. FFmpeg is free software and the project publishes its license terms, so there is no watermark or per-file fee to worry about.
Step 5: FFmpeg. FFmpeg crops with the crop video filter, written as crop=w:h:x:y. A GIF is a palette format, so you cannot simply crop and save. You have to rebuild a good palette from the cropped pixels or the colors band. One command does both:
ffmpeg -i demo.gif \
-vf "crop=180:180:40:0,split[a][b];[a]palettegen=stats_mode=diff[p];[b][p]paletteuse=dither=bayer:bayer_scale=5:diff_mode=rectangle" \
-loop 0 cropped-ffmpeg.gif
Here is how the filter chain reads. crop=180:180:40:0 cuts a 180×180 square starting 40 px from the left edge. split sends the cropped stream down two paths. palettegen builds a 256-color palette from the cropped pixels only, and stats_mode=diff weights the palette toward pixels that move. paletteuse then maps the frames onto that palette, and diff_mode=rectangle keeps unchanged areas out of the file. -loop 0 sets an infinite loop.
If the GIF has transparency, change the palette step to palettegen=reserve_transparent=1. If your frame delays vary, as they do in the demo, add -fps_mode passthrough before the output name and check the result with the verify script. FFmpeg can resample timing on some inputs, and the check is cheap.
To center a square without doing arithmetic, let the filter do it. The default crop position is the center, so this works on any size:
ffmpeg -i input.gif \
-vf "crop='min(iw,ih)':'min(iw,ih)',split[a][b];[a]palettegen[p];[b][p]paletteuse" \
-loop 0 square.gif
Step 6: gifsicle. gifsicle is built for GIF frames, so the crop is a flag. The syntax is --crop x,y+WxH or --crop x1,y1-x2,y2, and it applies to the input files that follow it:
gifsicle --unoptimize --crop 40,0+180x180 --optimize=3 demo.gif -o cropped-gifsicle.gif
--unoptimize expands each frame to the full canvas before the crop, which avoids the partial-frame problem. --optimize=3 re-optimizes the result at the end. Both are mode options, so their position among the flags does not matter, but --crop must come before the file it should affect.
Two other flags are worth knowing. --crop-transparency trims transparent borders from the following frames, which is handy for logo loops with wasted margin. -b edits files in place, so use it only on copies. If the frame count drops after a gifsicle crop, confirm --unoptimize is on the command, run the verify script again, and fall back to the ImageMagick route if it still fails.
Step 7: crop with ImageMagick
ImageMagick is the right pick when the crop is one step in a longer chain, such as crop, then resize, then recolor. Its current stable release is 7.1.2-36 according to the official homepage, and the program you run is magick. Version 6 still gets legacy fixes and installs the older convert command, with the same options.
magick demo.gif -coalesce -crop 180x180+40+0 +repage -layers OptimizePlus -loop 0 cropped-magick.gif
Every flag in that line earns its place:
-coalescerebuilds each frame as a full canvas. Skip it and the crop acts on the optimized patches.-crop 180x180+40+0uses the geometry form width x height, plus x, plus y. Note the order differs from FFmpeg, which puts x and y last.+repageresets the virtual canvas. Without it, the file can keep the old 320×180 page size and the offset of the crop, so some viewers show padding or shifted content.-layers OptimizePlusturns the full frames back into small patches and, where it helps, makes the result smaller.-loop 0writes an infinite loop.
ImageMagick keeps each frame’s delay when you coalesce and optimize, so you do not set -delay yourself. After a crop, run the same inspect command from Step 2 on the new file. A cropped frame 1 should now be a small patch inside a 180×180 canvas.
For a centered crop without arithmetic, use -gravity center before -crop:
magick demo.gif -coalesce -gravity center -crop 180x180+0+0 +repage -layers OptimizePlus -loop 0 centered.gif
Steps 8 and 9: crop with GIMP and Photoshop
Pick a desktop editor when you want to place the rectangle by eye, or fix individual frames while you are in there. Both treat a GIF as a stack of layers or frames, so the rule is to crop the image, not a single layer.

Step 8: GIMP 3.2.8. GIMP is free and open source. Its release post for 3.2.8 is dated November 2, 2026, and the 3.2.8 release post lists bug fixes and security updates rather than a GIF-specific crop feature, so the workflow below is the long-standing one.
- Choose File, Open and pick the GIF. GIMP opens each frame as a layer, named with the delay in brackets, such as Frame 1 (60ms).
- Press R for the Rectangle Select tool, drag a rough box, then type exact Position and Size values in the tool options.
- Choose Image, Crop to Selection. This crops every layer, not only the active one. That is the step that preserves the animation.
- Scrub the layers (or use Filters, Animation, Playback) to check that the subject stays inside the box.
- Choose File, Export As, name the file with a .gif extension, and tick As animation and Loop forever.
- Leave the default frame disposal alone unless smears appear, and keep the layer names intact, because GIMP reads the delay hints from them. If you rename layers, you lose per-frame timing.
- Optionally run the optimize filter in the Filters, Animation submenu before exporting, so the file does not hold full-size frames.
Step 9: Photoshop 2027 (28.0). Photoshop is the paid route. Adobe’s pricing lists a prepaid annual plan at US$263.88 per year, and Adobe’s page reportedly advertises a 7-day free trial. The 28.0 release added Relight, AI-assisted edge refinement and expanded generative tools, but Adobe’s November 2026 release notes do not list any change to animated GIF cropping, so the classic Timeline workflow still applies.
- Choose File, Open and pick the GIF. Photoshop builds the frames into layers and shows them in the Timeline. If the Timeline is hidden, open it from the Window menu.
- Select the Crop tool (C). Untick Delete Cropped Pixels so the crop stays reversible, and set a ratio or exact size in the options bar.
- Drag the box, press Enter, and scrub the Timeline to check every frame.
- Choose File, Export, Save for Web (Legacy) and pick GIF. Set Looping Options to Forever, set colors to 256 or lower, and pick a dither level.
- Preview in the dialog, then save. If your build no longer lists Save for Web (Legacy) under the Export menu, use the Photoshop beta or one of the command-line routes instead.
Steps 10 to 12: verify, optimize and export
Step 10: verify. Never trust a crop you have only looked at on one screen. A verify script costs ten seconds and catches lost delays, dropped frames and a missing loop. The one in the next section prints a pass or fail line. Run it for every tool you use:
python3 verify_gif.py demo.gif cropped-ffmpeg.gif
python3 verify_gif.py demo.gif cropped-gifsicle.gif
python3 verify_gif.py demo.gif cropped-magick.gif
Compare delays first, since this is where tools disagree. A GIF that plays noticeably too fast looks fine in a still screenshot and wrong in motion.
Step 11: optimize. Cropping already trims pixels, so files usually shrink. If yours does not, run a final pass with gifsicle. This keeps the animation and shrinks the file:
gifsicle -O3 cropped-ffmpeg.gif -o final.gif
Only optimize once, at the end. Optimizing between crops adds nothing and costs color quality.
Step 12: export and test where it plays. Open the final file in a browser tab and at least one chat or social app. Players differ, and a file that looks right in one can show a flash or a wrong delay in another. Check that it loops, that it does not flicker, that the edges are clean and that a transparent GIF shows the right background on both a light and a dark page. If the GIF is for a platform that re-encodes uploads, test the uploaded version too, because the platform can change the result after your export. Name the file after the shape, such as logo-1x1.gif, so you do not mix crops.
Render settings. Use this table to record the spec of each output. The numbers below describe the demo crop:
| Output | Resolution | Frame rate | Length | Export format |
|---|---|---|---|---|
| Demo, 1:1 center crop | 180×180 | About 12.5 fps (60 ms and 100 ms delays) | Not listed | GIF |
| Demo, 4:3 left crop | 240×180 | About 12.5 fps | Loops forever | GIF |
| Demo, 9:16 center crop | 101×180 | About 12.5 fps | Not listed | GIF |
| Your clip, after Ezgif | Per your rectangle | Unchanged | Unchanged | GIF |
| Your clip, after FFmpeg | Per your rectangle | Unchanged (check) | Unchanged | GIF |
If you build intros or loops for video, the theme pages at Vipid intro themes list resolution, length and frame rate for each theme, which is a useful model for documenting your own GIF specs.
The complete working project
The project is two small Python files and the test generator from Step 1. crop_gif.py crops a GIF by rectangle or by aspect ratio, verify_gif.py proves the animation survived, and both use only Pillow. They run the same on Linux, macOS and Windows. Think of crop_gif.py as a small animated GIF cropper that you own, with no upload, no watermark and no size limit beyond your own memory.
crop_gif.py
The script rebuilds each full frame, crops it, copies the delay from the source frame, and writes the file with the original loop count. It rejects still images and rectangles that fall outside the canvas. It converts to RGB unless the source has transparency, because an unneeded alpha channel makes Pillow’s quantizer worse.
#!/usr/bin/env python3
"""Crop every frame of an animated GIF and keep delays, order and loop count."""
import argparse
import sys
from fractions import Fraction
from PIL import Image, ImageSequence
def parse_rect(text):
try:
x, y, w, h = (int(v) for v in text.split(","))
except ValueError:
raise argparse.ArgumentTypeError("use x,y,w,h as four integers, e.g. 40,0,180,180")
return x, y, w, h
def ratio_rect(src_w, src_h, ratio, anchor):
rw, rh = (int(v) for v in ratio.split(":"))
target = Fraction(rw, rh)
if Fraction(src_w, src_h) > target:
h = src_h
w = int(h * target)
else:
w = src_w
h = int(w / target)
gap_x, gap_y = src_w - w, src_h - h
x = {"left": 0, "center": gap_x // 2, "right": gap_x}.get(anchor, gap_x // 2)
y = {"top": 0, "center": gap_y // 2, "bottom": gap_y}.get(anchor, gap_y // 2)
return x, y, w, h
def main():
p = argparse.ArgumentParser(description=__doc__)
p.add_argument("src")
p.add_argument("dst")
g = p.add_mutually_exclusive_group(required=True)
g.add_argument("--rect", type=parse_rect, help="x,y,w,h in source pixels")
g.add_argument("--ratio", help="aspect ratio such as 1:1, 16:9 or 9:16")
p.add_argument("--anchor", default="center",
choices=["center", "left", "right", "top", "bottom"])
a = p.parse_args()
with Image.open(a.src) as im:
if not getattr(im, "is_animated", False):
sys.exit("error: input is a still image, nothing to animate")
src_w, src_h = im.size
x, y, w, h = a.rect or ratio_rect(src_w, src_h, a.ratio, a.anchor)
if w <= 0 or h <= 0 or x < 0 or y < 0 or x + w > src_w or y + h > src_h:
sys.exit(f"error: rect {x},{y},{w},{h} falls outside the {src_w}x{src_h} canvas")
loop = im.info.get("loop", 0)
mode = "RGBA" if "transparency" in im.info else "RGB"
frames, delays = [], []
for frame in ImageSequence.Iterator(im):
full = frame.convert(mode)
frames.append(full.crop((x, y, x + w, y + h)))
delays.append(frame.info.get("duration", 100))
frames[0].save(
a.dst,
save_all=True,
append_images=frames[1:],
duration=delays,
loop=loop,
disposal=2,
optimize=False,
)
print(f"{a.src}: {src_w}x{src_h} -> {a.dst}: {w}x{h} at +{x}+{y}")
print(f"frames={len(frames)} total_ms={sum(delays)} loop={'forever' if loop == 0 else loop}")
if __name__ == "__main__":
main()
The logic fits in five moves. It reads the source canvas size, then works out the rectangle, either from your --rect numbers or from a --ratio and an --anchor. It checks the rectangle against the canvas. It walks the frames with Pillow’s sequence iterator, which hands over each frame already composited onto the full canvas, so the optimized patches are not a problem. It crops each one and records its delay. Finally it saves the frames with the original loop count and a disposal method that clears each frame, so nothing smears.
You can extend it in small steps. Add a --resize flag after the crop to scale the result, add a --max-colors flag by calling Pillow’s quantize on each frame, or wrap the batch loop in a function that writes a CSV of results. Keep the verify call in every version, because it is the part that tells you the animation is still an animation.
verify_gif.py
This one reads both files, lists frame count, total duration, loop count and per-frame delays, and exits with 0 on a match or 1 on a mismatch, so you can use it in scripts and CI.
#!/usr/bin/env python3
import sys
from PIL import Image, ImageSequence
def info(path):
with Image.open(path) as im:
d = [f.info.get("duration", 0) for f in ImageSequence.Iterator(im)]
return im.size, len(d), sum(d), im.info.get("loop", "none"), d
a, b = info(sys.argv[1]), info(sys.argv[2])
print("source :", a[0], "frames", a[1], "ms", a[2], "loop", a[3])
print("cropped:", b[0], "frames", b[1], "ms", b[2], "loop", b[3])
ok = a[1] == b[1] and a[4] == b[4] and a[3] == b[3]
print("PASS: frame count, per-frame delays and loop match" if ok else "FAIL: timing changed")
sys.exit(0 if ok else 1)
Run it and read the output
python3 make_test_gif.py
python3 crop_gif.py demo.gif out_square.gif --ratio 1:1
python3 crop_gif.py demo.gif out_rect.gif --rect 40,0,180,180
python3 verify_gif.py demo.gif out_square.gif
Example output from the demo file:
demo.gif: 320x180 -> out_square.gif: 180x180 at +70+0
frames=12 total_ms=960 loop=forever
source : (320, 180) frames 12 ms 960 loop 0
cropped: (180, 180) frames 12 ms 960 loop 0
PASS: frame count, per-frame delays and loop match
Pass a rectangle that falls outside the canvas and the script stops with a clear message instead of writing a broken file:
error: rect 300,0,100,100 falls outside the 320x180 canvas
The script writes unoptimized frames, so the file can be bigger than a gifsicle or ImageMagick result. Run the gifsicle pass from Step 11 when size matters.
From the Vipid archive: the animated logo intro theme makes a handy practice clip if you want to try a square crop on a logo loop.
Batch cropping a folder
Ezgif’s Terms point scripted and batch jobs to local tools, and the project above is built for exactly that. This loop crops every GIF in a folder to a centered square and verifies each one. Because the script derives the rectangle from each file’s own size, mixed-size inputs are fine:
mkdir -p cropped
for f in *.gif; do
python3 crop_gif.py "$f" "cropped/$f" --ratio 1:1 && python3 verify_gif.py "$f" "cropped/$f"
done
If every file shares one canvas size and you want one fixed rectangle, gifsicle is faster. Add the optimize flag and the folder shrinks in one pass:
mkdir -p cropped
for f in *.gif; do
gifsicle --unoptimize --crop 40,0+180x180 --optimize=3 "$f" -o "cropped/$f"
done
On Windows PowerShell, the same loop looks like this:
New-Item -ItemType Directory -Force cropped | Out-Null
Get-ChildItem *.gif | ForEach-Object {
python crop_gif.py $_.FullName "cropped\$($_.Name)" --ratio 1:1
}
Batch work has two rules. Keep the originals in a separate folder, and run the verify script over the output folder before you upload anything. A silent timing bug repeated across 200 files is the kind of mistake you only want to make once.
Common pitfalls
These are the mistakes that most often waste an afternoon.
- Cropping a single layer. In GIMP and Photoshop, a crop that touches only the active layer or the first frame produces a still image. Use Crop to Selection in GIMP, and the Crop tool on the whole canvas in Photoshop.
- Forgetting +repage. In ImageMagick, leaving it out can keep the old page geometry, so the cropped file shows padding or a shifted subject in some viewers.
- Measuring on a scaled preview. A browser preview is usually smaller than the real file. Type the numbers into the fields and confirm the output size.
- Judging the crop on frame 1. A subject that wanders toward the edge on frame 40 gets sliced. Scrub the loop and leave a margin of a few pixels.
- Cropping the same file three times. Each save re-quantizes the palette. Keep one master and crop once.
- Resizing before cropping. A resize changes the coordinates, so your planned rectangle no longer fits. Crop first, resize second.
- Trusting the extension. A file named .gif can be an animated WebP or even a video someone renamed. Inspect it with ffprobe before you blame the cropper.
- Using zero-delay frames. Many browsers play frames with a 0 or 1 centisecond delay slower than the file says, so a crop that looks fast in one tool plays differently in another. Keep delays at 2 centiseconds or more when you control them.
Troubleshooting
Match your symptom to a cause below.
- The output is a still image. The tool cropped one frame or one layer. Redo it with an animation-aware route and run the verify script.
- Frames are missing, or the picture flickers. Try a different crop-processing option in Ezgif, or use
--unoptimizein gifsicle or-coalescein ImageMagick. - Moving objects leave trails. The disposal data was lost. Re-export from GIMP with a different frame disposal choice, or use FFmpeg or ImageMagick instead.
- The animation plays too fast or too slow. Delays were reset. In GIMP, restore the delay in the layer names (such as 60ms). In FFmpeg, add
-fps_mode passthroughand compare with the verify script. - The loop plays once and stops. The loop extension is missing. Add
-loop 0in FFmpeg and ImageMagick, tick Loop forever in GIMP, or set Forever in Photoshop’s Save for Web dialog. - The crop is offset or the canvas has padding. In ImageMagick, add
+repageafter-crop. Then inspect the output with the Step 2 command. - Colors look banded or noisy. The palette was rebuilt badly. In FFmpeg, use the palettegen and paletteuse chain. Avoid several save passes.
- The cropped file is bigger than the original. Unoptimized full frames. Run
gifsicle -O3, or-layers OptimizePlusin ImageMagick. - Transparent areas turn black or white. Alpha was flattened. In FFmpeg, use
palettegen=reserve_transparent=1. In the Python project, the script keeps RGBA only when the source reports transparency. - FFmpeg refuses the crop. The rectangle is bigger than the input, or the width or height is zero or negative. Print the size with ffprobe and recompute.
- Ezgif rejects the file. Check the size (200 MB for server-side uploads) and frame count (2,000) quoted in its Terms. Crop locally instead.
- The command magick is not found. You have ImageMagick 6. Use
convertwith the same options, or install version 7. - GIMP exports one frame. You skipped As animation in the export dialog. Export again with it ticked.
Advanced tips
Pan the crop to follow a subject. The FFmpeg crop filter evaluates its x and y expressions for every frame, so you can slide a fixed-size window across the clip. This example moves a 180×180 window 4 pixels per frame and stops at the right edge:
ffmpeg -i wide.gif \
-vf "crop=180:180:'min(n*4,iw-180)':0,split[a][b];[a]palettegen[p];[b][p]paletteuse" \
-loop 0 pan.gif
Find solid borders automatically. If a GIF has a black or white margin you want to remove, cropdetect suggests the rectangle:
ffmpeg -i input.gif -vf cropdetect=limit=24:round=2 -f null -
Read the last crop= suggestion in the log and feed it back into the crop command. Check it by eye, because a dark scene can fool the detector.
Combine crop, frame rate and scale in one pass. Every extra save costs color, so chain edits in one filter graph. Crop first, then cut the frame rate, then resize:
ffmpeg -i input.gif \
-vf "crop=480:480:100:0,fps=12,scale=240:-1:flags=lanczos,split[a][b];[a]palettegen[p];[b][p]paletteuse" \
-loop 0 small-square.gif
Know when to leave GIF. GIF is limited to 256 colors per frame and compresses motion poorly. If the cropped file is still too large, a short MP4 or WebM loop is usually far smaller. Our export and codecs guides cover those formats and when each one plays well.
Mind the motion. A tighter crop makes movement look bigger on screen, and many apps loop a GIF with no pause control. If the source has fast flashing, a close crop makes it more intense for the viewer, so loosen the box or slow the frames before you publish.
Keep a master. Store the original and a crop log (rectangle, tool, date) next to it. When a platform changes its preview shape, you re-crop from the master in a minute instead of re-cropping a degraded copy.
Common questions
What is the best animated GIF cropper? It depends on the job. For one file and no install, use Ezgif’s Crop animated images tool. For repeatable crops and batches, use gifsicle or the Python project above. For frame-level retouching, open GIMP or Photoshop.
Does cropping a GIF reduce quality? The crop itself removes pixels but does not blur the rest. The quality loss comes from re-quantizing the palette on each save. Crop once from your master, and rebuild the palette in the same pass, as the FFmpeg command does.
Can I crop an animated GIF without uploading it? Yes. FFmpeg, gifsicle, ImageMagick, GIMP, Photoshop and the Python project all run on your own machine, so nothing leaves your computer.
Why did my cropped GIF turn into a still image? The tool cropped one frame or one layer. Use an animation-aware route and check the result with the verify script, which fails if the frame count changes.
Is Ezgif free, and are there limits? Ezgif’s Terms of Service, dated November 18, 2026, say the service is provided free of charge. They list a 200 MB upload limit and a 2,000-frame limit for server-side animation processing.
Can I crop a GIF in Mac Preview? It is not a good idea. A Mac-focused guide reports that Preview does not preserve the animation when you crop an animated GIF. Use Ezgif, the Python project, or a command-line tool.
Does cropping change the playback speed? It should not. Delays live in each frame, so a correct crop leaves them alone. If the speed changes, the tool reset the delays, and the verify script will show a mismatch.
More from the Vipid blog
- GIF Into MP4: Convert It With FFmpeg or in Your Browser
- How to Design a YouTube Banner That Survives Every Crop
- How to Create a Picture Slideshow With Music in 12 Steps
- Vipid intro themes resolution, length and frame rate per theme
- Promo themes product and channel promos
- Sample videos finished Vipid intros
- Vipid intro maker make a custom intro in the browser
Jonah Reyes
Jonah Reyes is the Editing & Export Editor at Vipid. He covers editing software, export settings and codecs, and the video specs of YouTube, Shorts, TikTok and Reels, plus OBS and screen recording. He builds Vipid’s spec tables from the platforms’ own documentation and re-checks them every 60 to 90 days, so the numbers in a guide match what the upload dialog actually accepts.


