convert input.gif -coalesce -repage 0x0 -crop WxH+X+Y +repage output.gif
- Animated gifs are often optimised to save space, but imagemagick doesn’t seem to consider this when applying the crop command and treats each frame individually.
-coalesce
rebuilds the full frames.
- Other commands will take into consideration the offset information supplied in the original gif, so you need to force that to be reset with
-repage 0x0
.
- The crop itself is straightforward, with width, height, x offset and y offset supplied respectively. For example, a crop 40 wide and 30 high at an x offset of 50 = 40×30+50+0.
- Crop does not remove the canvas that it snipped from the image. Applying
+repage
after the crop will do this.