url: https://cdn.star.nesdis.noaa.gov/GOES18/ABI/SECTOR/np/GEOCOLOR/GOES18-NP-GEOCOLOR-900x540.gif Conversation with gemini... ================================================================================ is there a way to crop and resize an animated gif? Yes, absolutely. Since we established you are using ImageMagick v6 (convert), you can do both operations in a single command. The most important rule when editing animated GIFs is to use the -coalesce flag first. This "un-optimizes" the GIF so every frame is a full picture before you start cutting it. If you skip this, your cropped GIF will look like a glitchy mess of static. The Command Structure Generally, you want to Crop first, then Resize the result (or vice versa depending on your goal). Scenario A: Crop a piece out, then shrink it (e.g., "Cut out the center 500x500 box, then resize that to a 100x100 thumbnail") Bash convert input.gif -coalesce -crop 500x500+10+10 +repage -resize 100x100 -layers Optimize output.gif Scenario B: Resize the whole thing, then trim it (e.g., "Shrink the image to 300 wide, then crop off the bottom") Bash convert input.gif -coalesce -resize 300x -crop 300x200+0+0 +repage -layers Optimize output.gif Explanation of the Flags -coalesce: Crucial. It reconstructs every frame of the animation to be a full image. Without this, cropping breaks the animation transparency. -crop WxH+X+Y: WxH: The width and height of the cutout box. +X+Y: The starting coordinate (top-left corner). +0+0 is top left. +50+50 moves the box 50px right and 50px down. +repage: Crucial. After cropping, ImageMagick remembers the original canvas size (virtual canvas). This flag tells it "Forget the old size, the cropped size is the new canvas." If you forget this, your GIF will just be a tiny square floating in a large empty background. -resize WxH: Standard resizing. -layers Optimize: Re-compresses the GIF so the file size isn't massive. PHP Example Here is how you would run "Crop center 400x400 then resize to 200x200" in your PHP script: PHP 2. Crop -> 3. Reset Canvas -> 4. Resize -> 5. Optimize // This crops a 400x400 square starting at x=50, y=50 $cmd = "convert $input -coalesce -crop 400x400+50+50 +repage -resize 200x200 -layers Optimize $output"; exec($cmd); echo ""; ?> Gravity Crop (Easier) If you just want to "Crop the dead center" without doing math for X and Y coordinates, use -gravity center: Bash convert input.gif -coalesce -gravity center -crop 400x400+0+0 +repage output.gif Gemini can