1Libnetpbm Image Processing MLainburaalr(y3)FunctionLsibMnaentupablm Image Processing Manual(3)
2
3
4
5       Table Of Contents ⟨#toc⟩
6

NAME

8       libnetpbm_image - overview of netpbm image-processing functions
9

DESCRIPTION

11       This  reference  manual  covers  functions in the libnetpbm library for
12       processing images, using the Netpbm image formats and the libnetpbm in-
13       memory image formats.
14
15       For  historical  reasons as well as to avoid clutter, it does not cover
16       the largely obsolete PBM, PGM, PPM, and PNM classes of libnetpbm  func‐
17       tions.  For those, see
18
19
20       ·
21
22              PBM Function Manual(1)
23
24       ·
25
26              PGM Function Manual(1),
27
28       ·
29
30              PPM Function Manual(1)
31
32       ·
33
34              PNM Function Manual(1)
35
36              Note  that  you do not need those functions to process PBM, PGM,
37              PPM, and PNM images.  The functions in this  manual  are  suffi‐
38              cient for that.
39
40       The  PPM  drawing functions are covered separately in PPM Drawing Func‐
41       tion Manual(1).
42
43       The PBM text font functions are convered separately in PBM  Font  Func‐
44       tion Manual(1).
45
46       For introductory and general information using libnetpbm, see Libnetpbm
47       User's Guide(1).
48
49       libnetpbm also contains functions that are  not  specifically  oriented
50       toward  processing image data.  Read about those in the Libnetpbm Util‐
51       ity Manual(1).
52
53       To use these services, #include pam.h.
54
55
56

Types

58       Here are some important types that you use with libnetpbm:
59
60
61
62
63       sample A sample of a Netpbm image.  See the format specifications -- as
64              an  example,  the  red  intensity of a particular pixel of a PPM
65              image is a sample.  This is an integer type.
66
67
68       tuple  A tuple from a PAM image or the PAM equivalent of a  PNM  image.
69              See  the PAM format specification -- as an example, a pixel of a
70              PPM image would be a tuple.  A tuple is an array of samples.
71
72
73       samplen
74              Same as sample, except in normalized form.  This is  a  floating
75              point  type  with a value in the range 0..1.  0 corresponds to a
76              PAM/PNM sample value of 0.  1 corresponds to  a  PAM/PNM  sample
77              value equal to the image's maxval.
78
79
80       tuplen The  same  as tuple, except composed of normalized samples (sam‐
81              plen) instead of regular samples (sample).
82
83
84
85
86
87   struct pam
88       The main argument to most of the PAM functions is the address of a  pam
89       structure, which is defined as follows:
90
91
92           struct pam {
93               int size
94               int len
95               FILE *file
96               int format
97               int plainformat
98               int height
99               int width
100               int depth
101               sample maxval
102               int bytes_per_sample
103               char tuple_type[256]
104               int allocation_depth
105               char **comment_p;
106           }
107
108
109       See The Libnetbm User's Guide ⟨libnetpbm_ug.html#pamstruct⟩  for infor‐
110       mation on the pam structure.
111
112
113

Macros

115       PNM_MAXMAXVAL is the maximum maxval that Netpbm images  could  histori‐
116       cally  have:  255.   Many  programs  aren't  capable of handling Netpbm
117       images with a maxval larger than this.  It's named this way  for  back‐
118       ward  compatibility  --  it  had this name back when it was the maximum
119       maxval.
120
121       PNM_OVERALLMAXVAL is the maximum maxval that  Netpbm  images  can  have
122       today (65535).
123
124       PBM_FORMAT, RPBM_FORMAT, PGM_FORMAT, RPGM_FORMAT, PPM_FORMAT, RPPM_FOR‐
125       MAT, and PAM_FORMAT are the format codes of the various Netpbm formats.
126       RPBM_FORMAT  is the raw PBM format and PBM_FORMAT is the plain PBM for‐
127       mat,  and  so  on.   See  the  format  member  of  the  pam   structure
128       ⟨libnetpbm_ug.html#pamstruct⟩ .
129
130       PAM_FORMAT_TYPE(format)  gives  the  type of a format, given the format
131       code.  The types of formats are PBM, PGM, PPM, and PAM and  macros  for
132       the  type  codes  are,  respectively, PBM_TYPE, PGM_TYPE, PPM_TYPE, and
133       PAM_TYPE.  Note that there are more format codes then there are  format
134       types  because  there  are different format codes for the plain and raw
135       subformats of each format.
136
137       Macros for the tuple types that are defined by Netpbm are  as  follows.
138       See     the     tuple_type     member     of    the    pam    structure
139       ⟨libnetpbm_ug.html#pamstruct⟩ .
140
141
142       ·      PAM_PBM_TUPLETYPE
143
144       ·      PAM_PGM_TUPLETYPE
145
146       ·      PAM_PPM_TUPLETYPE
147
148       ·      PAM_PBM_ALPHA_TUPLETYPE
149
150       ·      PAM_PGM_ALPHA_TUPLETYPE
151
152       ·      PAM_PPM_ALPHA_TUPLETYPE
153
154
155
156

Functions

158       These interfaces are declared in pam.h.
159
160
161   Memory Management
162       Synopsis
163
164       tuple ** pnm_allocpamarray( struct pam *pamP);
165
166       tuple * pnm_allocpamrow( struct pam *pamP);
167
168       void pnm_freepamarray( tuple **tuplearray, struct pam *pamP);
169
170       void pnm_freepamrow( tuple *tuplerow);
171
172       tuple * allocpamtuple( struct pam *pamP);
173
174       void pnm_freepamtuple( tuple tuple );
175
176       tuple * allocpamtuplen( struct pam *pamP);
177
178       tuplen * pnm_allocpamrown( struct pam *pamP);
179
180       void pnm_freepamrown( tuplen *tuplenrow);
181
182
183
184       Description
185
186       pnm_allocpamtuple allocates space for a tuple.
187         pnm_freepamtuple frees space allocated for a tuple.
188
189       pnm_allocpamarray()  allocates  space   for   an   array   of   tuples.
190       pnm_freepamarray()  frees  an  array space allocated by pnm_allocpamar‐
191       ray() or pnm_readpam().
192
193       pnm_allocpamtuplen is the same  as  pnm_allocpamtuple  except  that  it
194       allocates  space for a tuple in the normalized form.  pnm_freepamtuplen
195       is similarly like pnm_freepamtuple.
196
197       pnm_allocpamrow()  allocates space for a row of a PAM image,  in  basic
198       form.  pnm_freepamrow() frees it.
199
200       pnm_allocpamrown()  is  the  same  as  pnm_allocpamrow() except that it
201       allocates space for a PAM row in  the  normalized  form.   pnm_freepam‐
202       rown() is similarly like pnm_freepamrow.
203
204
205
206   Reading Netpbm Files
207       Synopsis
208
209       void pnm_readpaminit( FILE *file, struct pam *pamP, int size);
210
211       void pnm_readpamrow( struct pam *pamP, tuple *tuplerow);
212
213       tuple ** pnm_readpam( FILE *file, struct pam *pamP, int size);
214
215       void pnm_readpamrown( struct pam *pamP, tuplen *tuplenrow);
216
217
218       Description
219
220       pnm_readpaminit() reads the header of a Netpbm image.
221
222       See above for a general description of the pamP argument.
223
224       pnm_readpaminit()  returns the information from the header in the *pamP
225       structure.  It does not require any members of *pamP through tuple_type
226       to be set at invocation, and sets all of those members.  It expects all
227       members after tuple_type to be meaningful.
228
229       size is the size of the *pamP structure as understood  by  the  program
230       processing the image.  pnm_readpaminit() does not attempt to use or set
231       any members of the structure beyond that.  The point of  this  argument
232       is  that  the  definition  of  the structure may change over time, with
233       additional fields  being  added  to  the  end.   This  argument  allows
234       pnm_readpaminit  to  distinguish  between  a  new program that wants to
235       exploit the additional features and an old program that  cannot  (or  a
236       new  program that just doesn't want to deal with the added complexity).
237       At a minimum, this size must contain the members up through tuple_type.
238       You  should  use  the  PAM_STRUCT_SIZE  macro to compute this argument.
239       E.g. PAM_STRUCT_SIZE(tuple_type).
240
241       PAM_STRUCT_SIZE was introduced in Netpbm 10.23 (July 2004).   In  older
242       Netpbm,  you  can  just use sizeof(), but then your code is not forward
243       compatible at the source code level with newer libnetpbm (because  when
244       you compile it with newer libnetpbm header files, you'll be saying your
245       structure contains all the new members that  have  been  invented,  but
246       your code doesn't actually initialize them).  So you might want to com‐
247       pute a proper size yourself.
248
249       The function expects to find the image file positioned to the start  of
250       the header and leaves it positioned to the start of the raster.
251
252       pnm_readpamrow()  reads  a  row of the raster from a Netpbm image file.
253       It expects all of the members of the *pamP structure  to  be  set  upon
254       invocation  and  does  not  modify any of them.  It expects to find the
255       file positioned to the start of the row in question in the  raster  and
256       leaves it positioned just after it.  It returns the row as the array of
257       tuples tuplerow, which must already have its column pointers set up  so
258       that it forms a C 2-dimensional array.  The leftmost tuple is Element 0
259       of this array.
260
261       pnm_readpam() reads an entire image from a PAM or PNM  image  file  and
262       allocates  the space in which to return the raster.  It expects to find
263       the file positioned to the first byte of the image and leaves it  posi‐
264       tioned just after the image.
265
266       *pamP is the same as for pnm_readpaminit().
267
268       The  return  value is a newly allocated array of the rows of the image,
269       with the top row being Element 0 of the array.  Each row is represented
270       as pnm_readpamrow() would return.
271
272       The  return  value  is also effectively a 3-dimensional C array of sam‐
273       ples, with the dimensions corresponding to the height, width, and depth
274       of the image, in that order.
275
276       pnm_readpam()  combines the functions of pnm_allocpamarray(), pnm_read‐
277       paminit(), and iterations of pnm_readpamrow().   It  may  require  more
278       dynamic storage than you can afford.
279
280       pnm_readpamrown()  is  like pnm_readpamrow() except that it returns the
281       row contents in normalized form (composed of normalized tuples (tuplen)
282       instead of basic form (tuple).
283
284       pnm_readpaminit()  and  pnm_readpam abort the program with a message to
285       Standard Error if the PAM or PNM  image  header  is  not  syntactically
286       valid,  including  if  it  contains  a number too large to be processed
287       using the system's normal data structures (to wit, a number that  won't
288       fit in a C 'int').
289
290
291   Writing Netpbm Files
292       Synopsis
293
294       void pnm_writepaminit( struct pam *pamP);
295
296       void pnm_writepamrow( struct pam *pamP, const tuple *tuplerow);
297
298       void pnm_writepam( struct pam *pamP, const tuple * const *tuplearray);
299
300       void pnm_writepamrown( struct pam *pamP, const tuplen *tuplerown);
301
302       void pnm_formatpamrow( struct pam *pamP, const tuple *tuplerow unsigned
303       char * const outbuf, unsigned int * const rowSizeP );
304
305       Description
306
307       pnm_writepaminit() writes the header of a PAM or PNM image and computes
308       some of the fields of the pam structure.
309
310       See above for a description of the pamP argument.
311
312       The  following  members of the *pamP structure must be set upon invoca‐
313       tion to tell the function how and what to write.  size, len, file, for‐
314       mat,  height, width, depth, maxval.  Furthermore, if format is PAM_FOR‐
315       MAT, tuple_type must be set and if format is not PAM_FORMAT,  plainfor‐
316       mat must be set.
317
318       pnm_writepaminit() sets the bytes_per_sample member based on the infor‐
319       mation supplied.
320
321       pnm_writepamrow() writes a row of the raster into a PAM  or  PNM  image
322       file.   It  expects  to  find  the file positioned where the row should
323       start and leaves it  positioned  just  after  the  row.   The  function
324       requires  all  the  elements  of  *pamP  to  be set upon invocation and
325       doesn't modify them.
326
327       tuplerow is an array of tuples  representing  the  row.   The  leftmost
328       tuple is Element 0 of this array.
329
330       pnm_writepam()  writes an entire PAM or PNM image to a PAM or PNM image
331       file.  It expects to find the file positioned to where the image should
332       start and leaves it positioned just after the image.
333
334       The  members of the *pamP structure that must be set up invocation, and
335       their meanings, is the same as for pnm_writepaminit.
336
337       pnm_writepam() sets the bytes_per_sample member based on  the  informa‐
338       tion supplied.
339
340       tuplearray   is   an  array  of  rows  such  that  you  would  pass  to
341       pnm_writepamrow(), with the top row being Element 0 of the array.
342
343       pnm_writepam() combines the functions of pnm_writepaminit(), and itera‐
344       tions  of pnm_writepamrow().  Its raster input may be more storage than
345       you can afford.
346
347       pnm_writepamrown() is like pnm_writepamrow() except that it  takes  the
348       row contents in normalized form (composed of normalized tuples (tuplen)
349       instead of basic form (tuple).
350
351       pnm_formatpamrow() is like pnm_writepamrow(), except  that  instead  of
352       writing  a row to a file, it places the same bytes that would go in the
353       file in a buffer you supply.  There isn't  an  equivalent  function  to
354       construct   an   image   header;   i.e.   there   is   no   analog   to
355       pnm_writepaminit().  But the header format, particularly for PAM, is so
356       simple  that  you  can easily build it yourself with standard C library
357       string functions.
358
359       pnm_formatpamrow() was new in Netpbm 10.25 (October 2004).
360
361
362   Transforming Pixels
363       Synopsis
364
365       void pnm_YCbCrtuple( tuple  tuple,  double  *YP,  double  *CrP,  double
366       *CbP);
367
368       void  pnm_YCbCr_to_rgbtuple( const struct pam * const pamP, tuple const
369       tuple, double const Y, double const Cb, double const Cr,  int  *  const
370       overflowP);
371
372       extern double pnm_lumin_factor[3];
373
374       void  pnm_normalizetuple(  struct  pam * const pamP, tuple        const
375       tuple, tuplen       const tuplen);
376
377       void pnm_unnormalizetuple( struct pam * const pamP, tuplen        const
378       tuplen, tuple        const tuple);
379
380       void  pnm_normalizeRow(  struct  pam  *       const pamP, const tuple *
381       const  tuplerow,  pnm_transformMap  *   const   transform,   tuplen   *
382       const tuplenrow);
383
384       void  pnm_unnormalizeRow( struct pam *       const pamP, const tuplen *
385       const  tuplenrow,  pnm_transformMap  *   const   transform,   tuple   *
386       const tuplerow);
387
388       void pnm_gammarown( struct pam * const pamP, tuplen *     const row);
389
390       void pnm_ungammarown( struct pam * const pamP, tuplen *     const row);
391
392       void  pnm_applyopacityrown( struct pam * const pamP, tuplen *     const
393       tuplenrow);
394
395       void  pnm_unapplyopacityrown(  struct  pam  *  const  pamP,  tuplen   *
396       const tuplenrow);
397
398       pnm_transformMap  *  pnm_creategammatransform( const struct pam * const
399       pamP);
400
401       void pnm_freegammatransform( const pnm_transformMap * const  transform,
402       const struct pam *       const pamP);
403
404       pnm_transformMap * pnm_createungammatransform( const struct pam * const
405       pamP);
406
407       void pnm_freeungammatransform( const pnm_transformMap  *  const  trans‐
408       form, const struct pam *       const pamP);
409
410
411       Description
412
413       pnm_YCbCrtuple()  returns the Y/Cb/Cr luminance/chrominance representa‐
414       tion of the color represented by the input  tuple,  assuming  that  the
415       tuple  is an RGB color representation (which is the case if it was read
416       from a PPM image).  The output components are based on the  same  scale
417       (maxval)  as  the  input  tuple,  but are floating point nonetheless to
418       avoid losing information because of rounding.  Divide them by the  max‐
419       val to get normalized [0..1] values.
420
421       pnm_YCbCr_to_rgbtuple()  does  the  reverse.  pamP indicates the maxval
422       for the returned tuple, and the Y, Cb, and Cr arguments are of the same
423       scale.
424
425       It  is  possible  for  Y, Cb, and Cr to describe a color that cannot be
426       represented in RGB form.  In that case, pnm_YCbCr_to_rgbtuple() chooses
427       a  color  as close as possible (by clipping each component to 0 and the
428       maxval) and sets *overflowP true.  It otherwise sets *overflowP false.
429
430
431       pnm_lumin_factor[] is the factors (weights) one  uses  to  compute  the
432       intensity  of  a  color  (according  to  some  standard -- I don't know
433       which).  pnm_lumin_factor[0] is for the red component, [1] is  for  the
434       green, and [2] is for the blue.  They add up to 1.
435
436       pnm_gammarown()  and  pnm_ungammarown() apply and unapply gamma correc‐
437       tion  to  a  row  of  an  image  using  the  same   transformation   as
438       pm_gamma709() and pm_ungamma709() ⟨libpm.html#gamma⟩ .  Note that these
439       operate on a row of normalized tuples (tuplen, not tuple).
440
441       pnm_applyopacityrown() reduces the intensity of samples  in  accordance
442       with  the  opacity plane of an image.  The opacity plane, if it exists,
443       tells how much of the light from that pixel should show when the  image
444       is  composed  with  another  image.   You use pnm_applyopacityrown() in
445       preparation for doing such a composition.  For example, if the  opacity
446       plane  says that the left half of the image is 50% opaque and the right
447       half 100% opaque, pnm_applyopacityrown() will reduce the  intensity  of
448       each sample of each tuple (pixel) in the left half of the image by 50%,
449       and leave the rest alone.
450
451       If the image does not have an opacity plane (i.e. its tuple type is not
452       one  that  libnetpbm recognizes as having an opacity plane), pnm_apply‐
453       opacityrown() does nothing (which  is  the  same  as  assuming  opacity
454       100%).  The tuple types that libnetpbm recognizes as having opacity are
455       RGB_ALPHA and GRAYSCALE_ALPHA.
456
457       pnm_unapplyopacityrown() does the reverse.  It assumes the  intensities
458       are  already reduced according to the opacity plane, and raises back to
459       normal.
460
461       pnm_applyopacityrown() works on (takes as input and produces as output)
462       normalized,  intensity-proportional  tuples.  That means you will typi‐
463       cally read the row from the image file with pnm_readpamrown() and  then
464       gamma-correct  it with pnm_ungammarown(), and then do pnm_applyopacity‐
465       rown().  You then manipulate the row further (perhaps add it with other
466       rows  you've  processed  similarly),  then do pnm_unapplyopacityrown(),
467       then pnm_gammarown(), then pnm_writepamrown().
468
469       pnm_applyopacityrown() and pnm_unapplyopacityrown() were new in  Netpbm
470       10.25 (October 2004).
471
472       pnm_normalizetuple() and pnm_unnormalizetuple() convert between a tuple
473       data type and a tuplen data type.  The former represents a sample value
474       using  the  same  unsigned  integer that is in the PAM image, while the
475       latter represents a sample value as a number scaled by  the  maxval  to
476       the  range  0..1.  I.e. pnm_normalizetuple() divides every sample value
477       by the maxval and pnm_unnormalizetuple() multiples every sample by  the
478       maxval.
479
480       pnm_normalizeRow()  and  pnm_unnormalizeRow()  do  the same thing on an
481       entire tuple row, but also have an extra feature:  You  can  specify  a
482       transform  function  to  be  applied in addition.  Typically, this is a
483       gamma transform function.  You can of course  more  easily  apply  your
484       transform  function  separately  from  normalizing, but doing it all at
485       once is usually way faster.  Why?  Because you can use a  lookup  table
486       that is indexed by an integer on one side and produces a floating point
487       number on the other.  To do it separately,  you'd  either  have  to  do
488       floating  point  arithmetic on the normalized value or do the transform
489       on the integer values and lose a lot of precision.
490
491       If you don't have any transformation to apply, just  specify  NULL  for
492       the  transform  argument  and  the  function  will just normalize (i.e.
493       divide or multiply by the maxval).
494
495       Here's an example of doing a transformation.  The example composes  two
496       images  together,  something  that has to be done with intensity-linear
497       sample values.
498
499
500       pnm_transformMap * const transform1 = pnm_createungammatransform(&inpam1);
501       pnm_transformMap * const transform2 = pnm_createungammatransform(&inpam2);
502       pnm_transformMap * const transformOut = pnm_creategammatransform(&outpam);
503
504       pnm_readpamrow(&inpam1, inrow1);
505       pnm_readpamrow(&inpam2, inrow2);
506
507       pnm_normalizeRow(&inpam1, inrow1, transform1, normInrow1);
508       pnm_normalizeRow(&inpam2, inrow2, transform2, normInrow2);
509
510       for (col = 0; col < outpam.width; ++col)
511           normOutrow[col] = (normInrow1[col] + normInrow2[col])/2;
512
513       pnm_unnormalizeRow(&outpam, normOutrow, transformOut, outrow);
514
515       pnm_writepamrow(&outpam, outrow);
516
517
518       To specify a transform, you  must  create  a  special  pnm_transformMap
519       object  and  pass it as the transform argument.  Typically, your trans‐
520       form is a gamma transformation because you want to work  in  intensity-
521       proportional sample values and the PAM image format uses gamma-adjusted
522       ones.  In that case, just use pnm_creategammatransform() and  pnm_crea‐
523       teungammatransform() to create this object and don't worry about what's
524       inside it.
525
526       pnm_creategammatransform()  and   pnm_createungammatransform()   create
527       objects  that  you use with pnm_normalizeRow() and pnm_unnormalizeRow()
528       as described above.  The created  object  describes  a  transform  that
529       applies  or  reverses  the ITU-R Recommendation BT.709 gamma adjustment
530       that is used in PAM visual images and normalizes  or  unnormalizes  the
531       sample values.
532
533       pnm_freegammatransform()  and  pnm_freeungammatransform()  destroy  the
534       objects.
535
536
537   Color specification
538       These are functions you use that deal with  names  or  identifiers  for
539       colors.
540
541       Synopsis
542
543       tuple pnm_parsecolor( const char * colorname, sample maxval );
544
545
546       tuple  pnm_parsecolor2(  const  char  *  colorname,  sample maxval, int
547       closeOk );
548
549
550       tuplen pnm_parsecolorn( const char * colorname );
551
552       pnm_colorspec_rgb_integer( struct pam * pamP, tuple color, sample  max‐
553       val );
554
555       pnm_colorspec_rgb_norm(  struct  pam  *  pamP, tuple color unsigned int
556       digitCt );
557
558       pnm_colorspec_rgb_x11( struct pam * pamP,  tuple  color,  unsigned  int
559       hexDigitCt );
560
561       pnm_colorspec_dict( struct pam * pamP, tuple color );
562
563       pnm_colorspec_dict_close( struct pam * pamP, tuple color );
564
565
566       Description
567
568       pnm_parsecolor,  pnm_parsecolor2, and pnm_parsecolorn return a color in
569       the conventional form used by libnetpbm to represent a color,  given  a
570       human-intelligible    name   for   the   color   such   as   'red'   or
571       'rgbi:1.0/0.5/0.25'.
572
573       pnm_parsecolorn returns  a  normalized  tuple  (type  tuplen),  whereas
574       pnm_parsecolor and pnm_parsecolor2 return a tuple that
575         uses an integer scale with a specified maxval.
576
577       When you use an integer scale, only certain discrete colors can be rep‐
578       resented, so the functions may round.  For example,  'wheat'  which  is
579       245/222/179  with maxval 255, cannot be represented exactly with maxval
580       15, so if you call pnm_parsecolor to produce a wheat color  tuple  with
581       maxval  15,  you  get  14/13/11,  which  is  not  quite the same.  With
582       pnm_parsecolor2, you get a warning message to Standard Error when  such
583       rounding  occurs,  unless  you  specify closeOk = true.  pnm_parsecolor
584       never warns about this.
585
586       pnm_colorspec_rgb_integer returns the color specification for the color
587       color  in  integer/maxval form like 'rgb-255:0/128/254'.  maxval is the
588       maxval to be used in the color specification (255 in this example);
589
590       pnm_colorspec_rgb_norm returns the color specification  for  the  color
591       color in normalized form like 'rgbi:0.000/0.052/0.996'.  digitCt is the
592       number of digits after the decimal point  (3  in  this  example).   The
593       function rounds and zero-fills as necessary.
594
595       pnm_colorspec_rgb_x11  returns  the  color  specification for the color
596       color in X11 form like 'rgb:00/80/fe'.  hexDigitCt  is  the  number  of
597       hexadecimal  digits to use for each component (2 in this example).  The
598       function rounds and zero-fills as necessary.
599
600       pnm_colorspec_dict returns the color specification for the color  color
601       as  name such as 'pink' from the color dictionary.  If the color is not
602       in the dictionary, including where the function does not find  a  color
603       dictionary file, the return value is null.
604
605       pnm_colorspect_dict_close is the same as pnm_colorspec_dict except that
606       when the color is not in the dictionary, it returns the  closest  color
607       to it that is in the dictionary.  As an exception, if the function can‐
608       not find a color dictionary file or the file it finds does not  contain
609       even a single color definition, the function returns a null string.
610
611
612       <h5>Color name</h5>
613
614       Color  names  in Netpbm are ASCSII text in one of the formats described
615       below.  This is what you use for the colorname  argument  of  functions
616       such  as  pnm_parsecolor  and  is the return value of functions such as
617       pnm_colorspec_rgb_norm.
618
619
620
621
622       ·      a name, as defined in the system color dictionary ⟨#rgb.txt⟩ .
623
624
625       ·
626               An X11-style hexadecimal specifier: rgb:r/g/b, where r, g,  and
627              b  are  each  1-  to 4-digit hexadecimal numbers.  For each, the
628              maxval is the maximum number that can be represented in the num‐
629              ber of hexadecimal digits given.  Example: rgb:01/ff/8000 speci‐
630              fies 1/255 red intensity, maximum  green  intensity,  and  about
631              half blue intensity.
632
633
634       ·
635               An  X11-style  decimal specifier: rgbi:r/g/b, where r, g, and b
636              are  floating   point   numbers   from   0   to   1.    Example:
637              rgbi:1.0/0.5/.25.
638
639
640       ·      rgb-maxval:r/g/b,  where r, g, and b are integers from 0 to max‐
641              val.  Example: rgb-255:255/128/64.  maxval  can  be  from  1  to
642              65535.
643
644              This format was new in Netpbm 10.83 (June 2018).
645
646
647       ·      an  old-X11-style hexadecimal triple: #rgb, #rrggbb, #rrrgggbbb,
648              or #rrrrggggbbbb.
649
650
651       ·      A triplet of decimal floating point numbers  from  0.0  to  1.0,
652              representing red, green, and blue intensities respectively, sep‐
653              arated by commas.  Example: 1.0,0.5,.25.  This is for  backwards
654              compatibility; it was in use before MIT came up with the similar
655              and preferred rgbi style).
656
657
658
659       If colorname does not conform to any of these  formats,  including  the
660       case  that  it  is  a  name, but is not in the system color dictionary,
661       pnm_parsecolor() throws an error(1).
662
663
664
665   Miscellaneous
666       Synopsis
667
668       void  pnm_checkpam(  struct  pam  *pamP,   const   enum   pm_check_type
669       check_type, enum pm_check_code *retvalP);
670
671       void pnm_nextimage( FILE *file, int * const eofP);
672
673       Description
674
675       pnm_checkpam()  checks  for  the  common file integrity error where the
676       file is the wrong size to contain the raster, according to the informa‐
677       tion in the header.
678
679       pnm_nextimage()positions a Netpbm image input file to the next image in
680       it (so that a subsequent pnm_readpaminit() reads its header).
681

DOCUMENT SOURCE

683       This manual page was generated by the Netpbm tool 'makeman'  from  HTML
684       source.  The master documentation is at
685
686              http://netpbm.sourceforge.net/doc/libnetpbm_image.html
687
688netpbm documentation               May 2018Libnetpbm Image Processing Manual(3)
Impressum