extractFrame

March 28, 2026 ยท View on GitHub

Extract a specific frame or all frames from an animated GIF or APNG as PNG images.

Usage

openGyver extractFrame <animated-image> [flags]

Arguments

ArgumentRequiredDescription
<animated-image>YesPath to an animated GIF (.gif) or APNG (.png)

Flags

FlagShortTypeDefaultDescription
--frameint0Frame number to extract (0-indexed)
--allboolfalseExtract all frames as individual PNG files
--output-ostringinput_frameN.pngOutput file path
--quiet-qboolfalseSuppress output messages
--json-jboolfalseOutput as JSON

Supported Formats

FormatSingle FrameAll FramesEngine
GIFyesyesPure Go (image/gif)
APNGframe 0 onlynoGo stdlib + ffmpeg fallback

Examples

# Extract first frame (default)
openGyver extractFrame animation.gif

# Extract frame 5
openGyver extractFrame animation.gif --frame 5

# Extract frame to custom path
openGyver extractFrame animation.gif --frame 5 -o keyframe.png

# Extract ALL frames as individual PNGs
openGyver extractFrame animation.gif --all
# Creates: animation_000.png, animation_001.png, animation_002.png, ...

# Extract all frames to a specific directory
openGyver extractFrame animation.gif --all -o frames/frame.png
# Creates: frames/frame_000.png, frames/frame_001.png, ...

# Extract from APNG (frame 0)
openGyver extractFrame animated.png --frame 0

# JSON output
openGyver extractFrame animation.gif --frame 3 -j

# Quiet mode
openGyver extractFrame animation.gif --frame 0 -o thumb.png -q

JSON Output Format

Single Frame

{
  "success": true,
  "input": "animation.gif",
  "output": "animation_frame3.png",
  "frame": 3,
  "total_frames": 24
}

All Frames

{
  "success": true,
  "input": "animation.gif",
  "total_frames": 24,
  "files": [
    "animation_000.png",
    "animation_001.png",
    "animation_002.png"
  ]
}

Notes

  • GIF extraction is pure Go โ€” no external tools needed. Works on any platform.
  • APNG frame 0 uses Go's standard image/png decoder (which returns the default image). For other APNG frames, ffmpeg is required.
  • Frame numbers are 0-indexed. A GIF with 10 frames has frames 0-9.
  • All output frames are saved as PNG regardless of input format.
  • When using --all, frames are numbered with 3-digit zero-padding (000, 001, ...).