Developer(s) | Jef Poskanzer, Bryan Henderson, Akira F Urushibata [1] |
---|---|
Initial release | 1988 |
Stable release | |
Repository | |
Written in | C, Perl, Unix Shell |
Operating system | Cross-platform |
License | Various, see below |
Website | netpbm |
Netpbm (formerly Pbmplus) is an open-source package of graphics programs and a programming library. It is used mainly in the Unix world, where one can find it included in all major open-source operating system distributions, but also works on Microsoft Windows, macOS, and other operating systems. [3]
Filename extension | .pbm, .pgm, .ppm, .pnm |
---|---|
Internet media type | |
Uniform Type Identifier (UTI) | public.pbm |
Developed by | Jef Poskanzer |
Type of format | Image file format |
Extended to | Portable Arbitrary Map (PAM) |
Open format? | yes |
Several graphics formats are used and defined by the Netpbm project:
are image file formats designed to be easily exchanged between platforms. They are also sometimes referred to collectively as the portable anymap format (PNM), [7] [8] not to be confused with the related portable arbitrary map format (PAM). The "magic number" (Px) at the beginning of a file determines the type, not the file extension, although it is best practice to use the correct extension if possible.
The PBM format was invented by Jef Poskanzer in the 1980s as a format that allowed monochrome bitmaps to be transmitted within an email message as plain ASCII text, allowing it to survive any changes in text formatting. [8] Poskanzer developed the first library of tools to handle the PBM format, Pbmplus, released in 1988. It mainly contained tools to convert between PBM and other graphics formats. By the end of 1988, Poskanzer had developed the PGM and PPM formats along with their associated tools and added them to Pbmplus. The final release of Pbmplus was December 10, 1991.
In 1993, the Netpbm library was developed to replace the unmaintained Pbmplus. It was simply a repackaging of Pbmplus with additions and fixes submitted by people all over the world. [1]
Each file starts with a two-byte magic number (in ASCII) that identifies the type of file it is (PBM, PGM, and PPM) and its encoding (ASCII/"plain" or binary/"raw"). The magic number is a capital P followed by a single-digit number.
Type | Magic number | Extension | Colors | |
---|---|---|---|---|
ASCII (plain) | Binary (raw) | |||
Portable BitMap | P1 | P4 | .pbm | 2, the values 0 and 1 (white & black) |
Portable GrayMap | P2 | P5 | .pgm | maximum 65535 gray levels, typically in the range 0-255 or 0-65535, black-to-white range |
Portable PixMap | P3 | P6 | .ppm | maximum 65535 color levels for each RGB channel, typically in the range 0-255 or 0-65535 |
A value of P7
refers to the PAM file format that is covered as well by the netpbm library. [9]
The ASCII ("plain") formats allow for human readability and easy transfer to other platforms; the binary ("raw") formats are easier to parse by programs and more efficient in file size.
In the binary formats, PBM uses 1 bit per pixel, PGM uses 8 or 16 bits per pixel, and PPM uses 24 or 48 bits per pixel: 8/16 for red, 8/16 for green, 8/16 for blue. Application support for the 16 bit variants is still rare.
PGM and PPM documentation defines that gray and color values use the BT.709 color space and gamma transfer function. However, depending on the application, the used color space may be sRGB, linear or some other color space. There is no metadata in the file to indicate which color space is being used.
A simple example of the PBM format is as follows. (Not shown are the newline character(s) at the end of each line.):
P1 # This is an example bitmap of the letter "J" 6 10 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 1 0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
The string P1 identifies the file format. The number sign introduces a comment. The next two numbers give the width and the height. Then follows the matrix with the pixel values (in the monochrome case here, only zeros and ones).
It is not required that pixels are nicely lined up, the format ignores whitespaces and linefeeds in the data section, although it's recommended that no line is longer than 76 characters. The following displays the same image:
P1 # This is an example bitmap of the letter "J" 6 10 000010000010000010000010000010000010100010011100000000000000
Here is the resulting image:
Here it is again magnified 20 times:
A value of 0 signifies a white pixel, and a 1 signifies a black pixel. This differs from the other formats, where higher values signify brighter pixels.
The P4 binary format of the same image represents each pixel with a single bit. A row is width pixels wide packed to the length of 8 pixels or a byte. The first pixel in a row is the most significant bit. The extra bits used to make the length equal to a byte are ignored. The following formula can be used to calculate the number of required bytes ⌈width / 8⌉ * height. If we use the example above a ⌈6 / 8⌉ * 10 would be 10 bytes.
P4 # This is an example binary format of the letter "J" with each byte in decimal notation 6 10 8 8 8 8 8 8 136 112 0 0
The PGM and PPM formats (both ASCII and binary versions) have an additional parameter for the maximum value (numbers of grey between black and white) after the X and Y dimensions and before the actual pixel data. Black is 0 and max value is white. (Not shown are the newline character(s) at the end of each line.)
P2 # Shows the word "FEEP" 24 7 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 3 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 15 15 15 0 0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 15 0 0 3 3 3 0 0 0 7 7 7 0 0 0 11 11 11 0 0 0 15 15 15 15 0 0 3 0 0 0 0 0 7 0 0 0 0 0 11 0 0 0 0 0 15 0 0 0 0 0 3 0 0 0 0 0 7 7 7 7 0 0 11 11 11 11 0 0 15 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
This is an example of a color RGB image stored in PPM format. (Not shown are the newline character(s) at the end of each line.)
P3 # "P3" means this is a RGB color image in ASCII # "3 2" is the width and height of the image in pixels # "255" is the maximum value for each color # This, up through the "255" line below are the header. # Everything after that is the image data: RGB triplets. # In order: red, green, blue, yellow, white, and black. 3 2 255 255 0 0 0 255 0 0 0 255 255 255 0 255 255 255 0 0 0
The P6 binary format of the same image represents each color component of each pixel with one byte (thus three bytes per pixel) in the order red, green, then blue. The file is smaller, but the color information is more difficult to read by humans. The header remains in ASCII and the arguments are still separated by a whitespace. The binary image information comes after the header (which ends with a whitespace).
In the binary format, last headerline must be like "255\n", with data immediately following it; any comment added after 255 will be taken as the start of image data, and the image will be skewed to the right (at least when opened by the image-manipulation program GIMP (December 2022)).
The PPM format is not compressed, and thus requires more space and bandwidth than a compressed format would. For example, the above 192×128 PNG (Portable Network Graphics) image has a file size of 166 bytes. When converted to a 192×128 PPM image, the file size is 73,848 bytes. Filesize reduction factor 100 or so when converting to png is typical if the image is a line drawing; if the image is a photo, it is best converted to jpeg, which yields a greater filesize reduction.
The PPM format is generally an intermediate format used for image work before converting to a more efficient format, for example the PNG format, without any loss of information in the intermediate step.
The image shown above using only 0 or the maximal value for the red-green-blue channels can be also encoded as:
P3 # The same image with width 3 and height 2, # using 0 or 1 per color (red, green, blue) 3 2 1 1 0 0 0 1 0 0 0 1 1 1 0 1 1 1 0 0 0
White space including line ends and comment lines is syntactically equivalent to a single space within the PNM headers. For the plain formats P1...P3 this also affects the pixmap lines; in fact lines should be limited to 70 characters:
P3 3 2 1 1 0 0 0 1 0 0 0 1 1 1 0 1 1 1 0 0 0
The original definition of the PGM and the PPM binary formats (the P5 and P6 formats) did not allow bit depths greater than 8 bits. While the ASCII format can accommodate greater bit depths, it increases file size and thus slows read and write operations. Accordingly, many programmers extended the format to allow higher bit depths. Using higher bit depths encounters the problem of having to decide on the endianness of the file. The various implementations did not agree on which byte order to use, and some connected the 16-bit endianness to the pixel packing order. [10] The current documentation of PGM and PPM says that the most significant byte is first and the Netpbm implementation also uses the big-endian byte order. [11]
The PFM (Portable Floatmap) is the unofficial four byte IEEE 754 single precision floating point extension. [12] [13] [14]
After the header the file proceeds with floating point numbers for each pixel, specified in left-to-right, bottom-to-top order. Some programs suggest PF4 as an additional extension for the RGBA format. [15]
PFM is supported by the programs Photoshop, [16] GIMP, and ImageMagick. It is supported by the de facto reference implementation netpbm. [12]
The Netpbm package contains over 350 programs, [17] most of which have "pbm", "pgm", "ppm", "pam", or "pnm" in their names. For example, one might use pamscale
to shrink an image by 10%, pamcomp
to overlay one image on top of another, pbmtext
to create an image of text, or reduce the number of colors in an image with pnmquant
.
The programs are designed to be minimal building blocks that can be used in various combinations to do other things. The Netpbm package can, for example, use two successive conversion programs to turn a color picture in the GIF format into a .bmp file:
giftopnm somepic.gif > somepic.ppm ppmtobmp somepic.ppm > somepic.bmp
This is more commonly done as a pipeline, to save execution time and to avoid leaving a temporary somepic.ppm file around:
giftopnm somepic.gif | ppmtobmp > somepic.bmp
The Netpbm programs are frequently used as intermediates to convert between obscure formats. For instance, there may be no tool to convert an X11 window dump (XWD format) directly to a Macintosh PICT file, but one can do this by running xwdtopnm
, then ppmtopict
. (Tools which say that they output PNM output either PBM, PGM, or PPM. Tools importing PNM will read any of the three formats.) As a more complex example, Netpbm tools can convert 48×48 XBM to Ikon and eventually X-Face. [18]
The PBM (black and white) format was invented by Jef Poskanzer in the mid-1980s. At the time, there was no standard, reliable way to send binary files in email, and attempting to send anything other than 7-bit ASCII in email often resulted in data corruption. PBM was designed to allow images to be sent via email without being corrupted. Poskanzer released the forerunner of Netpbm, called Pbmplus in 1988. By the end of 1988, Poskanzer had developed the PGM (greyscale) and PPM (color) formats and released them with Pbmplus.
The last release of Pbmplus was on December 10, 1991. Poskanzer never released any further updates, and in 1993, Netpbm was developed to replace it. At first, it was nothing more than a renamed release of Pbmplus, but updates continued to occur until 1995 when the package again became abandoned. In 1999, the Netpbm package was picked up by its present maintainer, Bryan Henderson.
In 2000, PAM was added to the file formats of the Netpbm library allowing an alpha channel. [19]
The name Netpbm came from the program developers collaborating over the Internet, which was notable at the time; the NetBSD operating system and NetHack game got their names similarly. (Unlike with the later, more widespread Portable Network Graphics (PNG) format, the "net" in the name is not actually in reference to the image itself being optimized for transfer over a network.)
Filename extension | .pam |
---|---|
Internet media type | image/x-portable-arbitrarymap [20] |
Developed by | Bryan Henderson |
Type of format | Image file format |
Extended from | Portable aNy Map (PNM) |
Open format? | yes |
Portable Arbitrary Map (PAM) is an extension of the older binary P4...P6 graphics formats, introduced with netpbm version 9.7 (August 2000). PAM generalises all features of PBM, PGM, and PPM, and provides for extensions. PAM defines two new attributes; depth and tuple type:
PAM is supported by XnView and FFmpeg. [21] [22] As specified the TUPLTYPE
is optional; however, FFmpeg requires it.
The header for the PAM file format begins with P7, and (unlike in the other formats) ends in an explicit close: "ENDHDR" followed by a whitespace. Line ends in a PAM header are significant; for PNM, line ends are whitespace.
There is no plain (human-readable, ASCII-based) version of PAM. PAM files are always binary, and attempts to use the switch -plain
with Netpbm programs that produce PAM output results in an error message.
For the black-and-white version of PAM (depth 1, tuple type BLACKANDWHITE), corresponding to PBM, PAM uses one byte per pixel, instead of PBM's use of one bit per pixel (packing eight pixels in one byte). Also, the value 1 in such a PAM image stands for white ("light on"), as opposed to black in PBM ("ink on").
TUPLTYPE | MAXVAL | DEPTH | comment |
---|---|---|---|
BLACKANDWHITE | 1 | 1 | special case of GRAYSCALE |
GRAYSCALE | 2...65535 | 1 | 2 bytes per pixel for MAXVAL > 255 |
RGB | 1...65535 | 3 | 6 bytes per pixel for MAXVAL > 255 |
BLACKANDWHITE_ALPHA | 1 | 2 | 2 bytes per pixel |
GRAYSCALE_ALPHA | 2...65535 | 2 | 4 bytes per pixel for MAXVAL > 255 |
RGB_ALPHA | 1...65535 | 4 | 8 bytes per pixel for MAXVAL > 255 |
All of the basic tuple types (BLACKANDWHITE, GRAYSCALE, and RGB) have a variant with an opacity channel. The tuple type is created by appending "_ALPHA" as a suffix to the base tuple type.
For example, an image with a tuple type of GRAYSCALE is equivalent to PGM (portable graymap). GRAYSCALE_ALPHA with transparency is not directly possible in PGM. The specification permits MAXVAL 1 for GRAYSCALE, but it would have the same effect as BLACKANDWHITE.
An example in the BMP article shows an RGBA image with 4×2=8 blue, green, red, and white pixels; half transparent (0x7F) in the first lower row, opaque (0xFF) in the second upper row; hex. FF00007F 00FF007F 0000FF7F FFFFFF7F FF0000FF 00FF00FF 0000FFFF FFFFFFFF
in BGRA order. For PAM, this bitmap has to be given in RGBA order, swapping the 1st and 3rd byte in each pixel. BMP rows are typically arranged bottom-up, for PAM and PNM rows are given top-down (i.e. for this example 0000FFFF 00FF00FF FF0000FF FFFFFFFF 0000FF7F 00FF007F FF00007F FFFFFF7F
). The PAM header for this example could be:
P7 WIDTH 4 HEIGHT 2 DEPTH 4 MAXVAL 255 TUPLTYPE RGB_ALPHA ENDHDR
PAM's tuple-type mechanism allows for many extensions. In theory, PAM can be extended to represent color models such as CMYK.
The format is not even limited to graphics, its definition allows it to be used for arbitrary three-dimensional matrices of unsigned integers. Some programs of the Netpbm package, for example pamsummcol, function as crude matrix arithmetic processors and use the PAM format this way.
Netpbm consists of hundreds of different tools, each offered with a public copyright license of its own. An analysis by Debian developer Steve McIntyre from 2001 suggests mostly free software licenses, one non-commercial license (non-free) and a dozen without any license offered (thus also non-free). As mentioned in the analysis, it obviously doesn't cover changes since. [23]
The Graphics Interchange Format is a bitmap image format that was developed by a team at the online services provider CompuServe led by American computer scientist Steve Wilhite and released on June 15, 1987.
Portable Network Graphics is a raster-graphics file format that supports lossless data compression. PNG was developed as an improved, non-patented replacement for Graphics Interchange Format (GIF)—unofficially, the initials PNG stood for the recursive acronym "PNG's not GIF".
PCX, standing for PiCture eXchange, is an image file format developed by the now-defunct ZSoft Corporation of Marietta, Georgia, United States. It was the native file format for PC Paintbrush and became one of the first widely accepted DOS imaging standards, although it has since been succeeded by more sophisticated image formats, such as BMP, JPEG, and PNG. PCX files commonly store palette-indexed images ranging from 2 or 4 colors to 16 and 256 colors, although the format has been extended to record true-color (24-bit) images as well.
The JPEG File Interchange Format (JFIF) is an image file format standard published as ITU-T Recommendation T.871 and ISO/IEC 10918-5. It defines supplementary specifications for the container format that contains the image data encoded with the JPEG algorithm. The base specifications for a JPEG container format are defined in Annex B of the JPEG standard, known as JPEG Interchange Format (JIF). JFIF builds over JIF to solve some of JIF's limitations, including unnecessary complexity, component sample registration, resolution, aspect ratio, and color space. Because JFIF is not the original JPG standard, one might expect another MIME type. However, it is still registered as "image/jpeg".
The BMP file format, or bitmap, is a raster graphics image file format used to store bitmap digital images, independently of the display device, especially on Microsoft Windows and OS/2 operating systems.
RGBA stands for red green blue alpha. While it is sometimes described as a color space, it is actually a three-channel RGB color model supplemented with a fourth alpha channel. Alpha indicates how opaque each pixel is and allows an image to be combined over others using alpha compositing, with transparent areas and anti-aliasing of the edges of opaque regions. Each pixel is a 4D vector.
Interleaved Bitmap (ILBM) is an image file format conforming to the Interchange File Format (IFF) standard. The format originated on the Amiga platform, and on IBM-compatible systems, files in this format or the related PBM format are typically encountered in games from late 1980s and early 1990s that were either Amiga ports or had their graphical assets designed on Amiga machines.
Truevision TGA, often referred to as TARGA, is a raster graphics file format created by Truevision Inc.. It was the native format of TARGA and VISTA boards, which were the first graphic cards for IBM-compatible PCs to support high color or true color display. This family of graphic cards was intended for professional computer image synthesis and video editing with PCs; for this reason, usual resolutions of TGA image files match those of the NTSC and PAL video formats.
X PixMap (XPM) is an image file format used by the X Window System, created in 1989 by Daniel Dardailler and Colas Nahaboo working at Bull Research Center at Sophia Antipolis, France, and later enhanced by Arnaud Le Hors.
In computer graphics, the X Window System used X BitMap (XBM), a plain text binary image format, for storing cursor and icon bitmaps used in the X GUI. The XBM format is superseded by XPM, which first appeared for X11 in 1989.
STL is a file format native to the stereolithography CAD software created by 3D Systems. Chuck Hull, the inventor of stereolithography and 3D Systems’ founder, reports that the file extension is an abbreviation for stereolithography, although it is also referred to as standard triangle language or standard tessellation language.
An image file format is a file format for a digital image. There are many formats that can be used, such as JPEG, PNG, and GIF. Most formats up until 2022 were for storing 2D images, not 3D ones. The data stored in an image file format may be compressed or uncompressed. If the data is compressed, it may be done so using lossy compression or lossless compression. For graphic design applications, vector formats are often used. Some image file formats support transparency.
In computing, indexed color is a technique to manage digital images' colors in a limited fashion, in order to save computer memory and file storage, while speeding up display refresh and file transfers. It is a form of vector quantization compression.
The Apple Icon Image format (.icns) is an icon format used in Apple Inc.'s macOS. It supports icons of 16 × 16, 32 × 32, 48 × 48, 128 × 128, 256 × 256, 512 × 512 points at 1x and 2x scale, with both 1- and 8-bit alpha channels and multiple image states. The fixed-size icons can be scaled by the operating system and displayed at any intermediate size.
GOCR is a free optical character recognition program, initially written by Jörg Schulenburg. It can be used to convert or scan image files into text files.
Silicon Graphics Image (SGI) or the RGB file format is the native raster graphics file format for Silicon Graphics workstations. The format was invented by Paul Haeberli. It can be run-length encoded (RLE). FFmpeg and ImageMagick, among others, support this format.
RGBE or Radiance HDR is an image format invented by Gregory Ward Larson for the Radiance rendering system. It stores pixels as one byte each for RGB values with a one byte shared exponent. Thus it stores four bytes per pixel.
Sixel, short for "six pixels", is a bitmap graphics format supported by terminals and printers from DEC. It consists of a pattern six pixels high and one wide, resulting in 64 possible patterns. Each possible pattern is assigned an ASCII character, making the sixels easy to transmit on 7-bit serial links.
In computing, a bitmap graphic is an image formed from rows of different colored pixels. A GIF is an example of a graphics image file that uses a bitmap.
The Quite OK Image Format (QOI) is a specification for lossless image compression of 24-bit or 32-bit color raster (bitmapped) images, invented by Dominic Szablewski and first announced on 24 November 2021.
PAM format added