美文网首页
[Gifsicle],压缩、优化gif的命令行工具 —— 中英文

[Gifsicle],压缩、优化gif的命令行工具 —— 中英文

作者: 辛德瑞拉Dangerous | 来源:发表于2018-12-05 17:06 被阅读0次

    声明:业余时间闲着无聊,正好用到了这个gifsicle,觉得挺好用的一个工具,所以就把官方的使用文档给简单翻译了一下,不对正确之处,勿喷,还望指正;如果觉得不妥,还是官方文档为准。虽然gifsicle使用并不是很难,但是命令还挺多的,然而简书的mrkdown语法不支持页面跳转,我这里用注脚的方式写了个目录,但是目录在文档末尾,比较麻烦;最好的方式是使用Ctrl+F在整个页面搜索所需命令及其释义和示例。文档中 【🏹:xxxxxx 】为翻译内容。


    NAME[1]

    gifsicle − manipulates GIF images and animations 【🏹:操作GIF图片和动画】

    SYNOPSIS(概要)[2]

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

    DESCRIPTION(描述)[3]

    gifsicle is a powerful command-line program for creating, editing, manipulating, and getting information about GIF images and animations.【🏹:gifsicle是一个款强大的用于创建、编辑、操作GIF图片和动画以及获取GIF的信息的命令行程序.】

    Gifsicle normally processes input GIF files according to its command line options and writes the result to the standard output. The −i option, for example, tells gifsicle to interlace its inputs:【🏹:Gifsicle一般情况下, 根据命令行的可选命令来处理输入的GIF文件. 如命令 −i, 它会告知 gifsicle 去结合它的输入文件:】

    gifsicle −i < pic.gif > interlaced-pic.gif

    Gifsicle is good at creating and manipulating GIF animations. By default, it combines two or more input files into a “flipbook” animation:【🏹:Gifsicle 善于创建和操作GIF动画。默认情况,它会合并(串联)2个或者更多文件到一个可以轮播的动画中:】

    gifsicle pic1.gif pic2.gif pic3.gif > animation.gif

    Use options like −−delay, −−loopcount, and −−optimize to tune your animations.【🏹:使用可选命令,像 −−delay, −−loopcount, 和 −−optimize 来调整你的GIF动画.】

    To modify GIF files in place, use the −−batch option. With −−batch, gifsicle will modify the files you specify instead of writing a new file to the standard output. To interlace(使结合、使交错)all the GIFs in the current directory, you could say:【🏹:适当修改GIF文件, 使用可选命令 −−batch. ,使用 −−batch, gifsicle 将修改您指定的文件,而不是将新文件写入到标准输出. 为了结合当前目录下的所有GIF动画, 你可以使用如下命令:】

    gifsicle −−batch −i *.gif

    New users may want to skip to the Examples section at the end.【🏹:新用户可能希望直接跳到最后的Examples(示例)部分.】

    CONCEPT INDEX(概念索引)[4]

    Concepts are on the left, relevant gifsicle options are on the right.【🏹:左侧是概念, 相应的 gifsicle 命令在右侧.】

    此部分略

    COMMAND LINE(命令行)[5]

    gifsicle’s command line consists of GIF input files and options. Most options start with a dash (−) or plus (+); frame ,selections, a kind of option, start with a number sign (#). Anything else is a GIF input file.【🏹:gifsicle’s 命令行包含GIF输入文件和命令可选项. 大部分命令可选项是以(−)和(+)开头; 帧的选择(frame selections), 是一种可选命令, 它是以(#)开头.其他任何东西都是GIF输入文件.】

    gifsicle reads and processes GIF input files in order. If no GIF input file is given, or you give the special filename ‘−’, it reads from the standard input.【🏹:gifsicle 按顺序读取和处理GIF输入文件.如果没有给出GIF输入文件,或者您给出特殊文件名 ‘−’, 它从标准输入读取.】

    gifsicle exits with status 0 if there were no errors and status 1 otherwise.【🏹:gifsicle 会退出如果没有错误,状态为0,否则状态为1.】

    OPTIONS(可选命令行)[6]

    Every option has a long form, ‘−−long−descriptive−name’. You don’t need to type the whole long descriptive name, just enough to make it unambiguous.【🏹:每个可选项命令行都有很长的形式,‘ −−long−descriptive−name ’. 您不需要键入整个长描述性名称,使其明确无误就足够了.】

    Some options also have a short form, ‘−X’. You can combine short options if they don’t take arguments: ‘−IIb’ is the same as ‘−I −I −b’. But be careful with options that do take arguments: ‘−cblah’ means ‘−c blah’, not ‘−c −b −l −a −h’.【🏹:有些可选项命令行也有简短形式, ‘−X’.如果不带参数,您可以组合这些短选项,例如:‘−IIb’和‘−I −I −b’是一样的.但要注意那些带参数的选项,例如:‘−cblah’ 的意思是‘−c blah’, 而不是 ‘−c −b −l −a −h’的组合.】

    Many options also have a converse, ‘−−no−option’, which turns off the option. You can turn off a short option ‘−X’ by saying ‘+X’ instead.【🏹:很多可选命令也有自身相反的命令, ‘−−no−option’,这个命令的意思是可以关闭可选项. 您可以通过说‘+X’ 来关闭短选项‘−X’.】

    Mode Options

    Mode options tell gifsicle what kind of output to generate. There can be at most one, and it must precede any GIF inputs.【🏹:模式命令选项告诉 gifsicle 要生成什么样的输出。最多可以有一个,它必须在任何GIF输入之前.】

    −−merge, −m
    Combine all GIF inputs into one file with multiple frames and write that file to the standard output. This is the default mode.【🏹:将所有GIF输入合并为一个具有多个帧的文件,并将该文件写入标准输出。 这是默认模式.】

    −−batch, −b
    Modify each GIF input in place by reading and writing to the same filename. (GIFs read from the standard input are written to the standard output.)【🏹:通过读取和写入相同的文件名来修改每个GIF输入。(从标准输入读取的GIF将写入标准输出.)】

    −−explode, −e
    Create an output GIF for each frame of each input file. The output GIFs are named ‘xxx.000’, ‘xxx.001’, and so on, where ‘xxx’ is the name of the input file (or whatever you specified with ‘−−output’) and the numeric extension is the frame number.【🏹:为每个输入文件的每个帧创建一个输出GIF。 输出GIF名为'xxx.000','xxx.001',依此类推,其中'xxx'是输入文件的名称(或者您使用‘ −−output ’指定的任何名称)数字扩展名为 帧号.】

    −−explode−by−name, −E
    Same as −−explode, but write any named frames to files ‘xxx.name’ instead of ‘xxx.frame-number’. Frames are named using the ‘−−name’ option.【🏹:与−−explode相同,但将任何命名帧写入文件'xxx.name'而不是'xxx.frame-number'。 框架使用−−name选项命名.】

    General Options

    General options control the information gifsicle prints and where it writes its output. The info options and −−verbose can be turned off with ‘−−no−X’. −−info, −I

    Print a human-readable description of each input GIF to the standard output, or whatever file you specify with −o. This option suppresses normal output, and cannot be combined with mode options like −−batch. If you give two −−info or −I options, however, information is printed to standard error, and normal output takes place as usual.

    −−color−info,
    −−cinfo

    Like −−info, but also print information about input files’ colormaps.

    −−extension−info,
    −−xinfo

    Like −−info, but also print any unrecognized GIF extensions in a hexdump(1)-like format.

    −−size−info,
    −−sinfo

    Like −−info, but also print information about compressed image sizes.

    −−help,
    −h

    Print usage information and exit.

    −o file
    −−output file

    Send output to file. The special filename ‘-’ means the standard output.

    −−verbose,
    −V

    Print progress information (files read and written) to standard error.【🏹:将进度信息(读取和写入的文件)打印到标准错误.】

    −−no−warnings,
    −w

    Suppress all warning messages.【🏹:禁止显示所有警告消息.】

    −−no−ignore−errors

    Exit with status 1 when encountering a very erroneous GIF. Default is to muddle on.【🏹:遇到非常错误的GIF时退出状态1. 默认是混乱.】

    −−version

    Print the version number and some short non-warranty information and exit.

    −−careful

    Write slightly larger GIFs that avoid bugs in some other GIF implementations. Some Java and Internet Explorer versions cannot display the correct, minimal GIFs that Gifsicle produces. Use the −−careful option if you are having problems with a particular image.

    −−conserve−memory

    Conserve memory usage at the expense of processing time. This may be useful if you are processing large GIFs on a computer without very much memory. Or say −−no−conserve−memory.

    −−nextfile

    Allow input files to contain multiple concatenated GIF images. If a filename appears multiple times on the command line, gifsicle will read a new image from the file each time. This option can help scripts avoid the need for temporary files. For example, to create an animated GIF with three frames with different delays, you might run "gifsicle −−nextfile −d10 − −d20 − −d30 − > out.gif" and write the three GIF images, in sequence, to gifsicle’s standard input.

    −−multifile

    Like −−nextfile, but read as many GIF images as possible from each file. This option is intended for scripts. For example, to merge an unknown number of GIF images into a single animation, run "gifsicle −−multifile − > out.gif" and write the GIF images, in sequence, to gifsicle’s standard input. Any frame selections apply only to the last file in the concatenation.

    Frame Selections

    A frame selection tells gifsicle which frames to use from the current input file. They are useful only for animations, as non-animated GIFs only have one frame. Here are the acceptable forms for frame specifications.

    参数 含义
    #num Select frame num. (The first frame is‘#0’. Negative numbers count backwardsfrom the last frame, which is ‘#-1’.)
    #num1num2 Select frames num1 through num2.
    #num1 Select frames num1 through the last frame.
    #name Select the frame named name.

    The ‘#’ character has special meaning for many shells, so you generally need to quote it.

    For example,

    gifsicle happy.gif "#0"

    uses the first frame from happy.gif;

    gifsicle happy.gif "#0-2"

    uses its first three frames; and

    gifsicle happy.gif "#-1-0"

    uses its frames in reverse order (starting from frame #-1 −− the last frame −− and ending at frame #0 −− the first).

    The action performed with the selected frames depends on the current mode. In merge mode, only the selected frames are merged into the output GIF. In batch mode, only the selected frames are modified; other frames remain unchanged. In explode mode, only the selected frames are exploded into output GIFs.

    Frame Change Options

    Frame change options insert new frames into an animation or replace or delete frames that already exist. Some things −− for example, changing one frame in an animation −− are difficult to express with frame selections, but easy with frame changes. 【🏹:帧改变选项命令(Frame change options)会向一个动画中插入一个新的帧或者代替、删除一些帧从已存在的动画中。有些事−−例如,在帧选择选项命令(frame selections)改变一帧是困难的,但是帧改变选项命令(Frame change options)就很容易.】

    −−delete frames [frames...]
    Delete frames from theinput GIF 【🏹:(删除帧;可以连续选择多个帧删除).】

    示例:gifsicle b.gif --delete "#0" -o test.gif

    −−insert−before frame other-GIFs
    Insert other-GIFs before frame in the input GIF【🏹:(在指定frame前插入其他GIF动画(other-GIFs)).】

    示例:gifsicle a.gif −−insert−before "#2" b.gif -o test.gif

    −−append other-GIFs
    Append other-GIFs to the input GIF【🏹:(在一个GIF动画后面加入其他GIF动画(other-GIFs)).】

    示例:gifsicle a.gif --append b.gif -o test.gif

    −−replace frames other-GIFs
    Replace frames from the input GIF with other-GIFs【🏹:(将指定帧(frames)替换成其他GIF动画(other-GIFs)).】

    示例:gifsicle a.gif --replace "#2" b.gif -o test.gif

    −−done
    Complete the current set of frame changes 【🏹:(完成了对当前帧集的更改).】

    The frames arguments are frame selections (see above). These arguments always refer to frames from the original input GIF. So, if ‘a.gif’ has 3 frames and ‘b.gif’ has one, this command【🏹:参数 frames 是帧选择命令可选项(frame selections)表示的 (请看之前frame selections的相关命令).这些参数总是涉及到原始输入GIF动画的帧. 因此,以下命令的意思是,删除‘a.gif’的第一帧,然后将‘a.gif’的第三帧用‘b.gif’替换了】

    gifsicle a.gif −−delete "#0" −−replace "#2" b.gif

    will produce an output animation with 2 frames: ‘a.gif’ frame 1, then ‘b.gif’.【🏹:这命令将产生一个删除了‘a.gif’的第一帧,然后将‘a.gif’的第三帧用‘b.gif’替换了的动画. 注意:这2个命令不能一起使用,否则会提示警告: gifsicle: fatal error: frame selection and frame changes don't mix

    The other-GIFs arguments are any number of GIF input files and frame selections. These images are combined in merge mode and added to the input GIF. The other-GIFs last until the next frame change option, so this command replaces the first frame of ‘in.gif’ with the merge of ‘a.gif’ and ‘b.gif’:【🏹:参数:other-GIFs,可以任意数量的GIF文件或者帧(通过frame selections获取的)。在合并模式这些图像组合并添加到输入GIF。other-GIFs 会持续到下一个帧更改选项(frame change option),所以这个命令的意思是:将‘a.gif’ and ‘b.gif’合并后替换掉‘in.gif’的第一帧】

    gifsicle −b in.gif −−replace "#0" a.gif b.gif

    This command, however, replaces the first frame of ‘in.gif’ with ‘a.gif’ and then processes‘b.gif’ separately:【🏹:但是,这个命令用'a.gif'替换'in.gif'的第一帧,然后分别处理'b.gif':】

    gifsicle −b in.gif −−replace "#0" a.gif −−done b.gif

    Warning: You shouldn’t use both frame selections and frame changes on the same input GIF.【🏹:Warning: 不能对同一个输入的GIF动画,同时使用frame selections and frame changes命令. 其实没太明白这句话的意思,按照我的理解应该是不同同时使用2个都具有frame selections and frame changes的命令,而不是不能同时使用frame selections and frame changes命令】

    Image Options

    Image options modify input images −− by changing their interlacing, transparency, and cropping, for example. Image options have three forms: ‘−−X’, ‘−−no−X’, and ‘−−same−X’. The ‘−−X’ form selects a value for the feature, the ‘−−no−X’ form turns off the feature, and the ‘−−same−X’ form means that the feature’s value is copied from each input. The default is always ‘−−same−X’. For example, −background="#0000FF" sets the background color to blue, −−no−background turns the background color off (by setting it to 0), and −−same−background uses input images’ existing background colors. You can give each option multiple times; for example,【🏹:图像命令可选项(Image options)可修改输入图像, 通过改变他们的interlacing, transparency, and cropping. 例如,Image options有三种形式:‘−−X’, ‘−−no−X’, 和 &lsquo −−same−X’. ‘−−X’ 形式是为某个特性选择一个值, ‘−−no−X’ 的形式是关闭这个特性, 而‘−−same−X’ 形式是从输入的文件中复制特性的值. 默认情况总是‘−−same−X’ 例如:−background="#0000FF"意思是设置背景色为蓝色;−−no−background意思是关闭了背景色选项(通过设置它为0); −−same−background 的意思是使用和输入图像一样的背景色.您可以多次提供每个选项;例如,】

    gifsicle −b −O2 −i a.gif −−same−interlace b.gif c.gif

    will make ‘a.gif’ interlaced, but leave ‘b.gif’ and ‘c.gif’ interlaced only if they were already.【🏹:这个interlaced一直不知道啥意思,哎,暂时没有理解???】

    −B color
    −−background color

    Set the output GIF’s background to color. The argument can have the same forms as in the −−transparent option below【🏹:(设置背景色,这个和−−transparent 有着相同的用法).】

    示例:gifsicle -B 255 -i 1.gif "#0" -o test.gif

    −−crop x1,y1-x2,y2
    −−crop x1,y1+widthxheight

    Crop the following input frames to a smaller rectangular area. The top-left corner of this rectangle is (x1,y1); you can give either the lower-right corner, (x2,y2), or the width and height of the rectangle. In the x1,y1+widthxheight form,width and height can be zero or negative. A zero dimension means the cropping area goes to the edge of the image; a negative dimension brings the cropping area that many pixels back from the image edge. For example, −−crop 2,2+-2x-2 will shave 2 pixels off each side of the input image. Cropping takes place before any rotation, flipping, resizing, or positioning.【🏹:将输入帧剪为较小的矩形区域.参数(x1,y1)为矩形区域的左上角,(x2,y2)为矩形的右下角;(widthxheight)表示矩形的宽和高,宽和高可以是0和负数; 裁剪在任何旋转,翻转,调整大小或定位之前进行.】

    示例:gifsicle --crop 10,10-50,50 -i 2.gif "#0" -o test.gif
    示例:gifsicle --crop 200,200+100x100 -i 2.gif "#0" -o test.gif

    −−crop−transparency

    Crop any transparent borders off the following input frames. This happens after any cropping due to the −−crop option. It works on the raw input images; for example, any transparency options have not yet been applied.【🏹:(暂时未发现其实用之处)】

    示例:gifsicle --crop 200,200+-100x100 --crop-transparency -i 1.gif "#0" -o test.gif

    −−flip−horizontal
    −−flip−vertical

    Flip the following frames horizontally or vertically【🏹:(水平和垂直翻转).】

    示例:gifsicle --crop 200,200+-100x100 --flip-horizontal -i 1.gif "#0" -o test.gif

    −i
    −−interlace

    Turn interlacing on.

    −S widthxheight
    −−logical−screen widthxheight

    Set the output logical screen to widthxheight. −−no−logical−screen sets the output logical screen to the size of the largest output frame, while −−same−logical−screen sets the output logical screen to the largest input logical screen. −−screen is a synonym for −−logical−screen.【🏹:widthxheight设置输出文件的逻辑屏幕的宽高.−−no−logical−screen 设置输出文件的逻辑屏幕宽高为最大, −−same−logical−screen设置输出文件的逻辑屏幕宽高为输入文件的宽高. −−screen−−logical−screen有相同的语义.】

    示例:gifsicle --crop 200,200+-100x100 --flip-horizontal -i 1.gif "#0" -o test.gif

    −p x,y
    −−position x,y

    Set the following frames’ positions to (x,y). −−no−position means −−position 0,0. Normally, −−position x,y places every succeeding frame exactly at x,y. However, if an entire animation is input, x,y is treated as the position for the animation.

    示例:gifsicle -p 100,100 -i 1.gif -o test.gif
    示例:gifsicle -p 100,100 -i 1.gif "#0" -i 2.gif -o test.gif

    −−rotate−90
    −−rotate−180
    −−rotate−270

    Rotate the following frames by 90, 180, or 270 degrees. −−no−rotate turns off any rotation【🏹:(逆时针旋转).】

    示例:gifsicle --rotate-90 -i 2.gif -o test.gif

    −t color
    −−transparent color

    Make color transparent in the following frames. Color can be a colormap index (0−255), a hexadecimal color specification (like "#FF00FF" for magenta), or slash- or comma-separated red, green and blue values (each between 0 and 255).【🏹:使GIF动画的 color 透明. Color 的值可以是(0−255), 也可以是一个指定的16进制 (像 "#FF00FF"), 或者使用'/' 或者','隔开RGB对应的数值(RGB的值分别可以从0到255之间).】

    示例:gifsicle --transparent 120 -i < 1.gif > test.gif

    Extension Options(这项实用性不是很大)

    Extension options add non-visual information to the output GIF. This includes names, comments, and generic extensions.【🏹:扩展选项将非可视信息添加到输出GIF。 这包括名称,注释和通用扩展.】

    −−app−extension app−name extension

    Add an application extension named app−name and with the value extension to the output GIF.−−no−app−extensions removes application extensions from the input images.

    −c text
    −−comment text

    Add a comment, text, to the output GIF. The comment will be placed before the next frame in the stream. −−no−comments removes comments from the input images.

    −−extension number extension

    Add an extension numbered number and with the value extension to the output GIF. Number can be in decimal, octal, hex, or it can be a single character like ‘n’, whose ASCII value is used. −−no−extensions (or +x) removes extensions from the input images.

    −n text
    −−name text

    Set the next frame’s name to text. This name is stored as an extension in the output GIF (extension number 0xCE, followed by the characters of the frame name). −−no−names removes name extensions from the input images.

    【】Animation Options

    Animation options apply to GIF animations, or to individual frames in GIF animations. As with image options, most animation options have three forms,‘−−X’, ‘−−no−X’, and ‘−−same−X’, and you can give animation options multiple times; for example,【🏹:Animation options作用于GIF动画或者GIF动画的帧。和image options一样,大部分的Animation options命令也有这三种形式:‘−−X’,‘−−no−X’, and ‘−−same−X’ 你也可以多次使用这些命令,例如,】

    gifsicle −b a.gif −d50 "#0" "#1" −d100 "#2" "#3"

    sets the delays of frames 0 and 1 to 50, and frames 2 and 3 to 100【🏹:(设置第一帧延迟为50,第二、三帧延迟为100).】

    −d time
    −−delay time

    Set the delay between frames to time in hundredths of a second.【🏹:以百分之一秒为单位设置帧之间的延迟.】

    −D method
    −−disposal method (这个命令对于压缩GIF帮助不大)

    Set the disposal method for the following frames to method. A frame’s disposal method determines how a viewer should remove the frame when it’s time to display the next. Method can be a number between 0 and 7 (although only 0 through 3 are generally meaningful), or one of these names: none (leave the frame visible for future frames to build upon), asis (same as "none"), background (or bg) (replace the frame with the background), or previous (replace the frame with the area from the previous displayed frame). −−no−disposal means −−disposal=none.【🏹:参数method是对于帧的处理方法(disposal method), 一个帧的处理方法决定了观看者在显示下一帧时应如何移除帧.method可以是0到7之间的数字(尽管通常只有0到3有意义)或者其中一个名称:none(让帧可见为了将来帧的构建),asis (和"none"一样),background(or bg) (用背景替换帧),或者 previous (用先前显示的帧中的区域替换帧)−−no−disposal 意思是 −−disposal=none. 】

    −l [count]
    −−loopcount [=count]

    Set the Netscape loop extension to count. Count is an integer, or forever to loop endlessly. If you supply a −−loopcount option without specifying count, Gifsicle will use forever. −−no−loopcount (the default) turns off looping.

    Set the loop count to one less than the number of times you want the animation to run. An animation with −−no−loopcount will show every frame once; −−loopcount=1 will loop once, thus showing every frame twice; and so forth. Note that −−loopcount=0 is equivalent to −−loopcount=forever, not −−no−loopcount.【🏹:循环GIF动画的次数,0forever是一直循环下去;−−no−loopcount表示关闭循环特性.】

    示例:gifsicle -i 2.gif --loopcount=1 -o test.gif

    −O [level]
    −−optimize [=level]

    Optimize output GIF animations for space. Level determines how much optimization is done; higher levels take longer, but may have better results. There are currently three levels:【🏹:优化输出GIF动画。级别确定完成了多少优化; 更高的等级需要更长时间,但可能会有更好的结果, 目前有三个级别:】

    参数 含义
    −O1 Stores only the changed portion of each image. This is the default(仅存储每个图像(帧)的更改部分,这是默认值).
    −O2 Also uses transparency to shrink the file further(还使用透明度进一步缩小文件).
    −O3 Try several optimization methods (usually slower, sometimes better results)(尝试多种优化方法(通常较慢,有时更好的结果)).

    Other optimization flags provide finer-grained control【🏹:(其他优化标志提供更精细的控制).】
    −Okeep-empty
    Preserve empty transparent frames (they are dropped by default)【🏹:(保留空透明帧(默认情况下会丢弃)).】

    You may also be interested in other options for shrinking GIFs, such as −k and −−no−extensions.【🏹:您可能还对缩小GIF的其他选项感兴趣,例如−k−−no−extensions.】

    示例:gifsicle -O2 -i 2.gif -o test.gif

    −U
    −−unoptimize
    Unoptimize GIF animations into an easy-to-edit form【🏹:(将GIF动画优化为易于编辑的形式).】

    GIF animations are often optimized (see −−optimize) to make them smaller and faster to load, which unfortunately makes them difficult to edit. −−unoptimize changes optimized input GIFs into unoptimized GIFs, where each frame is a faithful representation of what a user would see at that point in the animation.【🏹:GIF动画经常被优化(参见−−optimize)以使它们更小且加载更快,遗憾的是它们很难编辑。−−unoptimize将优化的输入GIF更改为未优化的GIF,其中每个帧都忠实地表示用户在动画中的该点所看到的内容.】

    Image Transformation Options(图像转换命令可选项)

    Image transformation options apply to entire GIFs as they are read or written. They can be turned off with ‘−−no−option’.【🏹:图像转换命令可选项适用于读取或写入的整个GIF. 这些命令可以通过这个命令来关闭命令可选项 ‘−−no−option’. 】

    −−resize widthxheight

    Resize the output GIF to the given width and height. If width or height is an underscore ‘_’, that dimension is chosen so that the aspect ratio remains unchanged. Resizing happens after all input frames have been combined and before optimization. Resizing uses logical screen dimensions; if the input stream has an unusual logical screen (many GIF displayers ignore logical screens), you may want to provide −−no−logical−screen (or +S) to reset it so gifsicle uses image dimensions instead. See also −−resize−method.

    【🏹:将输出GIF的大小调整为给定的宽度和高度。如果宽度或高度是下划线'_',则选择该尺寸以使宽高比保持不变. 在所有输入帧组合之后和优化之前调整大小。 调整大小使用逻辑屏幕尺寸;如果输入流有一个不寻常的逻辑屏幕(许多GIF显示器忽略逻辑屏幕),你可能想通过这个命令来重置逻辑屏幕的尺寸 −−no−logical−screen (or +S),因此 gifsicle 会使用图片维度代替它. See also −−resize−method.】

    −−resize−width width
    −−resize−height height

    Resize to a given width or height, preserving aspect ratio. Equivalent to −−resize widthx_ or −−resize xheight.【🏹:使用给定的宽度或高度来调整GIF文件, 保持宽高比不变. 相当于−−resize widthx 或者−−resize _xheight.】

    −−resize−fit widthxheight
    −−resize−touch widthxheight

    Resize the output GIF to fit within a rectangle with dimensions width x height. The aspect ratio remains unchanged. The −−resize−fit option only shrinks the image—no resize is performed if the GIF already fits within the rectangle. Either width or height may be an underscore ‘_’, which leaves that dimension unconstrained.

    【🏹:调整输出GIF的大小以适合尺寸为width x height的矩形. 宽高比保持不变. 命令−−resize−fit 只仅仅缩小图像—如果GIF已经适合矩形,则不执行调整大小. 宽度或高度可以是下划线'_',这使得该维度不受约束.】

    −−resize−fit−width width
    −−resize−fit−height height
    −−resize−touch−width width
    −−resize−touch−height height

    Like −−resize−fit and −−resize−touch, but constrains only one dimension.【🏹:像 −−resize−fit−−resize−touch, 只仅仅约束一个维度.】

    −−scale Xfactor[xYfactor]

    Scale the output GIF’s width and height by Xfactor and Yfactor. If Yfactor is not given, it defaults to Xfactor. Scaling happens after all input frames have been combined and before optimization.【🏹:通过XfactorYfactor来缩放GIF的宽和高(Xfactor和Yfactor以倍数的形式来缩放的). 如果没有给定 Yfactor, 它默认为Xfactor. 缩放操作一定要发生在所有帧数合并之后和优化之前.】

    −−resize−method method

    Set the method used to resize images. The ‘sample’ method runs very quickly, but when shrinking images, it produces noisy results. The ‘mix’ method is somewhat slower, but produces better-looking results. The default method is currently ‘mix’.【🏹:设置用于调整图像大小的方法。“样本”方法运行得非常快,但是当缩小图像时,会产生嘈杂的结果。 'mix'方法有点慢,但产生更好看的结果。默认方法目前是“混合”.】

    Details: The resize methods differ most when shrinking images. The ‘sample’ method is a point sampler: each pixel position in the output image maps to exactly one pixel position in the input. When shrinking, full rows and columns from the input are dropped. The other methods use all input pixels, which generally produces better-looking images. The ‘box’ method, a box sampler, is faster than the more complex filters and produces somewhat sharper results, but there will be anomalies when shrinking images by a small amount in one dimension. (Some output pixels will correspond to exactly 1 input row or column, while others will correspond to exactly 2 input rows or columns.) The ‘mix’ method is a full bilinear interpolator. This is slower and produces somewhat blurrier results, but avoids anomalies.【🏹:详细信息:缩小图像时,调整大小方法的差异最大。 “sample”方法是一个点采样器:输出图像中的每个像素位置都映射到输入中的一个像素位置。缩小时,输入中的完整行和列将被删除。其他方法使用所有输入像素,这通常会产生更好看的图像。盒子采样器的“盒子”方法比更复杂的滤波器更快,并且产生更清晰的结果,但是当在一个维度上缩小图像少量时会出现异常。(某些输出像素将精确对应于1个输入行或列,而其他输出像素将恰好对应于2个输入行或列。)“混合”方法是完整的双线性插值器。这样较慢并且产生一些模糊的结果,但避免了异常.】

    Gifsicle also supports more complex resamplers, including Catmull-Rom cubic resampling (‘catrom’), the Mitchell-Netravali filter (‘mitchell’), a 2-lobed Lanczos filter (‘lanczos2’), and a 3-lobed Lanczos filter (‘lanczos3’). These filters are slower still, but can give sharper, better results.【🏹:Gifsicle还支持更复杂的重采样器,包括Catmull-Rom立方重采样('catrom'),Mitchell-Netravali滤波器('mitchell'),2瓣Lanczos滤波器('lanczos2')和3瓣Lanczos滤波器( 'lanczos3')。这些滤镜仍然较慢,但可以提供更清晰,更好的效果.】

    −−resize−colors n

    Allow Gifsicle to add intermediate colors when resizing images. Normally, Gifsicle’s resize algorithms use input images’ color palettes without changes. When shrinking images with very few colors (e.g., pure black-and-white images), adding intermediate colors can improve the results. Example: −−resize−colors 64 allows Gifsicle to add intermediate colors for images that have fewer than 64 input colors.【🏹:允许Gifsicle在调整图像大小时添加中间色。 通常,Gifsicle的调整大小算法使用输入图像的调色板而不做任何更改。 当用非常少的颜色缩小图像(例如,纯黑白图像)时,添加中间色可以改善结果。示例:−−resize−colors允许Gifsicle为少于64种输入颜色的图像添加中间色.】

    【】Color Options(颜色命令可选项)

    Color options apply to entire GIFs as they are read or written. They can be turned off with ‘−−no−option’.【🏹:(Color options适用于读取或写入的整个GIF。 可以使用‘−−no−option’关闭它们)】

    −k num −−colors num

    Reduce the number of distinct colors in each output GIF to num or less. Num must be between 2 and 256. This can be used to shrink output GIFs or eliminate any local color tables.【🏹:将每个输出GIF中不同颜色的数量减少到num或更少.Num必须介于2到256之间.这可用于缩小输出GIF或消除任何本地颜色表.

    Normally, an adaptive group of colors is chosen from the existing color table. You can affect this process with the −−color−method option or by giving your own colormap with −−use−colormap. Gifsicle may need to add an additional color (making num+1 in all) if there is transparency in the image.【🏹:通常,从现有颜色表中选择自适应颜色组。 您可以使用−−color−method选项或使用−−use−colormap提供自己的色彩映射来影响此过程。 如果图像中有透明度,Gifsicle可能需要添加其他颜色(让参数num + 1).】

    示例:gifsicle -k 60 -i 2.gif -o test.gif

    −−color−method method

    Determine how a smaller colormap is chosen. ‘diversity’, the default, is xv(1)’s diversity algorithm, which uses a strict subset of the existing colors and generally produces good results. ‘blend−diversity’ is a modification of this: some color values are blended from groups of existing colors. ‘median−cut’ is the median cut algorithm described by Heckbert. −−method is a synonym for −−color−method.【🏹:确定如何选择较小的色彩映射表.‘diversity’,默认是xv(1)的多样性算法,它使用现有颜色的严格子集,通常会产生良好的结果. ‘blend−diversity’是对此的修改:某些颜色值是从现有颜色组中混合而成.&lsquo median−cut’ 是Heckbert描述的中值切割算法. −−method−−color−method具有相同语义】

    示例:gifsicle --color-method blend-diversity -k 60 -i 2.gif -o test.gif
    示例:gifsicle --color-method median-cut -k 60 -i 2.gif -o test1.gif
    示例:gifsicle --color-method diversity -k 60 -i 2.gif -o test2.gif

    −f
    −−dither [=method]

    When −−dither is on and the colormap is changed, combinations of colors are used to approximate missing colors. This looks better, but makes bigger files and can cause animation artifacts, so it is off by default.【🏹:当−−dither打开并且颜色图更改时,颜色组合用于近似缺失颜色。 这样看起来更好,但是会生成更大的文件并导致动画瑕疵,因此默认情况下它是关闭的.】

    Specify a dithering algorithm with the optional method argument. The default, ‘floyd-steinberg’, uses Floyd-Steinberg error diffusion. This usually looks best, but can cause animation artifacts, because dithering choices will vary from frame to frame. Gifsicle also supports ordered dithering algorithms that avoid animation artifacts. The ‘ro64’ mode uses a large,random-looking pattern and generally produces good results. The ‘o3’, ‘o4’, and ‘o8’ modes use smaller, more regular patterns. The ‘ordered’ mode chooses a good ordered dithering algorithm. For special effects, try the halftone modes ‘halftone’, ‘squarehalftone’, and ‘diagonal’. Some modes take optional parameters using commas. The halftone modes take a cell size and a color limit: ‘halftone,10,3’ creates 10-pixel wide halftone cells where each cell uses up to 3 colors.【🏹:使用可选的参数method指定抖动算法. 默认的‘floyd-steinberg’,使用Floyd-Steinberg误差扩散。 这通常看起来最好,但可能会导致动画瑕疵,因为抖动选择会因帧而异。 Gifsicle还支持有序的抖动算法,可避免动画伪影。 ‘ro64’ 模式使用大型随机图案,通常会产生良好的效果. ‘o3’, ‘o4’, 和 ‘o8’模式使用更小,更规则的模式. ‘ordered’模式选择了良好的有序抖动算法. 对于特殊效果,尝试半色调模式&lsquo halftone’,‘squarehalftone’, and‘diagonal’.某些模式使用逗号选择可选参数. 半色调模式采用单元格大小和颜色限制:‘halftone,10,3’创建10像素宽的半色调单元格,每个单元格最多使用3种颜色.】

    示例:gifsicle --dither=halftone,10,3 -k 60 -i 2.gif -o test.gif
    示例:gifsicle --dither=o3 -k 60 -i 2.gif -o test2.gif
    示例:gifsicle --dither=squarehalftone -k 60 -i 2.gif -o test3.gif

    −−gamma gamma

    Set the gamma correction to gamma, which can be a real number or ‘srgb’. Roughly speaking, higher numbers exaggerate shadows and lower numbers exaggerate highlights. The default is the function defined by the standard sRGB color space, which usually works well. (Its effects are similar to −−gamma=2.2.) Gifsicle uses gamma correction when choosing a color palette (−−colors) and when dithering (−−dither).【🏹:参数gamma将被设置为伽玛校正,可以是实数或‘srgb’. 粗略地说,较高的数字扩大阴影,较低的数字扩大了亮点.默认值是标准sRGB颜色空间定义的函数,通常效果很好. (它的效果类似于 −−gamma=2.2) Gifsicle在选择调色板(−−colors)和抖动(−−dither)时使用伽马校正。】

    示例:gifsicle --gamma=200 -k 60 -i 2.gif -o test.gif

    −−change−color color1 color2

    Change color1 to color2 in the following input GIFs. (The color arguments have the same forms as in the −t option.) Change multiple colors by giving the option multiple times. Color changes don’t interfere with one another, so you can safely swap two colors with ‘−−change−color color1 color2 −−change−color color2 color1’. They all take effect as an input GIF is read. −−no−change−color cancels all color changes.【🏹:在输入GIF的中将参数color1更改为参数color2.(颜色数值与−t选项中的颜色数值相同). 通过多次提供选项来更改多种颜色.颜色变化不会相互干扰,因此您可以使用‘−−change−color color1 color2 −−change−color color2 color1’安全地交换两种颜色 −−no−change−color取消所有颜色变化】

    示例:gifsicle --change-color #7ec31f #000000 -i 2.gif -o test.gif

    −−transform−colormap command

    Command should be a shell command that reads from standard input and writes to standard output. Each colormap in the output GIF is translated into text colormap format (see −−use−colormap below) and piped to the command. The output that command generates (which should also be in text colormap format) will replace the input colormap. The replacement doesn’t consider color matching, so pixels that used color slot n in the input will still use color slot n in the output.【🏹:参数Command应该是一个shell命令,它从标准输入读取并写入标准输出. 输出GIF中的每个色彩映射都转换为文本色彩映射格式(请参阅下面的−−use−colormap)并通过管道传输到命令. 命令生成的输出(也应采用文本色彩映射格式)将替换输入的色彩映射.替换不考虑颜色匹配,因此在输入中使用颜色槽n的像素仍将在输出中使用颜色槽n.】

    −−use−colormap colormap

    Change the image to use colormap. Each pixel in the image is changed to the closest match in colormap (or, if −−dither is on, to a dithered combination of colors in colormap). Colormap can be web for the 216-color “Web-safe palette”; gray for grayscale; bw for black-and-white; or the name of a file. That file should either be a text file
    (the format is described below) or a GIF file, whose global colormap will be used. If −−colors=N is also given, an N−sized subset of colormap will be used.【🏹:使用参数colormap去更改图像.图像中的每个像素都会更改为色彩映射中最接近的匹配(或者,如果−−dither是打开的,则为colormap中抖动的颜色组合). Colormap可以是用于216色“Web安全调色板”的Web;gray为灰度; bw为黑白; 或文件的名称。该文件应该是文本文件(格式如下所述)或GIF文件,将使用其全局色彩映射。 如果还给出了−−colors=N,则将使用N−大小的色彩映射子集。】

    示例:gifsicle --use-colormap bw -i 2.gif -o test.gif
    示例:gifsicle --use-colormap gray -i 2.gif -o test.gif

    Text colormap files use this format【🏹:(文本色彩映射文件使用此格式):

    ; each non-comment line represents one color, "red green blue" ; each component should be between 0 and 255 0 0 0 ; like this 255 255 255 ; or use web hex notation #ffffff ; like this

    EXAMPLES(示例)[7]

    First, let’s create an animation, ‘anim.gif’:

    gifsicle a.gif b.gif c.gif d.gif > anim.gif

    This animation will move very quickly: since we didn’t specify a delay, a browser will cycle through the frames as fast as it can. Let’s slow it down and pause .5 seconds between frames, using the −−delay option.【🏹:这个动画将非常快速地移动:由于我们没有指定延迟,浏览器将尽可能快地循环遍历帧。 让我们放慢速度并在帧之间暂停.5秒,使用−−delay选项.】

    gifsicle −−delay 50 a.gif b.gif c.gif d.gif > anim.gif

    If we also want the GIF to loop three times, we can use −−loopcount:

    gifsicle −d 50 −−loop=3 a.gif b.gif c.gif d.gif > anim.gif

    (Rather than type −−delay again, we used its short form, −d. Many options have short forms; you can see them by running ‘gifsicle −−help’. We also abbreviated −−loopcount to −−loop, which is OK since no other option starts with ‘loop’.)【🏹:(而不是再次输入−−delay,我们使用它的简短形式−d。许多选项都有简短的形式;你可以通过运行‘gifsicle −−help’看到它们。我们还将−−loopcount 缩写 −−loop,这是好的,因为没有其他选项以‘loop’开头。)】

    To explode ‘anim.gif’ into its component frames【🏹:(将‘anim.gif’ 分解为其组成框架):】

    gifsicle −−explode anim.gif ls anim.gif

    anim.gif anim.gif.000 anim.gif.001 anim.gif.002 anim.gif.003

    To optimize ‘anim.gif’(优化‘anim.gif’):

    gifsicle −b −O2 anim.gif

    To change the second frame of ‘anim.gif’ to ‘x.gif’【🏹:(将'anim.gif'的第二帧更改为'x.gif'):】

    gifsicle −b −−unoptimize −O2 anim.gif −−replace "#1" x.gif

    −−unoptimize is used since ‘anim.gif’ was optimized in the last step. Editing individual frames in optimized GIFs is dangerous without −−unoptimize; frames following the changed frame could be corrupted by the change. Of course, this might be what you want.【🏹:−−unoptimize被使用,因为‘anim.gif’ 在最后一步中被优化了。 在没有使用−−unoptimize的情况下编辑优化过的GIF中的各个帧是危险的; 更改帧后面的帧可能会被更改破坏。 当然,这可能就是你想要的.】

    Note that −−unoptimize and −−optimize can be on simultaneously. −−unoptimize affects input GIF files, while −−optimize affects output GIF files.【🏹:请注意−−unoptimize−−optimize可以同时打开。−−unoptimize 影响输入GIF文件,而−−optimize影响输出GIF文件.】

    To print information about the first and fourth frames of ‘anim.gif’【🏹:(打印有关‘anim.gif’的第一帧和第四帧的信息):】

    gifsicle −I "#0" "#3" < anim.gif

    To make black the transparent color in all the GIFs in the current directory, and also print information about each:【🏹:要在当前目录中的所有GIF中使黑色成为透明色,并打印有关每个GIF的信息:】

    gifsicle −bII −−trans "#000000" *.gif

    Giving −I twice forces normal output to occur. With only one −I, the GIFs would not be modified.【🏹:这里−I两次强制正常输出。 只有一个−I,GIF不会被修改.】

    To change ‘anim.gif’ to use a 64-color subset of the Web-safe palette:【🏹:更改‘anim.gif’以使用Web安全调色板的64色子集:】

    gifsicle −b −−colors=64 −−use−col=web anim.gif

    To make a dithered black-and-white version of ‘anim.gif’【🏹:(制作一个抖动的黑白版‘anim.gif’):】

    gifsicle −−dither −−use−col=bw anim.gif > anim-bw.gif

    To overlay one GIF atop another −− producing a one-frame output GIF that looks like the superposition of the two inputs −− use gifsicle twice:【🏹:将一个GIF叠加在另一个上面−−产生一帧输出GIF,看起来像两个输入的叠加−−使用gifsicle两次:】

    gifsicle bottom.gif top.gif | gifsicle −U "#1" > result.gif


    1. NAME

    2. SYNOPSIS

    3. DESCRIPTION

    4. CONCEPT INDEX

    5. COMMAND LINE

    6. OPTIONS

    7. EXAMPLES

    相关文章

      网友评论

          本文标题:[Gifsicle],压缩、优化gif的命令行工具 —— 中英文

          本文链接:https://www.haomeiwen.com/subject/vzhycqtx.html