| 1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.3//EN"> |
| 2 |
<html><head><title>Pnmtojpeg User Manual</title></head> |
| 3 |
<body> |
| 4 |
<h1>pnmtojpeg</h1> |
| 5 |
Updated: 23 April 2007 |
| 6 |
<br> |
| 7 |
<a href="#index">Table Of Contents</a> |
| 8 |
|
| 9 |
<h2>NAME</h2> |
| 10 |
pnmtojpeg - convert PNM image to a JFIF ("JPEG") image |
| 11 |
|
| 12 |
<h2 id="synopsis">SYNOPSIS</h2> |
| 13 |
|
| 14 |
<b>pnmtojpeg</b> |
| 15 |
[<b>-exif=</b><i>filespec</i>] |
| 16 |
[<b>-quality=</b><i>n</i>] |
| 17 |
[{<b>-grayscale</b>|<b>-greyscale</b>}] |
| 18 |
[<b>-density=</b><i>n</i><b>x</b><i>n</i>[<b>dpi</b>,<b>dpcm</b>]] |
| 19 |
[<b>-optimize</b>|<b>-optimise</b>] |
| 20 |
[<b>-rgb</b>] |
| 21 |
[<b>-progressive</b>] |
| 22 |
[<b>-comment=</b><i>text</i>] |
| 23 |
[<b>-dct=</b>{<b>int</b>|<b>fast</b>|<b>float</b>}] |
| 24 |
[<b>-arithmetic</b>] |
| 25 |
[<b>-restart=</b><i>n</i>] |
| 26 |
[<b>-smooth=</b><i>n</i>] |
| 27 |
[<b>-maxmemory=</b><i>n</i>] |
| 28 |
[<b>-verbose</b>] |
| 29 |
[<b>-baseline</b>] |
| 30 |
[<b>-qtables=</b><i>filespec</i>] |
| 31 |
[<b>-qslots=n[,...]</b>] |
| 32 |
[<b>-sample=</b><i>H</i><b>x</b><i>V</i>[,...]] |
| 33 |
[<b>-scans=</b><i>filespec</i>] |
| 34 |
[<b>-tracelevel=</b><i>N</i>] |
| 35 |
|
| 36 |
<i>filename</i> |
| 37 |
|
| 38 |
<p>Minimum unique abbreviation of option is acceptable. You may use double |
| 39 |
hyphens instead of single hyphen to denote options. You may use white |
| 40 |
space in place of the equals sign to separate an option name from its value. |
| 41 |
|
| 42 |
|
| 43 |
<h2 id="description">DESCRIPTION</h2> |
| 44 |
|
| 45 |
<p>This program is part of <a href="index.html">Netpbm</a>. |
| 46 |
|
| 47 |
<p><b>pnmtojpeg</b> converts the named PBM, PGM, or PPM image file, or |
| 48 |
the standard input if no file is named, to a JFIF file on the standard |
| 49 |
output. |
| 50 |
|
| 51 |
<p><b>pnmtojpeg</b> uses the Independent JPEG Group's JPEG library to |
| 52 |
create the output file. See <b><a |
| 53 |
href="http://www.ijg.org">http://www.ijg.org</a> </b> for information |
| 54 |
on the library. |
| 55 |
|
| 56 |
<p>"JFIF" is the correct name for the image format commonly |
| 57 |
known as "JPEG." Strictly speaking, JPEG is a method of |
| 58 |
compression. The image format using JPEG compression that is by far |
| 59 |
the most common is JFIF. There is also a subformat of TIFF that uses |
| 60 |
JPEG compression. |
| 61 |
|
| 62 |
<p>EXIF is an image format that is a subformat of JFIF (to wit, a JFIF |
| 63 |
file that contains an EXIF header as an APP1 marker). |
| 64 |
<b>pnmtojpeg</b> creates an EXIF image when you specify the |
| 65 |
<b>-exif</b> option. |
| 66 |
|
| 67 |
<h2 id="options">OPTIONS</h2> |
| 68 |
|
| 69 |
<p>In addition to the options common to all programs based on libnetpbm |
| 70 |
(most notably <b>-quiet</b>, see <a href="index.html#commonoptions"> |
| 71 |
Common Options</a>), <b>pnmtojpeg</b> recognizes the following |
| 72 |
command line options: |
| 73 |
|
| 74 |
<h3 id="basicopts">Basic Options</h3> |
| 75 |
|
| 76 |
<dl compact> |
| 77 |
<dt><b>-exif=</b><i>filespec</i> |
| 78 |
|
| 79 |
<dd> |
| 80 |
This option specifies that the output image is to be EXIF (a subformat |
| 81 |
of JFIF), i.e. it will have an EXIF header as a JFIF APP1 marker. |
| 82 |
The contents of that marker are the contents of the specified file. |
| 83 |
The special value <b>-</b> |
| 84 |
means to read the EXIF header contents from standard input. It is |
| 85 |
invalid to specify standard input for both the EXIF header and the |
| 86 |
input image. |
| 87 |
<p> |
| 88 |
The EXIF file starts with a two byte field which is the length of |
| 89 |
the file, including the length field, in pure binary, most significant |
| 90 |
byte first. The special value of zero for the length field means there |
| 91 |
is to be no EXIF header, i.e. the same as no <b>-exif</b> |
| 92 |
option. This is useful for when you convert a file from JFIF to PNM |
| 93 |
using <b>jpegtopnm</b>, |
| 94 |
then transform it, then convert it back to JFIF with |
| 95 |
<b>pnmtojpeg</b>, and you don't know whether or not it includes an EXIF header. |
| 96 |
<b>jpegtopnm</b> |
| 97 |
creates an EXIF file containing nothing but two bytes of zero when |
| 98 |
the input JFIF file has no EXIF header. Thus, you can transfer |
| 99 |
any EXIF header from the input JFIF to the output JFIF without |
| 100 |
worrying about whether an EXIF header actually exists. |
| 101 |
<p> |
| 102 |
The contents of the EXIF file after the length field are the exact |
| 103 |
byte for byte contents of the APP1 marker, not counting the length |
| 104 |
field, that constitutes the EXIF header. |
| 105 |
|
| 106 |
<dt><b>-quality=</b><i>n</i> |
| 107 |
|
| 108 |
<dd>Scale quantization tables to adjust image quality. <i>n</i> is 0 |
| 109 |
(worst) to 100 (best); default is 75. Below about 25 can produce images |
| 110 |
some interpreters won't be able to interpret. See below for more info. |
| 111 |
|
| 112 |
<dt><b>-grayscale</b> |
| 113 |
<dt><b>-greyscale</b> |
| 114 |
<dt><b>-rgb</b> |
| 115 |
|
| 116 |
<dd>These options determine the color space used in the JFIF output. |
| 117 |
<b>-grayscale</b> (or <b>-greyscale</b>) means to create a gray scale |
| 118 |
JFIF, converting from color PPM input if necessary. <b>-rgb</b> means to |
| 119 |
create an RGB JFIF, and the program fails if the input is not PPM. |
| 120 |
|
| 121 |
<p>If you specify neither, The output file is in YCbCr format if the |
| 122 |
input is PPM, and grayscale format if the input is PBM or PGM. |
| 123 |
|
| 124 |
<p>YCbCr format (a color is represented by an intensity value and two |
| 125 |
chrominance values) usually compresses much better than RGB (a color |
| 126 |
is represented by one red, one green, and one blue value). RGB is |
| 127 |
rare. But you may be able to convert between JFIF and PPM faster with |
| 128 |
RGB, since it's the same color space PPM uses. |
| 129 |
|
| 130 |
<p>The <b>testimg.ppm</b> file that comes with Netpbm is 2.3 times |
| 131 |
larger with the <b>-rgb</b> option than with the YCbCr default, and in |
| 132 |
one experiment <b>pnmtojpeg</b> took 16% more CPU time to convert it. |
| 133 |
The extra CPU time probably indicates that processing of all the extra |
| 134 |
compressed data consumed all the CPU time saved by not having to |
| 135 |
convert the RGB inputs to YCbCr. |
| 136 |
|
| 137 |
<p>Grayscale format takes up a lot less space and takes less time to create |
| 138 |
and process than the color formats, even if the image contains nothing |
| 139 |
but black, white, and gray. |
| 140 |
|
| 141 |
<p>The <b>-rgb</b> option was added in Netpbm 10.11 in October 2002. |
| 142 |
|
| 143 |
<dt><b>-density=</b><i>density</i> |
| 144 |
|
| 145 |
<dd>This option determines the density (aka resolution) information |
| 146 |
recorded in the JFIF output image. It does not affect the raster in |
| 147 |
any way; it just tells whoever reads the JFIF how to interpret the |
| 148 |
raster. |
| 149 |
|
| 150 |
<p>The density value takes the form <i>x</i><b>x</b><i>y</i> followed |
| 151 |
by an optional unit specifier of <b>dpi</b> or <b>dpcm</b>. Examples: |
| 152 |
<b>1x1</b>, <b>3x2</b>, <b>300x300dpi</b>, <b>100x200dpcm</b>. The |
| 153 |
first number is the horizontal density; the 2nd number is the vertical |
| 154 |
density. Each may be any integer from 1 to 65535. The unit specifier |
| 155 |
is <b>dpi</b> for dots per inch or <b>dpcm</b> for dots per |
| 156 |
centimeter. If you don't specify the units, the density information |
| 157 |
goes into the JFIF explicitly stating "density unspecified" (also |
| 158 |
interpreted as "unknown"). This may seem pointless, but note that |
| 159 |
even without specifying the units, the density numbers tell the aspect |
| 160 |
ratio of the pixels. E.g. <b>1x1</b> tells you the pixels are square. |
| 161 |
<b>3x2</b> tells you the pixels are vertical rectangles. |
| 162 |
|
| 163 |
<p>Note that if you specify different horizontal and vertical |
| 164 |
densities, the resulting JFIF image is <em>not</em> a true |
| 165 |
representation of the input PNM image, because <b>pnmtojpeg</b> |
| 166 |
converts the raster pixel-for-pixel and the pixels of a PNM image are |
| 167 |
defined to be square. Thus, if you start with a square PNM image and |
| 168 |
specify <b>-density=3x2</b>, the resulting JFIF image is a horizontally |
| 169 |
squashed version of the original. However, it is common to use an |
| 170 |
input image which is a slight variation on PNM rather than true PNM |
| 171 |
such that the pixels are not square. In that case, the appropriate |
| 172 |
-density option yields a faithful reproduction of the input pseudo-PNM |
| 173 |
image. |
| 174 |
|
| 175 |
<p>The default is 1x1 in unspecified units. |
| 176 |
|
| 177 |
<p>Before Netpbm 10.15 (April 2003), this option did not exist and the |
| 178 |
<b>pnmtojpeg</b> always created a JFIF with a density of 1x1 in |
| 179 |
unspecified units. |
| 180 |
|
| 181 |
<dt><b>-optimize</b> |
| 182 |
|
| 183 |
<dd> Perform optimization of entropy encoding parameters. Without |
| 184 |
this, <b>pnmtojpeg</b> uses default encoding parameters. |
| 185 |
<b>-optimize</b> usually makes the JFIF file a little smaller, but |
| 186 |
<b>pnmtojpeg</b> runs somewhat slower and needs much more memory. |
| 187 |
Image quality and speed of decompression are unaffected by |
| 188 |
<b>-optimize</b>. |
| 189 |
|
| 190 |
<dt><b>-progressive</b> |
| 191 |
|
| 192 |
<dd> |
| 193 |
Create a progressive JPEG file (see below). |
| 194 |
<dt><b>-comment=</b><i>text</i> |
| 195 |
|
| 196 |
<dd> |
| 197 |
Include a comment marker in the JFIF output, with comment text |
| 198 |
<i>text</i>. |
| 199 |
|
| 200 |
Without this option, there are no comment markers in the output. |
| 201 |
|
| 202 |
</dl> |
| 203 |
|
| 204 |
<p>The <b>-quality</b> option lets you trade off compressed file size |
| 205 |
against quality of the reconstructed image: the higher the quality |
| 206 |
setting, the larger the JFIF file, and the closer the output image |
| 207 |
will be to the original input. Normally you want to use the lowest |
| 208 |
quality setting (smallest file) that decompresses into something |
| 209 |
visually indistinguishable from the original image. For this purpose |
| 210 |
the quality setting should be between 50 and 95 for reasonable |
| 211 |
results; the default of 75 is often about right. If you see defects |
| 212 |
at <b>-quality=75</b>, then go up 5 or 10 counts at a time until you |
| 213 |
are happy with the output image. (The optimal setting will vary from |
| 214 |
one image to another.) |
| 215 |
|
| 216 |
<p><b>-quality=100</b> generates a quantization table of all 1's, |
| 217 |
minimizing loss in the quantization step (but there is still |
| 218 |
information loss in subsampling, as well as roundoff error). This |
| 219 |
setting is of interest mainly for experimental purposes. Quality |
| 220 |
values above about 95 are <em>not</em> recommended for normal use; the |
| 221 |
compressed file size goes up dramatically for hardly any gain in |
| 222 |
output image quality. |
| 223 |
|
| 224 |
<p>In the other direction, quality values below 50 will produce very |
| 225 |
small files of low image quality. Settings around 5 to 10 might be |
| 226 |
useful in preparing an index of a large image library, for example. |
| 227 |
Try <b>-quality=2</b> (or so) for some amusing Cubist effects. (Note: |
| 228 |
quality values below about 25 generate 2-byte quantization tables, |
| 229 |
which are considered optional in the JFIF standard. <b>pnmtojpeg</b> |
| 230 |
emits a warning message when you give such a quality value, because |
| 231 |
some other JFIF programs may be unable to decode the resulting file. |
| 232 |
Use <b>-baseline</b> if you need to ensure compatibility at low |
| 233 |
quality values.) |
| 234 |
|
| 235 |
<p>The <b>-progressive</b> option creates a "progressive |
| 236 |
JPEG" file. In this type of JFIF file, the data is stored in |
| 237 |
multiple scans of increasing quality. If the file is being |
| 238 |
transmitted over a slow communications link, the decoder can use the |
| 239 |
first scan to display a low-quality image very quickly, and can then |
| 240 |
improve the display with each subsequent scan. The final image is |
| 241 |
exactly equivalent to a standard JFIF file of the same quality |
| 242 |
setting, and the total file size is about the same -- often a little |
| 243 |
smaller. |
| 244 |
|
| 245 |
<p><strong>Caution:</strong> progressive JPEG is not yet widely |
| 246 |
implemented, so many decoders will be unable to view a progressive |
| 247 |
JPEG file at all. |
| 248 |
|
| 249 |
<p>If you're trying to control the quality/file size tradeoff, you |
| 250 |
might consider the JPEG2000 format instead. See <a |
| 251 |
href="pamtojpeg2k.html">pamtojpeg2k</a>. |
| 252 |
|
| 253 |
<h3 id="advancedopts">Advanced options</h3> |
| 254 |
|
| 255 |
<dl compact> |
| 256 |
|
| 257 |
<dt><b>-dct=int</b> |
| 258 |
|
| 259 |
<dd>Use integer DCT method (default). |
| 260 |
|
| 261 |
<dt><b>-dct=fast</b> |
| 262 |
|
| 263 |
<dd>Use fast integer DCT (less accurate). |
| 264 |
|
| 265 |
<dt><b>-dct=float</b> |
| 266 |
|
| 267 |
<dd>Use floating-point DCT method. The float method is very slightly |
| 268 |
more accurate than the int method, but is much slower unless your |
| 269 |
machine has very fast floating-point hardware. Also note that results |
| 270 |
of the floating-point method may vary slightly across machines, while |
| 271 |
the integer methods should give the same results everywhere. The fast |
| 272 |
integer method is much less accurate than the other two. |
| 273 |
|
| 274 |
<dt><b>-arithmetic</b> |
| 275 |
<dd>Use arithmetic coding. Default is Huffman encoding. Arithmetic coding |
| 276 |
tends to get you a smaller result. |
| 277 |
|
| 278 |
<p>You may need patent licenses to use this option. According to |
| 279 |
<a href="http://www.faqs.org/faqs/jpeg-faq">the JPEG FAQ</a>, |
| 280 |
This method is covered by patents owned by IBM, AT&T, and Mitsubishi. |
| 281 |
|
| 282 |
<p>The author of the FAQ recommends against using arithmetic coding (and |
| 283 |
therefore this option) because the space savings is not great enough to |
| 284 |
justify the legal hassles. |
| 285 |
|
| 286 |
<p>Most JPEG libraries, including any distributed by the Independent |
| 287 |
JPEG Group since about 1998 are not capable of arithmetic encoding. |
| 288 |
<b>pnmtojpeg</b> uses a JPEG library (either bound to it when the |
| 289 |
<b>pnmtojpeg</b> executable was built or accessed on your system at |
| 290 |
run time) to do the JPEG encoding. If <b>pnmtojpeg</b> terminates |
| 291 |
with the message, "Sorry, there are legal restrictions on |
| 292 |
arithmetic coding" or "Sorry, arithmetic coding not |
| 293 |
supported," this is the problem. |
| 294 |
|
| 295 |
<dt><b>-restart=</b><i>n</i> |
| 296 |
|
| 297 |
<dd> |
| 298 |
Emit a JPEG restart marker every <i>n</i> MCU rows, or every <i>n</i> |
| 299 |
MCU blocks if you append <b>B</b> to the number. <b>-restart 0</b> |
| 300 |
(the default) means no restart markers. |
| 301 |
|
| 302 |
<dt><b>-smooth=</b><i>n</i> |
| 303 |
|
| 304 |
<dd> |
| 305 |
Smooth the input image to eliminate dithering noise. <i>n</i>, |
| 306 |
ranging from 1 to 100, indicates the strength of smoothing. 0 (the |
| 307 |
default) means no smoothing. |
| 308 |
|
| 309 |
<dt><b>-maxmemory=</b><i>n</i> |
| 310 |
|
| 311 |
<dd> |
| 312 |
Set a limit for amount of memory to use in processing large images. Value is |
| 313 |
in thousands of bytes, or millions of bytes if you append |
| 314 |
<b>M</b> to the number. For example, <b>-max=4m</b> |
| 315 |
selects 4,000,000 bytes. If <b>pnmtojpeg</b> |
| 316 |
needs more space, it will use temporary files. |
| 317 |
|
| 318 |
<dt><b>-verbose</b> |
| 319 |
|
| 320 |
<dd> |
| 321 |
Print to the Standard Error file messages about the conversion process. |
| 322 |
This can be helpful in debugging problems. |
| 323 |
</dl> |
| 324 |
|
| 325 |
<p>The <b>-restart</b> option tells <b>pnmtojpeg </b> to insert extra |
| 326 |
markers that allow a JPEG decoder to resynchronize after a |
| 327 |
transmission error. Without restart markers, any damage to a |
| 328 |
compressed file will usually ruin the image from the point of the |
| 329 |
error to the end of the image; with restart markers, the damage is |
| 330 |
usually confined to the portion of the image up to the next restart |
| 331 |
marker. Of course, the restart markers occupy extra space. We |
| 332 |
recommend <b>-restart=1</b> for images that will be transmitted |
| 333 |
across unreliable networks such as Usenet. |
| 334 |
|
| 335 |
<p>The <b>-smooth</b> option filters the input to eliminate |
| 336 |
fine-scale noise. This is often useful when converting dithered |
| 337 |
images to JFIF: a moderate smoothing factor of 10 to 50 gets rid of |
| 338 |
dithering patterns in the input file, resulting in a smaller JFIF file |
| 339 |
and a better-looking image. Too large a smoothing factor will visibly |
| 340 |
blur the image, however. |
| 341 |
|
| 342 |
<h3 id="wizardopts">Wizard Options</h3> |
| 343 |
|
| 344 |
<dl compact> |
| 345 |
<dt><b>-baseline</b> |
| 346 |
|
| 347 |
<dd>Force baseline-compatible quantization tables to be generated. |
| 348 |
This clamps quantization values to 8 bits even at low quality |
| 349 |
settings. (This switch is poorly named, since it does not ensure that |
| 350 |
the output is actually baseline JPEG. For example, you can use |
| 351 |
<b>-baseline</b> and <b>-progressive</b> together.) |
| 352 |
|
| 353 |
<dt><b>-qtables=</b><i>filespec</i> |
| 354 |
|
| 355 |
<dd>Use the quantization tables given in the specified text file. |
| 356 |
|
| 357 |
<dt><b>-qslots=n[,...]</b> |
| 358 |
|
| 359 |
<dd>Select which quantization table to use for each color component. |
| 360 |
|
| 361 |
<dt><b>-sample=</b><i>H</i><b>x</b><i>V</i>[,...] |
| 362 |
|
| 363 |
<dd>Set JPEG sampling factors for each color component. |
| 364 |
|
| 365 |
<dt><b>-scans=</b><i>filespec</i> |
| 366 |
|
| 367 |
<dd>Use the scan script given in the specified text file. See below |
| 368 |
for information on scan scripts. |
| 369 |
|
| 370 |
<dt><b>-tracelevel=</b><i>N</i> |
| 371 |
|
| 372 |
<dd>This sets the level of debug tracing the program outputs as it runs. |
| 373 |
0 means none, and is the default. This level primarily controls tracing |
| 374 |
of the JPEG library, and you can get some pretty interesting information |
| 375 |
about the compression process. |
| 376 |
|
| 377 |
</dl> |
| 378 |
|
| 379 |
<p>The "wizard" options are intended for experimentation |
| 380 |
with JPEG. If you don't know what you are doing, <strong>don't use |
| 381 |
them</strong>. These switches are documented further in the file |
| 382 |
wizard.doc that comes with the Independent JPEG Group's JPEG library. |
| 383 |
|
| 384 |
<h2 id="examples">EXAMPLES</h2> |
| 385 |
|
| 386 |
<p>This example compresses the PPM file foo.ppm with a quality factor |
| 387 |
of 60 and saves the output as foo.jpg: |
| 388 |
|
| 389 |
<pre> |
| 390 |
<b>pnmtojpeg -quality=60 foo.ppm > foo.jpg</b> |
| 391 |
</pre> |
| 392 |
|
| 393 |
<p>Here's a more typical example. It converts from BMP to JFIF: |
| 394 |
|
| 395 |
<pre> |
| 396 |
<b>cat foo.bmp | bmptoppm | pnmtojpeg > foo.jpg</b> |
| 397 |
</pre> |
| 398 |
|
| 399 |
<h2 id="loss">JPEG LOSS</h2> |
| 400 |
|
| 401 |
<p>When you compress with JPEG, you lose information -- i.e. the resulting |
| 402 |
image has somewhat lower quality than the original. This is a characteristic |
| 403 |
of JPEG itself, not any particular program. So if you do the usual |
| 404 |
Netpbm thing and convert from JFIF to PNM, manipulate, then convert back |
| 405 |
to JFIF, you will lose quality. The more you do it, the more you lose. |
| 406 |
Drawings (charts, cartoons, line drawings, and such with few colors |
| 407 |
and sharp edges) suffer the most. |
| 408 |
|
| 409 |
<p>To avoid this, you can use a compressed image format other than |
| 410 |
JPEG. PNG and JPEG2000 are good choices, and Netpbm contains converters |
| 411 |
for those. |
| 412 |
|
| 413 |
<p>If you need to use JFIF on a drawing, you should experiment with |
| 414 |
<b>pnmtojpeg</b>'s <b>-quality</b> and <b>-smooth</b> options to get a |
| 415 |
satisfactory conversion. <b>-smooth 10</b> or so is often helpful. |
| 416 |
|
| 417 |
<p>Because of the loss, you should do all the manipulation you have to |
| 418 |
do on the image in some other format and convert to JFIF as the last |
| 419 |
step. And if you can keep a copy in the original format, so much the |
| 420 |
better. |
| 421 |
|
| 422 |
The <b>-optimize</b> option to <b>pnmtojpeg</b> is worth using when |
| 423 |
you are making a "final" version for posting or archiving. |
| 424 |
It's also a win when you are using low quality settings to make very |
| 425 |
small JFIF files; the percentage improvement is often a lot more than |
| 426 |
it is on larger files. (At present, <b>-optimize</b> mode is |
| 427 |
automatically in effect when you generate a progressive JPEG file). |
| 428 |
|
| 429 |
<p>You can do flipping and rotating transformations losslessly with |
| 430 |
the program <b>jpegtran</b>, which is packaged with the Independent |
| 431 |
Jpeg Group's JPEG library. <b>jpegtran</b> exercises its intimate |
| 432 |
knowledge of the way JPEG works to do the transformation without ever |
| 433 |
actually decompressing the image. |
| 434 |
|
| 435 |
<h2 id="otherprog">OTHER PROGRAMS</h2> |
| 436 |
|
| 437 |
<p>Another program, <b>cjpeg</b>, is similar. <b>cjpeg</b> is |
| 438 |
maintained by the Independent JPEG Group and packaged with the JPEG |
| 439 |
library which <b>pnmtojpeg</b> uses for all its JPEG work. Because of |
| 440 |
that, you may expect it to exploit more current JPEG features. Also, |
| 441 |
since you have to have the library to run <b>pnmtojpeg</b>, but not |
| 442 |
vice versa, <b>cjpeg</b> may be more commonly available. |
| 443 |
|
| 444 |
<p>On the other hand, <b>cjpeg</b> does not use the NetPBM libraries |
| 445 |
to process its input, as all the NetPBM tools such as <b>pnmtojpeg</b> |
| 446 |
do. This means it is less likely to be consistent with all the other |
| 447 |
programs that deal with the NetPBM formats. Also, the command syntax |
| 448 |
of <b>pnmtojpeg</b> is consistent with that of the other Netpbm tools, |
| 449 |
unlike <b>cjpeg</b>. |
| 450 |
|
| 451 |
<h2 id="scanscripts">SCAN SCRIPTS</h2> |
| 452 |
|
| 453 |
<p>Use the <b>-scan</b> option to specify a scan script. Or use the |
| 454 |
<b>-progressive</b> option to specify a particular built-in scan |
| 455 |
script. |
| 456 |
|
| 457 |
<p>Just what a scan script is, and the basic format of the scan script |
| 458 |
file, is covered in the <b>wizard.doc</b> file that comes with the |
| 459 |
Independent JPEG Group's JPEG library. Scan scripts are same for |
| 460 |
<b>pnmtojpeg</b> as the are for <b>cjpeg</b>. |
| 461 |
|
| 462 |
<p>This section contains additional information that isn't, but |
| 463 |
probably should be, in that document. |
| 464 |
|
| 465 |
<p>First, there are many restrictions on what is a valid scan script. |
| 466 |
The JPEG library, and thus <b>pnmtojpeg</b>, checks thoroughly for any |
| 467 |
lack of compliance with these restrictions, but does little to tell |
| 468 |
you how the script fails to comply. The messages are very general and |
| 469 |
sometimes untrue. |
| 470 |
|
| 471 |
<p> |
| 472 |
To start with, the entries for the DC coefficient must come before any |
| 473 |
entries for the AC coefficients. The DC coefficient is Coefficient 0; |
| 474 |
all the other coefficients are AC coefficients. So in an entry for |
| 475 |
the DC coefficient, the two numbers after the colon must be 0 and 0. |
| 476 |
In an entry for AC coefficients, the first number after the colon must |
| 477 |
not be 0. |
| 478 |
<p> |
| 479 |
In a DC entry, the color components must be in increasing order. |
| 480 |
E.g. "0,2,1" before the colon is wrong. So is "0,0,0". |
| 481 |
<p> |
| 482 |
In an entry for an AC coefficient, you must specify only one color |
| 483 |
component. I.e. there can be only one number before the colon. |
| 484 |
<p> |
| 485 |
In the first entry for a particular coefficient for a particular color |
| 486 |
component, the "Ah" value must be zero, but the Al value can be any |
| 487 |
valid bit number. In subsequent entries, Ah must be the Al value from |
| 488 |
the previous entry (for that coefficient for that color component), |
| 489 |
and the Al value must be one less than the Ah value. |
| 490 |
<p> |
| 491 |
The script must ultimately specify at least some of the DC coefficient |
| 492 |
for every color component. Otherwise, you get the error message |
| 493 |
"Script does not transmit all the data." You need not specify all of |
| 494 |
the bits of the DC coefficient, or any of the AC coefficients. |
| 495 |
<p> |
| 496 |
There is a standard option in building the JPEG library to omit scan |
| 497 |
script capability. If for some reason your library was built with |
| 498 |
this option, you get the message "Requested feature was omitted at |
| 499 |
compile time." |
| 500 |
|
| 501 |
<h2 id="environment">ENVIRONMENT</h2> |
| 502 |
|
| 503 |
<dl compact> |
| 504 |
<dt><b>JPEGMEM</b> |
| 505 |
|
| 506 |
<dd>If this environment variable is set, its value is the default |
| 507 |
memory limit. The value is specified as described for the |
| 508 |
<b>-maxmemory</b> option. An explicit <b>-maxmemory </b> option |
| 509 |
overrides any <b>JPEGMEM</b>. |
| 510 |
|
| 511 |
</dl> |
| 512 |
|
| 513 |
<h2 id="seealso">SEE ALSO</h2> |
| 514 |
|
| 515 |
<b><a href="jpegtopnm.html">jpegtopnm</a></b>, |
| 516 |
<b><a href="pnm.html">pnm</a></b>, |
| 517 |
<b>cjpeg</b> man page, |
| 518 |
<b>djpeg</b> man page, |
| 519 |
<b>jpegtran</b> man page, |
| 520 |
<b>rdjpgcom</b> man page, |
| 521 |
<b>wrjpgcom</b> man page |
| 522 |
|
| 523 |
<p>Wallace, Gregory K. "The JPEG Still Picture Compression |
| 524 |
Standard", Communications of the ACM, April 1991 (vol. 34, |
| 525 |
no. 4), pp. 30-44. |
| 526 |
|
| 527 |
|
| 528 |
<h2 id="author">AUTHOR</h2> |
| 529 |
|
| 530 |
<b>pnmtojpeg</b> and this manual were derived in large part from |
| 531 |
<b>cjpeg</b>, by the Independent JPEG Group. The program is otherwise |
| 532 |
by Bryan Henderson on March 07, 2000. |
| 533 |
|
| 534 |
<hr> |
| 535 |
<h2 id="index">Table Of Contents</h2> |
| 536 |
<ul> |
| 537 |
<li><a href="#synopsis">SYNOPSIS</a> |
| 538 |
<li><a href="#description">DESCRIPTION</a> |
| 539 |
<li><a href="#options">OPTIONS</a> |
| 540 |
<ul> |
| 541 |
<li><a href="#basicopts">Basic Options</a> |
| 542 |
<li><a href="#advancedopts">Advanced options</a> |
| 543 |
<li><a href="#wizardopts">Wizard Options</a> |
| 544 |
</ul> |
| 545 |
<li><a href="#examples">EXAMPLES</a> |
| 546 |
<li><a href="#loss">JPEG LOSS</a> |
| 547 |
<li><a href="#otherprog">OTHER PROGRAMS</a> |
| 548 |
<li><a href="#scanscripts">SCAN SCRIPTS</a> |
| 549 |
<li><a href="#environment">ENVIRONMENT</a> |
| 550 |
<li><a href="#seealso">SEE ALSO</a> |
| 551 |
<li><a href="#author">AUTHOR</a> |
| 552 |
</ul> |
| 553 |
</body> |
| 554 |
</html> |