# PNMImage

from pandac.PandaModules import PNMImage

Class : PNMImage
Description : The name of this class derives from the fact that we originally implemented it as a layer on top of the "pnm library", based on netpbm, which was built to implement pbm, pgm, and pbm files, and is the underlying support of a number of public-domain image file converters. Nowadays we are no longer derived directly from the pnm library, mainly to allow support of C++ iostreams instead of the C stdio FILE interface.
Conceptually, a PNMImage is a two-dimensional array of xels, which are the PNM-defined generic pixel type. Each xel may have a red, green, and blue component, or (if the image is grayscale) a gray component. The image may be read in, the individual xels manipulated, and written out again, or a black image may be constructed from scratch.
The image is of size XSize() by YSize() xels, numbered from top to bottom, left to right, beginning at zero.
Files can be specified by filename, or by an iostream pointer. The filename "-" refers to stdin or stdout.

## Inheritance:

PNMImage: PNMImageHeader
PNMImageHeader:

## Methods of PNMImage:

addAlpha
alphaFill
alphaFillVal
blend
blendSubImage
boxFilter
boxFilterFrom
clampVal
clear
clearReadSize
copyFrom
copyHeaderFrom
copySubImage
darkenSubImage
expandBorder
fill
fillVal
fromVal
gaussianFilter
gaussianFilterFrom
getAlpha
getAlphaVal
getBlue
getBlueVal
getBright
getChannel
getChannelVal
getGray
getGrayVal
getGreen
getGreenVal
getReadXSize
getReadYSize
getRed
getRedVal
getXel
getXelA
getXelVal
hasReadSize
isValid
lightenSubImage
makeGrayscale
makeRgb
operator =
operator []
quickFilterFrom
read
remixChannels
removeAlpha
renderSpot
setAlpha
setAlphaVal
setBlue
setBlueVal
setChannel
setChannelVal
setColorType
setGray
setGrayVal
setGreen
setGreenVal
setMaxval
setNumChannels
setReadSize
setRed
setRedVal
setXel
setXelA
setXelVal
takeFrom
toVal
write

## Methods of PNMImageHeader:

getColorType
getComment
getMaxval
getNumChannels
getType
getXSize
getYSize
hasAlpha
hasType
isGrayscale
makeReader
makeWriter
operator =
output
readHeader
readMagicNumber
setComment
setType

## Constants in PNMImageHeader:

CTInvalid | (ColorType)
CTGrayscale | (ColorType)
CTTwoChannel | (ColorType)
CTColor | (ColorType)
CTFourChannel | (ColorType)

addAlpha void PNMImage::add_alpha(void); Description: Adds an alpha channel to the image, if it does not already have one. The alpha channel is initialized to zeros.

alphaFill void PNMImage::alpha_fill(double alpha = (0)); Description: Sets the entire alpha channel to the given level.

alphaFillVal void PNMImage::alpha_fill_val(unsigned short int alpha = (0)); Description: Sets the entire alpha channel to the given level.

blend void PNMImage::blend(int x, int y, LVecBase3d const &val, double alpha); Description: Smoothly blends the indicated pixel value in with whatever was already in the image, based on the given alpha value. An alpha of 1.0 is fully opaque and completely replaces whatever was there previously; alpha of 0.0 is fully transparent and does nothing.

blendSubImage void PNMImage::blend_sub_image(PNMImage const &copy, int xto, int yto, int xfrom = (0), int yfrom = (0), int x_size = (-1), int y_size = (-1), double pixel_scale = (1)); Description: Behaves like copy_sub_image(), except the alpha channel of the copy is used to blend the copy into the destination image, instead of overwriting pixels unconditionally. If pixel_scale is not 1.0, it specifies an amount to scale each *alpha* value of the source image before applying it to the target image. If pixel_scale is 1.0 and the copy has no alpha channel, this degenerates into copy_sub_image().

boxFilter void PNMImage::box_filter(double radius = (1)); The bodies for the non-inline *_filter() functions can be found in the file pnm-image-filter.cxx. Description: This flavor of box_filter() will apply the filter over the entire image without resizing or copying; the effect is that of a blur operation.

boxFilterFrom void PNMImage::box_filter_from(double radius, PNMImage const &copy); Description: Makes a resized copy of the indicated image into this one using the indicated filter. The image to be copied is squashed and stretched to match the dimensions of the current image, applying the appropriate filter to perform the stretching.

clampVal unsigned short int PNMImage::clamp_val(int input_value) const; Description: A handy function to clamp values to [0..get_maxval()].

clear void PNMImage::clear(void); Description: Frees all memory allocated for the image, and clears all its parameters (size, color, type, etc). Description: This flavor of clear() reinitializes the image to an empty (black) image with the given dimensions.

clearReadSize void PNMImage::clear_read_size(void); Description: Undoes the effect of a previous call to set_read_size().

copyFrom void PNMImage::copy_from(PNMImage const &copy); Description: Makes this image become a copy of the other image.

copyHeaderFrom void PNMImage::copy_header_from(PNMImageHeader const &header); Description: Copies just the header information into this image. This will blow away any image data stored in the image. The new image data will be allocated, but left unitialized.

copySubImage void PNMImage::copy_sub_image(PNMImage const &copy, int xto, int yto, int xfrom = (0), int yfrom = (0), int x_size = (-1), int y_size = (-1)); Description: Copies a rectangular area of another image into a rectangular area of this image. Both images must already have been initialized. The upper-left corner of the region in both images is specified, and the size of the area; if the size is omitted, it defaults to the entire other image, or the largest piece that will fit.

darkenSubImage void PNMImage::darken_sub_image(PNMImage const &copy, int xto, int yto, int xfrom = (0), int yfrom = (0), int x_size = (-1), int y_size = (-1), double pixel_scale = (1)); Description: Behaves like copy_sub_image(), but the resulting color will be the darker of the source and destination colors at each pixel (and at each R, G, B, A component value). If pixel_scale is not 1.0, it specifies an amount to scale each pixel value of the source image before applying it to the target image. The scale is applied with the center at 1.0: scaling the pixel value smaller brings it closer to 1.0.

expandBorder void PNMImage::expand_border(int left, int right, int bottom, int top, LVecBase4d const &color); Description: Expands the image by the indicated number of pixels on each edge. The new pixels are set to the indicated color. If any of the values is negative, this actually crops the image.

fill void PNMImage::fill(double red, double green, double blue); Description: Sets the entire image (except the alpha channel) to the given color. Description: Sets the entire image (except the alpha channel) to the given grayscale level.

fillVal void PNMImage::fill_val(unsigned short int red, unsigned short int green, unsigned short int blue); Description: Sets the entire image (except the alpha channel) to the given grayscale level. Description: Sets the entire image (except the alpha channel) to the given color.

fromVal double PNMImage::from_val(unsigned short int input_value) const; Description: A handy function to scale values from [0..get_maxval()] to [0..1].

gaussianFilter void PNMImage::gaussian_filter(double radius = (1)); Description: This flavor of gaussian_filter() will apply the filter over the entire image without resizing or copying; the effect is that of a blur operation.

gaussianFilterFrom void PNMImage::gaussian_filter_from(double radius, PNMImage const &copy); Description: Makes a resized copy of the indicated image into this one using the indicated filter. The image to be copied is squashed and stretched to match the dimensions of the current image, applying the appropriate filter to perform the stretching.

getAlpha double PNMImage::get_alpha(int x, int y) const; Description: Returns the alpha component color at the indicated pixel. It is an error to call this unless has_alpha() is true. The value returned is a double in the range 0..1.

getAlphaVal unsigned short int PNMImage::get_alpha_val(int x, int y) const; Description: Returns the alpha component color at the indicated pixel. It is an error to call this unless has_alpha() is true. The value returned is in the range 0..maxval.

getBlue double PNMImage::get_blue(int x, int y) const; Description: Returns the blue component color at the indicated pixel. The value returned is a double in the range 0..1.

getBlueVal unsigned short int PNMImage::get_blue_val(int x, int y) const; Description: Returns the blue component color at the indicated pixel. The value returned is in the range 0..maxval.

getBright double PNMImage::get_bright(int x, int y) const; Description: Returns the linear brightness of the given xel, as a double in the range 0..1. This flavor of get_bright() returns the correct grayscale brightness level for both full-color and grayscale images. Description: This flavor of get_bright() works correctly only for color images. It returns a single brightness value for the RGB color at the indicated pixel, based on the supplied weights for each component. Description: This flavor of get_bright() works correctly only for four-channel images. It returns a single brightness value for the RGBA color at the indicated pixel, based on the supplied weights for each component.

getChannel double PNMImage::get_channel(int x, int y, int channel) const; Description: Returns the nth component color at the indicated pixel. The channel index should be in the range 0..(get_num_channels()-1). The channels are ordered B, G, R, A. This is slightly less optimal than accessing the component values directly by named methods. The value returned is a double in the range 0..1.

getChannelVal unsigned short int PNMImage::get_channel_val(int x, int y, int channel) const; Description: Returns the nth component color at the indicated pixel. The channel index should be in the range 0..(get_num_channels()-1). The channels are ordered B, G, R, A. This is slightly less optimal than accessing the component values directly by named methods. The value returned is in the range 0..maxval.

getGray double PNMImage::get_gray(int x, int y) const; Description: Returns the gray component color at the indicated pixel. This only has a meaningful value for grayscale images; for other image types, this returns the value of the blue channel only. However, also see the get_bright() function. The value returned is a double in the range 0..1.

getGrayVal unsigned short int PNMImage::get_gray_val(int x, int y) const; Description: Returns the gray component color at the indicated pixel. This only has a meaningful value for grayscale images; for other image types, this returns the value of the blue channel only. However, also see the get_bright() function. The value returned is in the range 0..maxval.

getGreen double PNMImage::get_green(int x, int y) const; Description: Returns the green component color at the indicated pixel. The value returned is a double in the range 0..1.

getGreenVal unsigned short int PNMImage::get_green_val(int x, int y) const; Description: Returns the green component color at the indicated pixel. The value returned is in the range 0..maxval.

getReadXSize int PNMImage::get_read_x_size(void) const; Description: Returns the requested x_size of the image if set_read_size() has been called, or the image x_size otherwise (if it is known).

getReadYSize int PNMImage::get_read_y_size(void) const; Description: Returns the requested y_size of the image if set_read_size() has been called, or the image y_size otherwise (if it is known).

getRed double PNMImage::get_red(int x, int y) const; Description: Returns the red component color at the indicated pixel. The value returned is a double in the range 0..1.

getRedVal unsigned short int PNMImage::get_red_val(int x, int y) const; Description: Returns the red component color at the indicated pixel. The value returned is in the range 0..maxval.

getXel LVecBase3d PNMImage::get_xel(int x, int y) const; The corresponding get_xel(), set_xel(), get_red(), etc. functions automatically scale their values by get_maxval() into the range [0..1]. Description: Returns the RGB color at the indicated pixel. Each component is a double in the range 0..1.

getXelA LVecBase4d PNMImage::get_xel_a(int x, int y) const; Description: Returns the RGBA color at the indicated pixel. Each component is a double in the range 0..1.

getXelVal pixel const &PNMImage::get_xel_val(int x, int y) const; The *_val() functions return or set the color values in the range [0..get_maxval()]. This range may be different for different images! Use the corresponding functions (without _val()) to work in the normalized range [0..1]. Description: Returns the RGB color at the indicated pixel. Each component is in the range 0..maxval.

hasReadSize bool PNMImage::has_read_size(void) const; Description: Returns true if set_read_size() has been called.

isValid bool PNMImage::is_valid(void) const; Description: Returns true if the image has been read in or correctly initialized with a height and width. If this returns false, virtually all member functions except clear() and read() are invalid function calls.

lightenSubImage void PNMImage::lighten_sub_image(PNMImage const &copy, int xto, int yto, int xfrom = (0), int yfrom = (0), int x_size = (-1), int y_size = (-1), double pixel_scale = (1)); Description: Behaves like copy_sub_image(), but the resulting color will be the lighter of the source and destination colors at each pixel (and at each R, G, B, A component value). If pixel_scale is not 1.0, it specifies an amount to scale each pixel value of the source image before applying it to the target image.

makeGrayscale void PNMImage::make_grayscale(void); Description: Converts the image from RGB to grayscale. Any alpha channel, if present, is left undisturbed. Description: Converts the image from RGB to grayscale. Any alpha channel, if present, is left undisturbed. The optional rc, gc, bc values represent the relative weights to apply to each channel to convert it to grayscale.

makeRgb void PNMImage::make_rgb(void); Description: Converts the image from grayscale to RGB. Any alpha channel, if present, is left undisturbed.

operator = void PNMImage::operator =(PNMImage const &copy); Description:

operator [] pixel *PNMImage::operator [](int y); If you're used to the NetPBM library and like working with a 2-d array of xels, and using the PNM macros to access their components, you may treat the PNMImage as such directly. Description: Allows the PNMImage to appear to be a 2-d array of xels.

quickFilterFrom void PNMImage::quick_filter_from(PNMImage const &copy, int xborder = (0), int yborder = (0)); Description: Resizes from the given image, with a fixed radius of 0.5. This is a very specialized and simple algorithm that doesn't handle dropping below the Nyquist rate very well, but is quite a bit faster than the more general box_filter(), above. If borders are specified, they will further restrict the size of the resulting image. There's no point in using quick_box_filter() on a single image.

read bool PNMImage::read(Filename const &filename, PNMFileType *type = ((void *)(0)), bool report_unknown_type = (1)); Description: Reads the indicated image filename. If type is non-NULL, it is a suggestion for the type of file it is. Returns true if successful, false on error. Description: Reads the image data from the indicated stream. The filename is advisory only, and may be used to suggest a type if it has a known extension. If type is non-NULL, it is a suggestion for the type of file it is (and a non-NULL type will override any magic number test or filename extension lookup). Returns true if successful, false on error. Description: This flavor of read() uses an already-existing PNMReader to read the image file. You can get a reader via the PNMImageHeader::make_reader() methods. This is a good way to examine the header of a file (for instance, to determine its size) before actually reading the entire image. The PNMReader is always deleted upon completion, whether succesful or not.

remixChannels void PNMImage::remix_channels(LMatrix4f const &conv); Description: Transforms every pixel using the operation (Ro,Go,Bo) = conv.xform_point(Ri,Gi,Bi); Input must be a color image.

removeAlpha void PNMImage::remove_alpha(void); Description: Removes the image's alpha channel, if it exists.

renderSpot void PNMImage::render_spot(LVecBase4d const &fg, LVecBase4d const &bg, double min_radius, double max_radius); Description: Renders a solid-color circle, with a fuzzy edge, into the center of the PNMImage. If the PNMImage is non-square, this actually renders an ellipse. The min_radius and max_radius are in the scale 0..1, where 1.0 means the full width of the image. If min_radius == max_radius, the edge is sharp (but still antialiased); otherwise, the pixels between min_radius and max_radius are smoothly blended between fg and bg colors.

setAlpha void PNMImage::set_alpha(int x, int y, double a); Description: Sets the alpha component color only at the indicated pixel. It is an error to call this unless has_alpha() is true. The value given should be in the range 0..1.

setAlphaVal void PNMImage::set_alpha_val(int x, int y, unsigned short int a); Description: Sets the alpha component color only at the indicated pixel. It is an error to call this unless has_alpha() is true. The value given should be in the range 0..maxval.

setBlue void PNMImage::set_blue(int x, int y, double b); Description: Sets the blue component color only at the indicated pixel. The value given should be a double in the range 0..1.

setBlueVal void PNMImage::set_blue_val(int x, int y, unsigned short int b); Description: Sets the blue component color only at the indicated pixel. The value given should be in the range 0..maxval.

setChannel void PNMImage::set_channel(int x, int y, int channel, double value); Description: Sets the nth component color at the indicated pixel. The channel index should be in the range 0..(get_num_channels()-1). The channels are ordered B, G, R, A. This is slightly less optimal than setting the component values directly by named methods. The value given should be a double in the range 0..1.

setChannelVal void PNMImage::set_channel_val(int x, int y, int channel, unsigned short int value); Description: Sets the nth component color at the indicated pixel. The channel index should be in the range 0..(get_num_channels()-1). The channels are ordered B, G, R, A. This is slightly less optimal than setting the component values directly by named methods. The value given should be in the range 0..maxval.

setColorType void PNMImage::set_color_type(PNMImageHeader::ColorType color_type); Description: Translates the image to or from grayscale, color, or four-color mode. Grayscale images are converted to full-color images with R, G, B set to the original gray level; color images are converted to grayscale according to the value of Bright(). The alpha channel, if added, is initialized to zero.

setGray void PNMImage::set_gray(int x, int y, double gray); Description: Sets the gray component color at the indicated pixel. This is only meaningful for grayscale images; for other image types, this simply sets the blue component color. However, also see set_xel(), which can set all the component colors to the same grayscale level, and hence works correctly both for grayscale and color images. The value given should be a double in the range 0..1.

setGrayVal void PNMImage::set_gray_val(int x, int y, unsigned short int gray); Description: Sets the gray component color at the indicated pixel. This is only meaningful for grayscale images; for other image types, this simply sets the blue component color. However, also see set_xel_val(), which can set all the component colors to the same grayscale level, and hence works correctly both for grayscale and color images. The value given should be in the range 0..maxval.

setGreen void PNMImage::set_green(int x, int y, double g); Description: Sets the green component color only at the indicated pixel. The value given should be a double in the range 0..1.

setGreenVal void PNMImage::set_green_val(int x, int y, unsigned short int g); Description: Sets the green component color only at the indicated pixel. The value given should be in the range 0..maxval.

setMaxval void PNMImage::set_maxval(unsigned short int maxval); Description: Rescales the image to the indicated maxval.

setNumChannels void PNMImage::set_num_channels(int num_channels); Description: Changes the number of channels associated with the image. The new number of channels must be an integer in the range 1 through 4, inclusive. This will allocate and/or deallocate memory as necessary to accomodate; see set_color_type().

setReadSize void PNMImage::set_read_size(int x_size, int y_size); Description: Specifies the size to we'd like to scale the image upon reading it. This will affect the next call to read(). This is usually used to reduce the image size, e.g. for a thumbnail. If the file type reader supports it (e.g. JPEG), then this will scale the image during the read operation, consequently reducing memory and CPU utilization. If the file type reader does not support it, this will load the image normally, and them perform a linear scale after it has been loaded.

setRed void PNMImage::set_red(int x, int y, double r); Description: Sets the red component color only at the indicated pixel. The value given should be a double in the range 0..1.

setRedVal void PNMImage::set_red_val(int x, int y, unsigned short int r); Description: Sets the red component color only at the indicated pixel. The value given should be in the range 0..maxval.

setXel void PNMImage::set_xel(int x, int y, LVecBase3d const &value); Description: Changes the RGB color at the indicated pixel. Each component is a double in the range 0..1. Description: Changes all three color components at the indicated pixel to the same value. The value is a double in the range 0..1.

setXelA void PNMImage::set_xel_a(int x, int y, LVecBase4d const &value); Description: Changes the RGBA color at the indicated pixel. Each component is a double in the range 0..1.

setXelVal void PNMImage::set_xel_val(int x, int y, pixel const &value); Description: Changes the RGB color at the indicated pixel. Each component is in the range 0..maxval. Description: Changes all three color components at the indicated pixel to the same value. The value is in the range 0..maxval.

takeFrom void PNMImage::take_from(PNMImage &orig); Description: Move the contents of the other image into this one, and empty the other image.

toVal unsigned short int PNMImage::to_val(double input_value) const; Description: A handy function to scale values from [0..1] to [0..get_maxval()].

write bool PNMImage::write(Filename const &filename, PNMFileType *type = ((void *)(0))) const; Description: Writes the image to the indicated filename. If type is non-NULL, it is a suggestion for the type of image file to write. Description: Writes the image to the indicated ostream. The filename is advisory only, and may be used suggest a type if it has a known extension. If type is non-NULL, it is a suggestion for the type of image file to write. Description: This flavor of write() uses an already-existing PNMWriter to write the image file. You can get a writer via the PNMImageHeader::make_writer() methods. The PNMWriter is always deleted upon completion, whether succesful or not.

getColorType PNMImageHeader::ColorType PNMImageHeader::get_color_type(void) const; Description: Returns the image type of the image, as an enumerated value. This is really just the number of channels cast to the enumerated type.

getComment string PNMImageHeader::get_comment(void) const; Description: Gets the user comment from the file.

getMaxval unsigned short int PNMImageHeader::get_maxval(void) const; Description: Returns the maximum channel value allowable for any pixel in this image; for instance, 255 for a typical 8-bit-per-channel image. A pixel with this value is full on.

getNumChannels int PNMImageHeader::get_num_channels(void) const; Description: Returns the number of channels in the image.

getType PNMFileType *PNMImageHeader::get_type(void) const; Description: If the file type is known (e.g. has_type() returns true), returns its PNMFileType pointer; otherwise, returns NULL.

getXSize int PNMImageHeader::get_x_size(void) const; Description: Returns the number of pixels in the X direction. This is one more than the largest allowable X coordinate.

getYSize int PNMImageHeader::get_y_size(void) const; Description: Returns the number of pixels in the Y direction. This is one more than the largest allowable Y coordinate.

hasAlpha static bool PNMImageHeader::has_alpha(PNMImageHeader::ColorType color_type); Description: This static variant of has_alpha() returns true if the indicated image type includes an alpha channel, false otherwise. Description: Returns true if the image includes an alpha channel, false otherwise. Unlike is_grayscale(), if this returns false it is an error to call any of the functions accessing the alpha channel.

hasType bool PNMImageHeader::has_type(void) const; Description: Returns true if the PNMImageHeader knows what type it is, false otherwise.

isGrayscale static bool PNMImageHeader::is_grayscale(PNMImageHeader::ColorType color_type); Description: This static variant of is_grayscale() returns true if the indicated image type represents a grayscale image, false otherwise. Description: Returns false if the image is a full-color image, and has red, green, and blue components; true if it is a grayscale image and has only a gray component. (The gray color is actually stored in the blue channel, and the red and green channels are ignored.)

makeReader PNMReader *PNMImageHeader::make_reader(Filename const &filename, PNMFileType *type = ((void *)(0)), bool report_unknown_type = (1)) const; Description: Returns a newly-allocated PNMReader of the suitable type for reading from the indicated image filename, or NULL if the filename cannot be read for some reason. The filename "-" always stands for standard input. If type is specified, it is a suggestion for the file type to use. The PNMReader should be deleted when it is no longer needed. Description: Returns a newly-allocated PNMReader of the suitable type for reading from the already-opened image file, or NULL if the file cannot be read for some reason. owns_file should be set true if the PNMReader is to be considered the owner of the stream pointer (in which case the stream will be deleted on completion, whether successful or not), or false if it should not delete it. The filename parameter is optional here, since the file has already been opened; it is only used to examine the extension and attempt to guess the file type. If magic_number is nonempty, it is assumed to represent the first few bytes that have already been read from the file. Some file types may have difficulty if this is more than two bytes. If type is non-NULL, it is a suggestion for the file type to use.

makeWriter PNMWriter *PNMImageHeader::make_writer(Filename const &filename, PNMFileType *type = ((void *)(0))) const; Description: Returns a newly-allocated PNMWriter of the suitable type for writing an image to the indicated filename, or NULL if the filename cannot be written for some reason. The filename "-" always stands for standard output. If type is specified, it is a suggestion for the file type to use. The PNMWriter should be deleted when it is no longer needed. Description: Returns a newly-allocated PNMWriter of the suitable type for writing to the already-opened image file, or NULL if the file cannot be written for some reason. owns_file should be set true if the PNMWriter is to be considered the owner of the stream pointer (in which case the stream will be deleted on completion, whether successful or not), or false if it should not delete it. The filename parameter is optional here, since the file has already been opened; it is only used to examine the extension and attempt to guess the intended file type. If type is non-NULL, it is a suggestion for the file type to use.

operator = void PNMImageHeader::operator =(PNMImageHeader const &copy); Description:

output void PNMImageHeader::output(ostream &out) const; Description:

readHeader bool PNMImageHeader::read_header(Filename const &filename, PNMFileType *type = ((void *)(0)), bool report_unknown_type = (1)); Description: Opens up the image file and tries to read its header information to determine its size, number of channels, etc. If successful, updates the header information and returns true; otherwise, returns false. Description: Reads the image header information only from the indicated stream. The filename is advisory only, and may be used to suggest a type if it has a known extension. If type is non-NULL, it is a suggestion for the type of file it is (and a non-NULL type will override any magic number test or filename extension lookup). Returns true if successful, false on error.

readMagicNumber static bool PNMImageHeader::read_magic_number(istream *file, string &magic_number, int num_bytes); Description: Ensures that the first n bytes of the file are read into magic_number. If magic_number is initially nonempty, assumes these represent the first few bytes already extracted. Returns true if successful, false if an end of file or error occurred before num_bytes could be read.

setComment void PNMImageHeader::set_comment(string const &comment); Description: Writes a user comment string to the image (header).

setType void PNMImageHeader::set_type(PNMFileType *type); Description: Sets the file type of this PNMImage. This will be the default type used when an image is read, if the type cannot be determined by magic number or inferred by extension, or the type used when the image is written, if the type cannot be inferred from the filename extension.