rgb3toppm
Convert RGB image files to PPM format
TLDR
Combine three PGM images (representing red, green and blue color components) into one PPM image
SYNOPSIS
rgb3toppm [-width width] [-height height] [rgbfile]
PARAMETERS
-width width
Specifies the width of the image in pixels. If not specified, and height is, it calculates the image's width assuming a square image. If neither are given, it assumes a square image.
-height height
Specifies the height of the image in pixels. If not specified, and width is, it calculates the image's height assuming a square image. If neither are given, it assumes a square image.
rgbfile
The input file containing raw RGB data. If not specified, input is read from standard input.
DESCRIPTION
rgb3toppm converts raw RGB (red, green, blue) image data to a portable pixmap (PPM) image format. It reads a stream of bytes, interpreting them as pixel data, and outputs a valid PPM file to standard output. This utility is particularly useful when dealing with image data that doesn't conform to standard image formats but is available as raw RGB pixel values. The format of the RGB input is crucial: it expects each pixel to be represented by three bytes, corresponding to red, green, and blue intensities. It is possible to specify size of an image or assume it is a square image. The output PPM image is in P6 (binary) format. rgb3toppm is a relatively simple tool intended for basic image format conversion from raw data to PPM.
CAVEATS
The input data must be pure RGB data without any header information or padding. It assumes the data is organized in row-major order (i.e., pixels are arranged sequentially from left to right and top to bottom). If the input data does not conform to this format, the resulting PPM image will be incorrect.
Error handling is basic; if the provided dimensions do not match the amount of data available in the input, the conversion may produce unexpected results or errors.
EXAMPLES
1. Convert an RGB file named raw_image.rgb to a PPM image, assuming a width of 256 and a height of 256:
rgb3toppm -width 256 -height 256 raw_image.rgb > image.ppm
2. Convert standard input to a PPM image, assuming a square image of size x, automatically calculated:
cat raw_image.rgb | rgb3toppm > image.ppm
SEE ALSO
ppmtoxxx(5), ppm(5)