gifsicle 命令详解

| 选择喜欢的代码风格  

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

gifsicle 命令安装:


  1. -bash: gifsicle: command not found
  2.  
  3. #Debian
  4. apt-get install gifsicle
  5.  
  6. #Ubuntu
  7. apt-get install gifsicle
  8.  
  9. #CentOS
  10. yum install gifsicle
  11.  
  12. #Alpine
  13. apk add gifsicle
  14.  
  15. #Arch Linux
  16. pacman -S gifsicle
  17.  
  18. #Kali Linux
  19. apt-get install gifsicle
  20.  
  21. #Fedora
  22. dnf install gifsicle
  23.  
  24. #OS X
  25. brew install gifsicle
  26.  
  27. #Raspbian
  28. apt-get install gifsicle
  29.  
  30. #Docker
  31. docker run cmd.cat/gifsicle gifsicle
  32.  
  33. #Windows
  34. https://eternallybored.org/misc/gifsicle/

gifsicle 命令补充说明:


gifsicle 是一个功能强大的命令行程序,用于创建、编辑、处理和获取有关 GIF 图像和动画的信息,可以批量处理生成 GIF

gifsicle 命令语法:


  1. gifsicle [options, frames, and filenames]...

gifsicle 命令选项:


  1. Mode options: at most one, before any filenames.
  2. -m, --merge Merge mode: combine inputs, write stdout.
  3. -b, --batch Batch mode: modify inputs, write back to
  4. same filenames.
  5. -e, --explode Explode mode: write N files for each input,
  6. one per frame, to 'input.frame-number'.
  7. -E, --explode-by-name Explode mode, but write 'input.name'.
  8.  
  9. General options: Also --no-OPTION for info and verbose.
  10. -I, --info Print info about input GIFs. Two -I's means
  11. normal output is not suppressed.
  12. --color-info, --cinfo --info plus colormap details.
  13. --extension-info, --xinfo --info plus extension details.
  14. --size-info, --sinfo --info plus compression information.
  15. -V, --verbose Prints progress information.
  16. -h, --help Print this message and exit.
  17. --version Print version number and exit.
  18. -o, --output FILE Write output to FILE.
  19. -w, --no-warnings Don't report warnings.
  20. --no-ignore-errors Quit on very erroneous input GIFs.
  21. --conserve-memory Conserve memory at the expense of speed.
  22. --multifile Support concatenated GIF files.
  23.  
  24. Frame selections: #num, #num1-num2, #num1-, #name
  25.  
  26. Frame change options:
  27. --delete FRAMES Delete FRAMES from input.
  28. --insert-before FRAME GIFS Insert GIFS before FRAMES in input.
  29. --append GIFS Append GIFS to input.
  30. --replace FRAMES GIFS Replace FRAMES with GIFS in input.
  31. --done Done with frame changes.
  32.  
  33. Image options: Also --no-OPTION and --same-OPTION.
  34. -B, --background COL Make COL the background color.
  35. --crop X,Y+WxH, --crop X,Y-X2,Y2
  36. Crop the image.
  37. --crop-transparency Crop transparent borders off the image.
  38. --flip-horizontal, --flip-vertical
  39. Flip the image.
  40. -i, --interlace Turn on interlacing.
  41. -S, --logical-screen WxH Set logical screen to WxH.
  42. -p, --position X,Y Set frame position to (X,Y).
  43. --rotate-90, --rotate-180, --rotate-270, --no-rotate
  44. Rotate the image.
  45. -t, --transparent COL Make COL transparent.
  46.  
  47. Extension options:
  48. --app-extension N D Add an app extension named N with data D.
  49. -c, --comment TEXT Add a comment before the next frame.
  50. --extension N D Add an extension number N with data D.
  51. -n, --name TEXT Set next frame's name.
  52. --no-comments, --no-names, --no-extensions
  53. Remove comments (names, extensions) from input.
  54. Animation options: Also --no-OPTION and --same-OPTION.
  55. -d, --delay TIME Set frame delay to TIME (in 1/100sec).
  56. -D, --disposal METHOD Set frame disposal to METHOD.
  57. -l, --loopcount[=N] Set loop extension to N (default forever).
  58. -O, --optimize[=LEVEL] Optimize output GIFs.
  59. -U, --unoptimize Unoptimize input GIFs.
  60. -j, --threads[=THREADS] Use multiple threads to improve speed.
  61.  
  62. Whole-GIF options: Also --no-OPTION.
  63. --careful Write larger GIFs that avoid bugs in other
  64. programs.
  65. --change-color COL1 COL2 Change COL1 to COL2 throughout.
  66. -k, --colors N Reduce the number of colors to N.
  67. --color-method METHOD Set method for choosing reduced colors.
  68. -f, --dither Dither image after changing colormap.
  69. --gamma G Set gamma for color reduction [2.2].
  70. --resize WxH Resize the output GIF to WxH.
  71. --resize-width W Resize to width W and proportional height.
  72. --resize-height H Resize to height H and proportional width.
  73. --resize-fit WxH Resize if necessary to fit within WxH.
  74. --scale XFACTOR[xYFACTOR] Scale the output GIF by XFACTORxYFACTOR.
  75. --resize-method METHOD Set resizing method.
  76. --resize-colors N Resize can add new colors up to N.
  77. --transform-colormap CMD Transform each output colormap by shell CMD.
  78. --use-colormap CMAP Set output GIF's colormap to CMAP, which can
  79. be 'web', 'gray', 'bw', or a GIF file.

gifsicle 命令实例


gifsicle 优化 GIF

  1. gifsicle --batch --optimize=3 amin.gif

使用 gifsicle 制作 GIF 动画:

  1. gifsicle --delay=10 --loop *.gif > anim.gif

gifsicle 从动画中提取帧:

  1. gifsicle anim.gif '#0' > firstframe.gif

通过 gifsicle, 您还可以通过替换,删除或插入帧来编辑动画:

  1. gifsicle -b anim.gif --replace '#0' new.gif

gifsicle 命令扩展阅读:




gifsicle 命令评论