| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.3//EN"> |
| 2 |
<html><head><title>Pamtogif User Manual</title></head> |
| 3 |
<body> |
| 4 |
<h1>pamtogif</h1> |
| 5 |
Updated: 09 June 2021 |
| 6 |
<br> |
| 7 |
<a href="#index">Table Of Contents</a> |
| 8 |
|
| 9 |
<h2>NAME</h2> |
| 10 |
pamtogif - convert a Netpbm image to a GIF image |
| 11 |
|
| 12 |
<h2 id="synopsis">SYNOPSIS</h2> |
| 13 |
|
| 14 |
<b>pamtogif</b> |
| 15 |
|
| 16 |
[<b>-interlace</b>] |
| 17 |
|
| 18 |
[<b>-sort</b>] |
| 19 |
|
| 20 |
[<b>-mapfile=</b><i>mapfile</i>] |
| 21 |
|
| 22 |
<br> |
| 23 |
|
| 24 |
[<b>-transparent=</b>[<b>=</b>]<i>color</i>] |
| 25 |
|
| 26 |
[<b>-alphacolor=</b><i>color</i>] |
| 27 |
|
| 28 |
[<b>-comment=</b><i>text</i>] |
| 29 |
|
| 30 |
[<b>-noclear</b>] |
| 31 |
|
| 32 |
[<b>-nolzw</b>] |
| 33 |
|
| 34 |
[<b>-aspect=</b><i>fraction</i>] |
| 35 |
|
| 36 |
[<b>-verbose</b>] |
| 37 |
|
| 38 |
<br> |
| 39 |
|
| 40 |
[<i>netpbmfile</i>] |
| 41 |
|
| 42 |
<p>All options can be abbreviated to their shortest unique prefix. You |
| 43 |
may use two hyphens instead of one to designate an option. You may |
| 44 |
use either white space or an equals sign between an option name and its |
| 45 |
value. |
| 46 |
|
| 47 |
<h2 id="description">DESCRIPTION</h2> |
| 48 |
|
| 49 |
<p>This program is part of <a href="index.html">Netpbm</a>. |
| 50 |
|
| 51 |
<p><b>pamtogif</b> reads a Netpbm image as input and produces a GIF file |
| 52 |
as output. |
| 53 |
|
| 54 |
<p>This program creates only individual GIF images. To combine |
| 55 |
multiple GIF images into an animated GIF, use <a |
| 56 |
href="http://www.lcdf.org/gifsicle/"><b>gifsicle</b></a> (not part of |
| 57 |
the Netpbm package). |
| 58 |
|
| 59 |
<p><b>pamtogif</b> creates either an original GIF87 format GIF file or the |
| 60 |
newer GIF89 format. It creates GIF89 when the output needs to have features |
| 61 |
that were new with GIF89, to wit transparency or comments. Otherwise, it |
| 62 |
creates GIF87. Really old GIF readers conceivably could not recognize |
| 63 |
GIF89. The output needs to have transparency when either the input has a |
| 64 |
transparency information or you specify the <b>-transparent</b> option. It |
| 65 |
needs to have comments when you specify the |
| 66 |
<b>-comment</b> option. |
| 67 |
|
| 68 |
<p><b>pamtogif</b> generates a GIF image with a single image block, which |
| 69 |
means the image cannot have more than 256 colors in it (it contains a single |
| 70 |
color map with a maximum size of 256). If the image you want to convert has |
| 71 |
more colors than that (<b>ppmhist</b> can tell you), you can |
| 72 |
use <b>pnmquant</b> to reduce it to 256. Or use the more complex but faster |
| 73 |
method described under the <b>-mapfile</b> option. |
| 74 |
|
| 75 |
<p>If your input image is a PAM with transparency information, <b>pamtogif</b> |
| 76 |
uses one entry in the GIF colormap specifically for the transparent pixels, |
| 77 |
so you can have at most 255 opaque colors. In contrast, if you use the |
| 78 |
<b>-transparent</b> option, one of the colors from the input becomes |
| 79 |
transparent, so the limit is still 256. |
| 80 |
|
| 81 |
<p><b>pamtogif</b> recognizes transparency information in the input by the |
| 82 |
tuple type being <b>RGB_ALPHA</b>, <B>GRAYSCALE_ALPHA</B>, or |
| 83 |
<b>BLACKANDWHITE_ALPHA</b>. This is the case for any image that has |
| 84 |
transparency information and was created by a Netpbm program that |
| 85 |
manipulates visual images. If, on the other hand, you have a PAM generated |
| 86 |
some other way, but you know the planes have the same meaning as implied by |
| 87 |
these tuple types, you can make <b>pamtogif</b> process the transparency |
| 88 |
information by changing the tuple type accordingly before you pass it |
| 89 |
to <b>pamtogif</b>. You can use <b>pamstack</b> to change the tuple type. |
| 90 |
|
| 91 |
<p><b>pamtogif</b> was new in Netpbm 10.37 (December 2006). In older Netpbm, |
| 92 |
use <b>ppmtogif</b>. |
| 93 |
|
| 94 |
<h2 id="options">OPTIONS</h2> |
| 95 |
|
| 96 |
<p>In addition to the options common to all programs based on libnetpbm |
| 97 |
(most notably <b>-quiet</b>, see <a href="index.html#commonoptions"> |
| 98 |
Common Options</a>), <b>pamtogif</b> recognizes the following |
| 99 |
command line options: |
| 100 |
|
| 101 |
<dl compact> |
| 102 |
|
| 103 |
<dt><b>-interlace</b> |
| 104 |
|
| 105 |
<dd> |
| 106 |
Produce an interlaced GIF file. |
| 107 |
|
| 108 |
<dt><b>-sort</b> |
| 109 |
|
| 110 |
<dd> |
| 111 |
Produce a GIF file with a color map sorted in a predictable order. |
| 112 |
|
| 113 |
<p>This does <em>not</em> produce the sorted color map which is part |
| 114 |
of the GIF format. That kind of sorted color map is one where the |
| 115 |
colors are sorted according to how important they are, and the GIF |
| 116 |
header tells the viewer that it is sorted that way. Its purpose is to |
| 117 |
allow the viewer to use fewer colors than are in the color map if it |
| 118 |
is not capable of displaying all the colors. |
| 119 |
|
| 120 |
<p>What this option produces is a color map sorted by red value, then |
| 121 |
green, then blue. That can be useful in analyzing GIF images, particularly |
| 122 |
those made with two versions of the program, because it removes some of |
| 123 |
the variability. |
| 124 |
|
| 125 |
|
| 126 |
<dt><b>-mapfile=</b><i>mapfile</i> |
| 127 |
|
| 128 |
<dd> |
| 129 |
|
| 130 |
<p>Use the colors found in the file <i>mapfile</i> to create the |
| 131 |
colormap in the GIF file, instead of the colors from <i>netpbmfile</i>. |
| 132 |
<i>mapfile</i> can be any PPM file; all that matters is the colors in |
| 133 |
it. If the colors in <i>netpbmfile</i> do not match those in |
| 134 |
<i>mapfile</i>, <b>pamtogif</b> matches them to a "best |
| 135 |
match." You can obtain a much better result by using <b>pnmremap</b> |
| 136 |
to change the colors in the input to those in the map file. |
| 137 |
|
| 138 |
<p>The <i>mapfile</i> file is not a palette file, just an image whose |
| 139 |
colors you want to use. The order of colors in the GIF palette have |
| 140 |
nothing to do with where they appear in the <i>mapfile</i> image, and |
| 141 |
duplication of colors in the image is irrelevant. |
| 142 |
|
| 143 |
<p>The map file's depth must match the number of color components in |
| 144 |
the input (which is not necessarily the same as the input's depth -- |
| 145 |
the input might have a transparency plane in addition). If your map file |
| 146 |
does not, or it <em>might</em> not, run your input through |
| 147 |
<b>pnmremap</b> using the same map file so that it does. |
| 148 |
|
| 149 |
<p>You can use <b>-mapfile</b> to speed up conversion of an image where you |
| 150 |
already have a map file because of earlier processing of your image. For |
| 151 |
example, it is common to start with an image that has more than 256 colors |
| 152 |
and remap its colors to a set of 256 colors so that <b>pamgtogif</b> can |
| 153 |
convert it (a GIF can have only 256 colors; <b>pamtogif</b> without |
| 154 |
<b>-mapfile</b> fails on any image that has more than that) with |
| 155 |
<b>pnmquant</b>. When you do this, <b>pnmquant</b> generates a palette to do |
| 156 |
the color quantization, then <b>pamtogif</b> generates an identical palette |
| 157 |
from the quantized image. You can save computation by generating the palette |
| 158 |
once: |
| 159 |
|
| 160 |
<pre> |
| 161 |
<kbd> |
| 162 |
$ pnmcolormap 256 myimage.ppm >/tmp/colormap.ppm |
| 163 |
$ pamtogif myimage.ppm -mapfile=/tmp/colormap.ppm >output.gif |
| 164 |
</kbd> |
| 165 |
</pre> |
| 166 |
|
| 167 |
|
| 168 |
<dt><b>-transparent=</b><i>color</i> |
| 169 |
|
| 170 |
<dd> |
| 171 |
<b>pamtogif</b> marks the specified color as transparent in the GIF image. |
| 172 |
|
| 173 |
<p>If you don't specify <b>-transparent</b>, <b>pamtogif</b> does not |
| 174 |
mark any color transparent (except as indicated by the transparency |
| 175 |
information in the input file). |
| 176 |
|
| 177 |
<p>Specify the color (<i>color</i>) as described for the <a |
| 178 |
href="libnetpbm_image.html#colorname">argument of the <b>pnm_parsecolor()</b> |
| 179 |
library routine</a>. |
| 180 |
|
| 181 |
<p>If the color you specify is not present in the image, <b>pamtogif</b> |
| 182 |
selects instead the color in the image that is closest to the one you |
| 183 |
specify. Closeness is measured as a Cartesian distance between colors |
| 184 |
in RGB space. If multiple colors are equidistant, <b>pamtogif</b> |
| 185 |
chooses one of them arbitrarily. |
| 186 |
|
| 187 |
<p>However, if you prefix your color specification with "=", |
| 188 |
e.g. <b>-transparent==red</b>, only the exact color you specify will |
| 189 |
be transparent. If that color does not appear in the image, there |
| 190 |
will be no transparency. <b>pamtogif</b> issues an information |
| 191 |
message when this is the case. |
| 192 |
|
| 193 |
<p>When you specify <b>-transparent</b>, <b>pamtogif</b> ignores |
| 194 |
explicit transparency information (the "alpha channel") in |
| 195 |
the input image. |
| 196 |
|
| 197 |
<dt><b>-alphacolor=</b><i>color</i> |
| 198 |
|
| 199 |
<dd>This specifies the foreground color for transparent pixels. A |
| 200 |
viewer may use the foreground color for a transparent pixel if it |
| 201 |
chooses not to have another color "show through.". The |
| 202 |
default is black. |
| 203 |
|
| 204 |
<p>This applies only to pixels that are transparent in the GIF because |
| 205 |
they are transparent in the Netpbm input. If a GIF pixel is |
| 206 |
transparent because of the <b>-transparent</b> option, the foreground |
| 207 |
color is the color indicated by that option. |
| 208 |
|
| 209 |
<p>Note that in GIF, all transparent pixels have the same foreground |
| 210 |
color. (There is only one entry in the GIF colormap for transparent |
| 211 |
pixels). |
| 212 |
|
| 213 |
<p>Specify the color (<i>color</i>) as described for the <a |
| 214 |
href="libnetpbm_image.html#colorname">argument of the <b>pnm_parsecolor()</b> |
| 215 |
library routine</a>. |
| 216 |
|
| 217 |
<dt><b>-comment=</b><i>text</i> |
| 218 |
|
| 219 |
<dd> |
| 220 |
Include a comment in the GIF output with comment text <i>text</i>. |
| 221 |
|
| 222 |
<p>Without this option, there are no comments in the output. |
| 223 |
|
| 224 |
<p>Note that in a command shell, you'll have to use quotation marks around |
| 225 |
<i>text</i> if it contains characters (e.g. space) that would make the shell |
| 226 |
think it is multiple arguments: |
| 227 |
<pre> |
| 228 |
$ pamtogif -comment "this is a comment" <xxx.ppm >xxx.gif |
| 229 |
</pre> |
| 230 |
|
| 231 |
<dt><b>-noclear</b> |
| 232 |
|
| 233 |
<dd> |
| 234 |
<p>This option causes the output not to contain any GIF clear codes. |
| 235 |
|
| 236 |
<p>In GIF, the stream defines codes that represent strings of pixels as it |
| 237 |
goes. The stream contains definitions of codes mixed in with the references |
| 238 |
to those codes that describe the pixels of the image. GIF specifies a maximum |
| 239 |
number of codes that can be defined; when the stream has defined that many, |
| 240 |
the stream can either just use those for the rest of the image or include a |
| 241 |
clear code, deleting all the string codes so that the stream can start over |
| 242 |
defining new ones. |
| 243 |
|
| 244 |
<p>By far the most common choice is the clear code. This usually results in a |
| 245 |
smaller stream because the set of strings of pixels that occur in an image |
| 246 |
vary over the parts of the image. Hardly any GIF encoders produce streams |
| 247 |
that don't use the clear code. |
| 248 |
|
| 249 |
<p>But it is conceivable that a stream could be smaller without the use of the |
| 250 |
clear code because it saves the stream having to redefine the same string |
| 251 |
codes over and over. It could even avoid a thrashing situation where the |
| 252 |
stream continually defines a set of strings that never get used again before |
| 253 |
the maximum is reached. |
| 254 |
|
| 255 |
<p>The default is to use the clear codes. |
| 256 |
|
| 257 |
<p>This option was new in Netpbm 10.82 (March 2018). Before that, the program |
| 258 |
aways uses the clear codes. |
| 259 |
|
| 260 |
<dt><b>-nolzw</b> |
| 261 |
|
| 262 |
<dd> |
| 263 |
<p>This option is mainly of historical interest -- it involves use of |
| 264 |
a patent that is now expired. |
| 265 |
|
| 266 |
<p>This option causes the GIF output, and thus <b>pamtogif</b>, not to |
| 267 |
use LZW (Lempel-Ziv) compression. As a result, the image file is |
| 268 |
larger and, before the patent expired, no royalties would be owed to |
| 269 |
the holder of the patent on LZW. See the section LICENSE below. |
| 270 |
|
| 271 |
<p>LZW is a method for combining the information from multiple pixels into a |
| 272 |
single GIF code. With the <b>-nolzw</b> option, <b>pamtogif</b> |
| 273 |
creates one GIF code per pixel, so it is not doing any compression and not |
| 274 |
using LZW. However, any GIF decoder, whether it uses an LZW decompressor |
| 275 |
or not, will correctly decode this uncompressed format. An LZW decompressor |
| 276 |
would see this as a particular case of LZW compression. |
| 277 |
|
| 278 |
<p>Note that if someone uses an LZW decompressor such as the one in |
| 279 |
<b>giftopnm</b> or pretty much any graphics display program to process |
| 280 |
the output of <b>pamtogif -nolzw </b>, he is then using the LZW |
| 281 |
patent. But the patent holder expressed far less interest in |
| 282 |
enforcing the patent on decoding than on encoding. |
| 283 |
|
| 284 |
<dt><b>-aspect=</b><i>fraction</i> |
| 285 |
|
| 286 |
<dd>This is the aspect ratio of the pixels of the image. Its only |
| 287 |
effect is to record that information in the GIF for use by whatever |
| 288 |
interprets the GIF. Note that this feature of GIF is hardly ever used |
| 289 |
and most GIF decoders ignore this information and assume pixels are |
| 290 |
square. |
| 291 |
|
| 292 |
<p>Pixels in a Netpbm image do not have aspect ratios; there is always |
| 293 |
a one-one correspondence between GIF pixels and Netpbm pixels. |
| 294 |
|
| 295 |
<p>The aspect ratio is the quotient of width divided by height. GIF |
| 296 |
allows aspect ratios from 0.25 (1:4) to 4 (4:1) in increments of 1/64. |
| 297 |
<b>pamtogif</b> implements a natural extension of GIF that allows an |
| 298 |
aspect ratio up to 4 14/64. If you specify anything outside this range, |
| 299 |
<b>pamtogif</b> fails. <b>pamtogif</b> rounds <i>fraction</i> to |
| 300 |
the nearest 1/64. |
| 301 |
|
| 302 |
<p>The default is square (1.0). |
| 303 |
|
| 304 |
<p>This option was new in Netpbm 10.38 (March 2007). Before that, the |
| 305 |
pixels are always square. |
| 306 |
|
| 307 |
|
| 308 |
<dt><b>-verbose</b> |
| 309 |
|
| 310 |
<dd>This option causes <b>pamtogif</b> to display information about the |
| 311 |
conversion process and the image it produces. |
| 312 |
|
| 313 |
</dl> |
| 314 |
|
| 315 |
<h2 id="seealso">SEE ALSO</h2> |
| 316 |
|
| 317 |
<b><a href="giftopnm.html">giftopnm</a></b>, |
| 318 |
|
| 319 |
<b><a href="pnmremap.html">pnmremap</a></b>, |
| 320 |
|
| 321 |
<b><a href="ppmtogif.html">ppmtogif</a></b>, |
| 322 |
|
| 323 |
<b>gifsicle</b> <<a |
| 324 |
href="http://www.lcdf.org/gifsicle">http://www.lcdf.org/gifsicle</a>>, |
| 325 |
|
| 326 |
<b><a href="pnm.html">pnm</a></b>, |
| 327 |
|
| 328 |
<b><a href="pam.html">pam</a></b>. |
| 329 |
|
| 330 |
<h2 id="history">HISTORY</h2> |
| 331 |
|
| 332 |
<p><b>pamtogif</b> was new in Netpbm 10.37 (December 2006). It |
| 333 |
replaced <b>ppmtogif</b>, which created GIF images for Pbmplus/Netpbm |
| 334 |
users since 1989. |
| 335 |
|
| 336 |
<p>The main outward change in the conversion from <b>ppmtogif</b> to |
| 337 |
<b>pamtogif</b> was that <b>pamtogif</b> was able to use transparency |
| 338 |
information ("alpha channel") in PAM input, whereas with |
| 339 |
<b>ppmtogif</b>, one had to supply the transparency mask in a separate |
| 340 |
pseudo-PGM image (via the <b>-alpha</b> option). |
| 341 |
|
| 342 |
<p>Jef Poskanzer wrote <b>ppmtogif</b> in 1989, and it has always been |
| 343 |
a cornerstone of Pbmplus/Netpbm because GIF is such a popular image |
| 344 |
format. Jef based the LZW encoding on GIFENCOD by David Rowley <<a |
| 345 |
href="mailto:[email protected]">[email protected]</a>>. |
| 346 |
Jef included GIFENCOD's GIFCOMPR.C file pretty much whole. Rowley, in |
| 347 |
turn, adapted the LZW compression code from classic Unix |
| 348 |
<b>compress</b>, which used techniques described in IEEE Computer, |
| 349 |
June 1984. |
| 350 |
|
| 351 |
<p>Jef's <b>ppmtogif</b> notably lacked the ability to use a |
| 352 |
transparency mask with it. You could create transparent pixels in a |
| 353 |
GIF, but only with the <b>-transparent</b> option, which allowed one |
| 354 |
to specify that all pixels of a certain color in the input were to be |
| 355 |
transparent. Bryan Henderson added the <b>-alpha</b> option in July |
| 356 |
2001 so you could supply a mask image that indicates exactly which |
| 357 |
pixels are to be transparent, and those pixels could have the same |
| 358 |
color as other opaque ones. |
| 359 |
|
| 360 |
<p>Bryan Henderson added another significant piece of code and |
| 361 |
function in October 2001: the ability to generate a GIF without using |
| 362 |
the LZW patent -- an uncompressed GIF. This was very important to |
| 363 |
many people at the time because the GIF patent was still in force, and |
| 364 |
this allowed them to make an image that any GIF viewer could display, |
| 365 |
royalty-free. Bryan adapted code from the Independent JPEG Group's |
| 366 |
<b>djpeg</b> for that. |
| 367 |
|
| 368 |
<p>There is no code in <b>pamtogif</b> from Jef's original, but Jef |
| 369 |
may still hold copyright over it because of the way in which it evolved. |
| 370 |
Virtually all of the code in <b>pamtogif</b> was written by Bryan |
| 371 |
Henderson and contributed to the public domain. |
| 372 |
|
| 373 |
|
| 374 |
<h2 id="license">LICENSE</h2> |
| 375 |
|
| 376 |
<p>If you use <b>pamtogif</b> without the <b>-nolzw</b> option, you |
| 377 |
are using a patent on the LZW compression method which is owned by |
| 378 |
Unisys. The patent has expired (in 2003 in the US and in 2004 |
| 379 |
elsewhere), so it doesn't matter. While the patent was in force, most |
| 380 |
people who used <b>pamtogif</b> and similar programs did so without a |
| 381 |
license from Unisys to do so. Unisys typically asked $5000 for a |
| 382 |
license for trivial use of the patent. Unisys never enforced the |
| 383 |
patent against trivial users. |
| 384 |
|
| 385 |
<p>Rumor has it that IBM also owns or owned a patent covering |
| 386 |
<b>pamtogif</b>. |
| 387 |
|
| 388 |
<p>A replacement for the GIF format that never required any patents to |
| 389 |
use is the PNG format. |
| 390 |
|
| 391 |
<hr> |
| 392 |
<h2 id="index">Table Of Contents</h2> |
| 393 |
<ul> |
| 394 |
<li><a href="#synopsis">SYNOPSIS</a> |
| 395 |
<li><a href="#description">DESCRIPTION</a> |
| 396 |
<li><a href="#options">OPTIONS</a> |
| 397 |
<li><a href="#seealso">SEE ALSO</a> |
| 398 |
<li><a href="#history">HISTORY</a> |
| 399 |
<li><a href="#license">LICENSE</a> |
| 400 |
</ul> |
| 401 |
</body> |
| 402 |
</html> |