HOME

TheInfoList



OR:

Netpbm (formerly Pbmplus) is an open-source package of graphics programs and a programming library. It is used mainly in the
Unix Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and ot ...
world, where one can find it included in all major open-source
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs. Time-sharing operating systems schedule tasks for efficient use of the system and may also in ...
distributions, but also works on
Microsoft Windows Windows is a group of several proprietary graphical operating system families developed and marketed by Microsoft. Each family caters to a certain sector of the computing industry. For example, Windows NT for consumers, Windows Server for serv ...
,
macOS macOS (; previously OS X and originally Mac OS X) is a Unix operating system developed and marketed by Apple Inc. since 2001. It is the primary operating system for Apple's Mac computers. Within the market of desktop and lapt ...
, and other operating systems.


File formats

Several graphics formats are used and defined by the Netpbm project. The portable pixmap format (PPM), the portable graymap format (PGM) and the portable bitmap format (PBM) are
image file formats 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 ...
designed to be easily exchanged between platforms. They are also sometimes referred to collectively as the portable anymap format (PNM), 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 right extension if possible. The PBM format was invented by
Jef Poskanzer Jeffrey A. Poskanzer is a computer programmer. He was the first person to post a weekly FAQ to Usenet. He developed the portable pixmap file format and pbmplus (the precursor to the Netpbm package) to manipulate it. He has also worked on the te ...
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. 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.


Description

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 ASCII ( ), abbreviated from American Standard Code for Information Interchange, is a character encoding standard for electronic communication. ASCII codes represent text in computers, telecommunications equipment, and other devices. Because of ...
/"plain" or binary/"raw"). The magic number is a capital P followed by a single-digit number. A value of P7 refers to the PAM file format that is covered as well by the netpbm library. The ASCII ("plain") formats allow for human readability and easy transfer to other platforms; the binary ("raw") formats are more efficient in file size but may have native byte-order issues. In the binary formats, PBM uses 1 bit per pixel, PGM uses 8 or 16 bits per pixel, and PPM uses 24 bits per pixel: 8 for red, 8 for green, 8 for blue. Some readers and writers may support 48 bits per pixel (16 each for R,G,B), but this is still rare. Conventionally PGM stores values in linear
color space A color space is a specific organization of colors. In combination with color profiling supported by various physical devices, it supports reproducible representations of colorwhether such representation entails an analog or a digital represent ...
, but depending on the application, it can often use either sRGB or a simplified
gamma Gamma (uppercase , lowercase ; ''gámma'') is the third letter of the Greek alphabet. In the system of Greek numerals it has a value of 3. In Ancient Greek, the letter gamma represented a voiced velar stop . In Modern Greek, this letter re ...
representation. The file data doesn't store information which color space it is using, and must be chosen by the user or other software. 16-bit PGM almost always is stored as linear, as gamma correction is usually advantageous only in 8-bit formats. Usually, 8-bit PPM format stores colors in a nonlinear format, conventionally CIE Rec. 709 for red, green, and blue, adjusted by the CIE Rec. 709 gamma transfer function. However it is very common to store color using sRGB color space, or sometimes using linear
color space A color space is a specific organization of colors. In combination with color profiling supported by various physical devices, it supports reproducible representations of colorwhether such representation entails an analog or a digital represent ...
. There is no metadata in the file to indicate which format is being used.


PBM example

A simple example of the PBM format is as follows (there is a newline character 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 The symbol is known variously in English-speaking regions as the number sign, hash, or pound sign. The symbol has historically been used for a wide range of purposes including the designation of an ordinal number and as a Typographic ligature, ...
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: : Note that a 0 signifies a white pixel, and a 1 signifies a black pixel. This is in contrast to the other formats, where higher values signify brighter pixels. The P4 binary format of the same image represents each pixel with a single bit, packing 8 pixels per byte, with the first pixel as the most significant bit. Extra bits are added at the end of each row to fill a whole byte.


PGM example

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. There is a newline character at the end of each line. P2 # Shows the word "FEEP" (example from Netpbm man page on PGM) 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


PPM example

This is an example of a color RGB image stored in PPM format. There is a newline character at the end of each line. P3 # "P3" means this is a RGB color image in ASCII 3 2 # "3 2" is the width and height of the image in pixels 255 # "255" is the maximum value for each color # The part above is the header # The part below is the image data: RGB triplets 255 0 0 # red 0 255 0 # green 0 0 255 # blue 255 255 0 # yellow 255 255 255 # white 0 0 0 # black 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 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). 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 Portable Network Graphics (PNG, officially pronounced , colloquially pronounced ) is a raster-graphics file format that supports lossless data compression. PNG was developed as an improved, non-patented replacement for Graphics Interchange F ...
) image has a file size of 166 bytes. When converted to a 192×128 PPM image, the file size is 73,848 bytes. 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


16-bit extensions

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 In computing, endianness, also known as byte sex, is the order or sequence of bytes of a word of digital data in computer memory. Endianness is primarily expressed as big-endian (BE) or little-endian (LE). A big-endian system stores the mos ...
of the file. The various implementations could not agree on which byte order to use, and some connected the 16-bit endianness to the pixel packing order. In Netpbm, the ''
de facto ''De facto'' ( ; , "in fact") describes practices that exist in reality, whether or not they are officially recognized by laws or other formal norms. It is commonly used to refer to what happens in practice, in contrast with ''de jure'' ("by la ...
'' standard implementation of the PNM formats, the most significant byte is first.


32-bit extensions

The PFM (Portable Floatmap) is the unofficial four byte IEEE 754 single precision floating point extension. A color file is identified with the ASCII text "PF" in the first line of the header and a gray-scale with "Pf". The next ASCII text line contains the width and height, separated by the space character hex 20 and sometimes with hex 0A (resulting in four lines). After each line a white space character hex 0A is written and not the Windows/DOS CR/LF combination. The third ASCII text line holds a nonzero decimal number that indicates little endian floats for the pixel data when negative and big-endian floats when positive. The absolute value of the number indicates the range. So the third line containing -1.0 indicates little-endian format in range zero to one. There are no comments. 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. It's supported by the programs
Photoshop Adobe Photoshop is a raster graphics editor developed and published by Adobe Inc. for Windows and macOS. It was originally created in 1988 by Thomas and John Knoll. Since then, the software has become the industry standard not only in raster ...
,
GIMP GIMP ( ; GNU Image Manipulation Program) is a free and open-source raster graphics editor used for image manipulation (retouching) and image editing, free-form drawing, transcoding between different image file formats, and more specialized task ...
, and
ImageMagick ImageMagick, invoked from the command line as magick, is a free and open-source cross-platform software suite for displaying, creating, converting, modifying, and editing raster images. Created in 1987 by John Cristy, it can read and write ove ...
.


Programs

Netpbm contains over 220 separate programs in the package, 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 picture in the PBM format into a
.bmp The BMP file format, also known as bitmap image file, device independent bitmap (DIB) file format and bitmap, is a raster graphics image file format used to store bitmap digital images, independently of the display device (such as a graphics adap ...
file: pgmtoppm "#FFFFFF" somepic.pbm > somepic.ppm ppmtobmp somepic.ppm > somepic.bmp This is more commonly done as a
pipeline Pipeline may refer to: Electronics, computers and computing * Pipeline (computing), a chain of data-processing stages or a CPU optimization found on ** Instruction pipelining, a technique for implementing instruction-level parallelism within a s ...
, to save execution time and to avoid leaving a temporary ''somepic.ppm'' file around: pgmtoppm "#FFFFFF" somepic.pbm , 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 In the X Window System, the program xwd (X Window dump) captures the content of a screen or of a window and optionally saves it into a file. xwd runs in one of two ways: if a user specifies the whole screen or the name or identifier of a win ...
format) directly to a Macintosh
PICT The Picts were a group of peoples who lived in what is now northern and eastern Scotland (north of the Firth of Forth) during Late Antiquity and the Early Middle Ages. Where they lived and what their culture was like can be inferred from ear ...
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 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. Format XBM fil ...
to ''Ikon'' and eventually
X-Face An X-Face is a small bitmap (48 × 48 pixels, black and white) image which is added to a Usenet posting or e-mail message, typically showing a picture of the author's face. The image data is included in the posting as encoded text, and attached ...
.


History

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 ASCII ( ), abbreviated from American Standard Code for Information Interchange, is a character encoding standard for electronic communication. ASCII codes represent text in computers, telecommunications equipment, and other devices. Because of ...
in email often resulted in
data corruption In the pursuit of knowledge, data (; ) is a collection of discrete values that convey information, describing quantity, quality, fact, statistics, other basic units of meaning, or simply sequences of symbols that may be further interpreted. ...
. 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. The name Netpbm came from the program developers collaborating over the
Internet The Internet (or internet) is the global system of interconnected computer networks that uses the Internet protocol suite (TCP/IP) to communicate between networks and devices. It is a '' network of networks'' that consists of private, pub ...
, which was notable at the time; the
NetBSD NetBSD is a free and open-source Unix operating system based on the Berkeley Software Distribution (BSD). It was the first open-source BSD descendant officially released after 386BSD was forked. It continues to be actively developed and is a ...
operating system and
NetHack ''NetHack'' is an open source single-player roguelike video game, first released in 1987 and maintained by the NetHack DevTeam. The game is a fork of the 1982 game ''Hack'', itself inspired by the 1980 game ''Rogue''. The player takes the role as ...
game got their names similarly. (Unlike with the later, more widespread
Portable Network Graphics Portable Network Graphics (PNG, officially pronounced , colloquially pronounced ) is a raster-graphics file format that supports lossless data compression. PNG was developed as an improved, non-patented replacement for Graphics Interchange F ...
(PNG) format, the "net" in the name is not actually in reference to the image itself being optimized for transfer over a network.)


PAM graphics format

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: #The ''depth'' attribute defines the number of channels in the image, such as 1 for greyscale images and 3 for RGB images. #The ''tuple type'' attribute specifies what kind of image the PAM file represents, thus enabling it to stand for the older Netpbm formats, as well as to be extended to new uses, e.g., transparency. PAM is supported by
XnView XnView is an image organizer and general-purpose file manager used for viewing, converting, organizing and editing raster images, as well as general purpose file management. It comes with built-in hex inspection, batch renaming and screen ...
and
FFmpeg FFmpeg is a free and open-source software project consisting of a suite of libraries and programs for handling video, audio, and other multimedia files and streams. At its core is the command-line ffmpeg tool itself, designed for processing of vid ...
. As specified the TUPLTYPE is optional; however, FFmpeg requires it.


Differences from the older formats

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 ASCII ( ), abbreviated from American Standard Code for Information Interchange, is a character encoding standard for electronic communication. ASCII codes represent text in computers, telecommunications equipment, and other devices. Because of ...
-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").


Transparency

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 Example may refer to: * '' exempli gratia'' (e.g.), usually read out in English as "for example" * .example, reserved as a domain name that may not be installed as a top-level domain of the Internet ** example.com, example.net, example.org, ex ...
in the BMP article shows an
RGBA 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 ...
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: File:Bmp_format2.svg, frameless, rect 50 50 100 100 0,0: blue 0000FF FF rect 100 50 150 100 0,1: green 00FF00 FF rect 150 50 200 100 0,2: red FF0000 FF rect 200 50 250 100 0,3: white FFFFFF FF rect 50 100 100 150 1,0: blue 0000FF 7F, half transparent rect 100 100 150 150 1,1: green 00FF00 7F, half transparent rect 150 100 200 150 1,2: red FF0000 7F, half transparent rect 200 100 250 150 1,3: white FFFFFF 7F, half transparent default BMP file format#Example 2 desc top-left P7 WIDTH 4 HEIGHT 2 DEPTH 4 MAXVAL 255 TUPLTYPE RGB_ALPHA ENDHDR


Extensions

PAM's tuple-type mechanism allows for many extensions. In theory, PAM can be extended to represent colour 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.


Licensing

Netpbm consists of hundreds of different tools, each with a license of their own. An analysis by
Debian Debian (), also known as Debian GNU/Linux, is a Linux distribution composed of free and open-source software, developed by the community-supported Debian Project, which was established by Ian Murdock on August 16, 1993. The first version of D ...
developer Steve McIntyre from 2001 suggests mostly free software licenses, one non-commercial license (non-free) and a dozen without any license (thus also non-free). As mentioned in the analysis, it obviously doesn't cover changes since.


See also

* GD Graphics Library *
GraphicsMagick GraphicsMagick is a fork of ImageMagick, emphasizing stability of both programming API and command-line options. It was branched off ImageMagick's version 5.5.2 in 2002 after irreconcilable differences emerged in the developers' group. In additi ...
*
ImageMagick ImageMagick, invoked from the command line as magick, is a free and open-source cross-platform software suite for displaying, creating, converting, modifying, and editing raster images. Created in 1987 by John Cristy, it can read and write ove ...
*
List of Unix commands This is a list of Unix commands as specified by IEEE Std 1003.1-2008, which is part of the Single UNIX Specification (SUS). These commands can be found on Unix operating systems and most Unix-like operating systems. List See also * List of G ...
*
X PixMap 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. It is intended primaril ...
(comparison of PBM and XPM)


References


External links

*
pfm: the PFM graphic image file format as understood by the Netpbm


{{Graphics file formats Free graphics software Free software programmed in C Free software programmed in Perl Graphics file formats Graphics libraries Image processing software Unix programming tools