#compdef timg

_timg() {
  # local context state line expl ret=1
  # typeset -A opt_args
  _arguments -s \
    '-p[Pixelation (half/quarter blocks, kitty/iTerm2/sixel graphics]:pixelation[half/quarter blocks, kitty/iTerm2/sixel graphics]:(h i k q s)' \
    '--grid=[Arrange images in a grid ("contact sheet")]:<cols>[x<rows>]:' \
    {-C,--center}'[Center image horizontally in available cell]' \
    '--title[Print title above each image (Env-var TIMG_DEFAULT_TITLE)]' \
    '--title=[Print title above each image (Env-var TIMG_DEFAULT_TITLE)]:fmt_str<decoder, basename, filename, height, width>:(%D %b %f %h %w)' \
    '-f[Read newline-separated list of image files (current directory)]:filelist:_files' \
    '-F[like -f, but relate to the directory containing filelist]:filelist:_files:' \
    '-b[Background color to use behind alpha channel]:str:(yellow rrggbb auto none)' \
    '-B[Checkerboard pattern color to use on alpha]:str:' \
    '--pattern-size=[Integer factor scale of the checkerboard pattern]:n:' \
    '--auto-crop[Crop away all same-color pixels around image]' \
    '--auto-crop=[Crop away all same-color pixels around image]:pre-crop:' \
    '--rotate=[Rotate according to included exif orientation]:rotate:(exif off):' \
    {-W,--fit-width}'[Scale to fit width, even if it exceeds height]' \
    '-U[Allow Upscaling. Enlarge to fit smaller images (e.g. icon)]' \
    '--upscale=[Allow Upscaling. Enlarge to fit smaller images (e.g. icon)]:integer:(i)' \
    '--clear[Clear first. '\''every'\'' is useful with -w/-wr, not with --grid]' \
    '--clear=[Clear first. '\''every'\'' is useful with -w/-wr, not with --grid]:clear:(every)' \
    '-V[Video subsystem. Don'\''t probe decoding (streaming from stdin)]' \
    '-I[Only use Image subsystem. Don'\''t attempt video decoding]' \
    '-w[Wait time between images (Default: 0.0)]:seconds:' \
    '-wr[like above, but wait time between rows in grid]:seconds' \
    '-a[Switch off anti-aliasing (Default: on)]' \
    '-g[Output geometry. -g<w>x or -gx<h> is possible. Default: 97x29]:<w>x<h>:' \
    '-o[Write to <outfile> instead of stdout]:outfile:' \
    '-E[Don'\''t hide the cursor while showing images]' \
    '--compress[Only for -pk or -pi: Compress image data. More CPU, less BW]' \
    '--compress=[Only for -pk or -pi: Compress image data. More CPU, less BW]:level:' \
    '--threads=[Run image decoding in parallel with n threads(Default: 6)]:n:' \
    '--color8[Choose 8 bit color mode for -ph or -pq]' \
    '--version[Print detailed version including used libraries]' \
    '--verbose[Print some terminal query info and stats]' \
    '-h[Print this help and exit]' \
    '--help[Page through detailed manpage-like help and exit]' \
    '--scroll[Scroll horizontally (optionally: delay ms (60))]' \
    '--scroll=[Scroll horizontally (optionally: delay ms (60))]:ms:' \
    '--delta-move=[delta x and delta y when scrolling (Default: 1:0)]:<dx\:dy>:' \
    '--loops=[Number of runs through a full cycle. -1 means '\''forever'\'']:num:' \
    '--frames=[Only show first num frames (if looping, loop only these)]:num:' \
    '--frame-offset=[Start animation/video at this frame]:num:' \
    '-t[Stop after this time, independent of --loops or --frames]:seconds:' \
    '*:file:_files'
}

_timg "$@"
