加载中...
avatar

用GIFSicle压缩gif图片

gifsicle是一个用于操作 GIF 图片的命令行工具,可以对gif文件进行修改尺寸大小、颜色、帧率等等,功能十分强大。

软件下载地址:https://eternallybored.org/misc/gifsicle/

使用之前要先进入gifsicle所在的文件夹,再打开cmd命令行,执行压缩命令。如下图:

img

自动压缩:

gifsicle -03 large.gif -o small.gif
(注:O3第一个为大写字母,第二个为数字,o为字母)

这条命令的好处就是让程序自动为你选择压缩方案,一般能在画质和体积之间取得平衡,并且第一帧之后的每一帧都能得到优化。

gifsicle -O3 –colors=256 –lossy=80 -o 压缩后.gif 压缩前.gif

调整 –lossy 你想要的质量参数(30-200 数字越大压缩后文件越小,但质量也会降低,推荐80 )。

当 –lossy 很少的损失被引入时,它效果最好,并且由于压缩算法的限制,非常高的损耗水平不会获得太多的收益。

C:\Users\tony\Desktop\gifsicle-1.92>gifsicle large.gif -O3 –colors=128 –lossy=80 –scale 0.9 -o small_dog.gif

按比例压缩:

gifsicle.exe large.gif –scale 0.5 -o small.gif

–scale 0.5 指的是图片的宽和高缩小为原来的 0.5 倍。

自定义压缩:

gifsicle -O3 large.gif -o small.gif –colors 64

–colors 64 指的是使用调色盘的长度,可以是256,128,64,32,16等等。数字越小,压缩率越高,图片质量的损失度也越大.

–colors 16

–colors 4

–colors 2

你还可以对 GIF 进行旋转、修改颜色、修改帧率等等,功能非常强大,这里就不赘述了,想了解的话,执行 gifsicle.exe --help 即可。

GIF 这算法压缩率确实不太行,所以都是通过控制参数来控制体积,自动不如手动来。
建议用 PS 压缩,(文件 /输出为网络格式 即可调整参数)以下几项参数按影响权重由高到低排列

  1. [尺寸] 对体积影响最大
  2. [帧数] 适当抽帧。比如 18fps 会比 24fps 体积大得多
  3. [品质] 可选 Liner 、两次立方。一般选两次立方即可
  4. [仿色] 可以设定百分比,对画质影响较大,慎用
  5. [色彩深度] 可以设置为 265/128 等 bit 位深,体积影响较小,但也会有影响

上面的因素中, 1 、 2 两项影响最大,拿这两项开刀,效果占总效果 80%以上
最后,可以适当选择”扩散”、”图案”等,根据画面对症下药(用渐变色测试能明显看出区别)。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
C:\Users\tony\Desktop\gifsicle-1.92>gifsicle --help
'Gifsicle' manipulates GIF images. Its most common uses include combining
single images into animations, adding transparency, optimizing animations for
space, and printing information about GIFs.

Usage: gifsicle [OPTION | FILE | FRAME]...

Mode options: at most one, before any filenames.
-m, --merge Merge mode: combine inputs, write stdout.
-b, --batch Batch mode: modify inputs, write back to
same filenames.
-e, --explode Explode mode: write N files for each input,
one per frame, to 'input.frame-number'.
-E, --explode-by-name Explode mode, but write 'input.name'.

General options: Also --no-OPTION for info and verbose.
-I, --info Print info about input GIFs. Two -I's means
normal output is not suppressed.
--color-info, --cinfo --info plus colormap details.
--extension-info, --xinfo --info plus extension details.
--size-info, --sinfo --info plus compression information.
-V, --verbose Prints progress information.
-h, --help Print this message and exit.
--version Print version number and exit.
-o, --output FILE Write output to FILE.
-w, --no-warnings Don't report warnings.
--no-ignore-errors Quit on very erroneous input GIFs.
--conserve-memory Conserve memory at the expense of speed.
--multifile Support concatenated GIF files.

Frame selections: #num, #num1-num2, #num1-, #name

Frame change options:
--delete FRAMES Delete FRAMES from input.
--insert-before FRAME GIFS Insert GIFS before FRAMES in input.
--append GIFS Append GIFS to input.
--replace FRAMES GIFS Replace FRAMES with GIFS in input.
--done Done with frame changes.

Image options: Also --no-OPTION and --same-OPTION.
-B, --background COL Make COL the background color.
--crop X,Y+WxH, --crop X,Y-X2,Y2
Crop the image.
--crop-transparency Crop transparent borders off the image.
--flip-horizontal, --flip-vertical
Flip the image.
-i, --interlace Turn on interlacing.
-S, --logical-screen WxH Set logical screen to WxH.
-p, --position X,Y Set frame position to (X,Y).
--rotate-90, --rotate-180, --rotate-270, --no-rotate
Rotate the image.
-t, --transparent COL Make COL transparent.

Extension options:
--app-extension N D Add an app extension named N with data D.
-c, --comment TEXT Add a comment before the next frame.
--extension N D Add an extension number N with data D.
-n, --name TEXT Set next frame's name.
--no-comments, --no-names, --no-extensions
Remove comments (names, extensions) from input.
Animation options: Also --no-OPTION and --same-OPTION.
-d, --delay TIME Set frame delay to TIME (in 1/100sec).
-D, --disposal METHOD Set frame disposal to METHOD.
-l, --loopcount[=N] Set loop extension to N (default forever).
-O, --optimize[=LEVEL] Optimize output GIFs.
-U, --unoptimize Unoptimize input GIFs.
-j, --threads[=THREADS] Use multiple threads to improve speed.

Whole-GIF options: Also --no-OPTION.
--careful Write larger GIFs that avoid bugs in other
programs.
--change-color COL1 COL2 Change COL1 to COL2 throughout.
-k, --colors N Reduce the number of colors to N.
--color-method METHOD Set method for choosing reduced colors.
-f, --dither Dither image after changing colormap.
--gamma G Set gamma for color reduction [2.2].
--lossy[=LOSSINESS] Alter image colors to shrink output file size
at the cost of artifacts and noise.
--resize WxH Resize the output GIF to WxH.
--resize-width W Resize to width W and proportional height.
--resize-height H Resize to height H and proportional width.
--resize-fit WxH Resize if necessary to fit within WxH.
--scale XFACTOR[xYFACTOR] Scale the output GIF by XFACTORxYFACTOR.
--resize-method METHOD Set resizing method.
--resize-colors N Resize can add new colors up to N.
--transform-colormap CMD Transform each output colormap by shell CMD.
--use-colormap CMAP Set output GIF's colormap to CMAP, which can
be 'web', 'gray', 'bw', or a GIF file.
文章作者: 蕾米亚
文章链接: http://omimo.ga/2020/48db5661.html
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 彭彭和丁满
打赏
  • 微信
    微信
  • 支付寶
    支付寶

评论