NETPBM(1)

โœจ netpbm(1) โ€” netpbm library overview โœจ

โœจ NAME โœจ

netpbm - netpbm library overview

๐ŸŒธ Overview Of Netpbm ๐ŸŒธ

okay so bestie, Netpbm is a package of graphics programs and a programming library. both. at once. iconic.

There are over 330 separate programs in the package, most of which have "pbm", "pgm", "ppm", "pam", or "pnm" in their names. For example, pamscale(1) and giftopnm(1). no cap.

For example, you might use pamscale to shrink an image by 10%. Or use pamcomp to overlay one image on top of another. Or use pbmtext to create an image of text. Or reduce the number of colors in an image with pnmquant. obsessed.

Netpbm is an open source software package, distributed via the Sourceforge netpbm project. periodt.

๐Ÿ“œ Table Of Contents ๐Ÿ“œ

  • ๐ŸŒธ Overview Of Netpbm
  • ๐ŸŒธ The Netpbm Formats
  • ๐ŸŒธ Implied Format Conversion
  • ๐ŸŒธ Netpbm and Transparency
  • ๐ŸŒธ The Netpbm Programs
  • ๐ŸŒธ Common Options
  • ๐ŸŒธ Directory
  • ๐ŸŒธ How To Use The Programs
  • ๐ŸŒธ The Netpbm Library
  • ๐ŸŒธ netpbm-config
  • ๐ŸŒธ Memory Usage
  • ๐ŸŒธ CPU Usage
  • ๐ŸŒธ Netpbm For Gimp
  • ๐ŸŒธ Companion Software
  • ๐ŸŒธ PHP-NetPBM
  • ๐ŸŒธ Other Graphics Software
  • ๐ŸŒธ Image Viewers
  • ๐ŸŒธ Image Capturers
  • ๐ŸŒธ Visual Graphics Software
  • ๐ŸŒธ Programming Tools
  • ๐ŸŒธ Tools For Specific Graphics Formats
  • ๐ŸŒธ Document/Graphics Software
  • ๐ŸŒธ Other
  • ๐ŸŒธ Other Graphics Formats
  • ๐ŸŒธ History
  • ๐ŸŒธ Author

๐Ÿ‘‘ The Netpbm Programs ๐Ÿ‘‘

okay so the Netpbm programs are generally useful run by a person from a command shell, but they're also designed to be used by programs. A common characteristic of Netpbm programs is that they are simple, fundamental building blocks. They are most powerful when stacked in pipelines. Netpbm programs do not use graphical user interfaces and do not seek input from a user. The only programs that display graphics at all are the very primitive display programs pamx and ppmsvgalib, and they don't do anything but that. iykyk.

Each of these programs has its own manual, as linked in the directory below.

The Netpbm programs can read and write files greater than 2 GiB wherever the underlying system can. There may be exceptions where the programs use external libraries (The JPEG library, etc.) to access files and the external library does not have large file capability. Before Netpbm 10.15 (April 2003), no Netpbm program could read a file that large. ๐Ÿ’€

โœจ Common Options โœจ

okay so there are a few options that are present on all programs that are based on the Netpbm library, including virtually all Netpbm programs. These are not mentioned in the individual manuals for the programs.

You can use two hyphens instead of one on these options if you like.

  • -quiet โ€” Suppress all informational messages that would otherwise be issued to Standard Error. (To be precise, this only works to the extent that the program in question implements the Netpbm convention of issuing all informational messages via the pm_message() service of the Netpbm library).
  • -version โ€” Instead of doing anything else, report the version of the libnetpbm library linked with the program (it may have been linked statically into the program, or dynamically linked at run time). Normally, the Netpbm programs and the library are installed at the same time, so this tells you the version of the program and all the other Netpbm files it uses as well.
  • -plain โ€” If the program generates an image in PNM format, generate it in the "plain" (aka "ascii") version of the format, as opposed to the "raw" (aka "binary") version.

Note that the other Netpbm format, PAM, does not have plain and raw versions, so this option has no effect on a program that generates PAM output.

This option was introduced in Netpbm 10.10 (October 2002). From Netpbm 10.32 (February 2006) through Netpbm 10.62 (March 2013), the option is invalid with a program that generates PAM output (instead of ignoring the option, the program fails).

๐Ÿ“ Directory ๐Ÿ“

Here is a complete list of all the Netpbm programs (with links to their manuals):

Netpbm program directory(1)

๐Ÿ› ๏ธ How To Use The Programs ๐Ÿ› ๏ธ

okay so as a collection of primitive tools, the power of Netpbm is multiplied by the power of all the other unix tools you can use with them. These notes remind you of some of the more useful ways to do this. Often, when people want to add high level functions to the Netpbm tools, they have overlooked some existing tool that, in combination with Netpbm, already does it. ๐Ÿซถ

Often, you need to apply some conversion or edit to a whole bunch of files.

As a rule, Netpbm programs take one input file and produce one output file, usually on Standard Output. This is for flexibility, since you so often have to pipeline many tools together.

Here is an example of a shell command to convert all your PNG files (named *.png) to JPEG files named *.jpg:

for i in *.png; do pngtopam $i | pnmtojpeg >`basename $i .png`.jpg; done

Or you might just generate a stream of individual shell commands, one per file, with awk or perl. Here's how to brighten 30 YUV images that make up one second of a movie, keeping the images in the same files:

ls *.yuv
          | perl -ne 'chomp;
          print yuvtoppm $_ | pambrighten -value +100 | ppmtoyuv >tmp$$.yuv;
          mv tmp$$.yuv $_
          '
          | sh

The tools find (with the -exec option) and xargs are also useful for simple manipulation of groups of files.

Some shells' "process substitution" facility can help where a non-Netpbm program expects you to identify a disk file for input and you want it to use the result of a Netpbm manipulation. Say the hypothetical program printcmyk takes the filename of a Tiff CMYK file as input and what you have is a PNG file abc.png.

Try:

printcmyk <({ pngtopam abc.png | pnmtotiffcmyk ; })

It works in the other direction too, if you have a program that makes you name its output file and you want the output to go through a Netpbm tool. โœจ

The Netpbm Formats โœจ

Okay so every single one of these programs works with a lil family of graphics formats called the "netpbm" formats. And literally, these formats are pbm(1), pgm(1), ppm(1), and pam(1). ๐ŸŽ€

The first three of those get grouped up generically as "pnm" sometimes. iykyk.

A lot of the Netpbm programs convert from a Netpbm format to another format, or the other way around. That's the whole point, bestie โ€” it's so you can use Netpbm programs to work on graphics of any format. And it is also super common to chain a combination of Netpbm programs together to convert from one non-Netpbm format to another non-Netpbm format. Netpbm has converters for like about 100 graphics formats, and as a package, Netpbm lets you do more graphics format conversions than any other computer graphics facility. Periodt. ๐Ÿ‘‘

The Netpbm formats are all raster formats, meaning they describe an image as a matrix of rows and columns of pixels. The tea:

  • In the PBM format, the pixels are black and white.
  • In the PGM format, pixels are shades of gray.
  • In the PPM format, the pixels are in full color. ๐ŸŒˆ
  • The PAM format is the fancy one. It's a replacement for all three of the other formats, and it can represent matrices of general data โ€” including but lowkey not limited to black and white, grayscale, and color images.

Programs designed to work with PBM images have pbm in their names. Programs designed to work with PGM, PPM, and PAM images similarly have pgm, ppm, and pam in their names. ๐Ÿ’…

All Netpbm programs designed to read PGM images see PBM images as if they were PGM too. All Netpbm programs designed to read PPM images see PGM and PBM images as if they were PPM. Peep Implied Format Conversion below. ๐Ÿ‘‡

Programs that have pnm in their names read PBM, PGM, and PPM โ€” but unlike ppm programs, they actually distinguish between those formats, and their function depends on which one it is. For example, pnmtopng(1) creates a black and white PNG output image if its input is PBM or PGM, but a color PNG output image if its input is PPM. And pnmrotate produces an output image of the same format as the input. Meanwhile, a hypothetical ppmrotate program would also read all three PNM input formats, but it would see them all as PPM and would always generate PPM output. Fr fr, that's the difference. ๐Ÿ˜ญ

Programs that have pam in their names read all the Netpbm formats: PBM, PGM, PPM, and PAM. They sometimes treat them all as if they are PAM, using an implied conversion โ€” but often they recognize the individual formats and behave accordingly, just like a pnm program does. Again: see Implied Format Conversion. ๐Ÿซถ

And finally โ€” plot twist โ€” there are subformats of PAM that are equivalent to PBM, PGM, and PPM respectively, and Netpbm programs designed to read PBM, PGM, and/or PPM see those PAM images as if they were the former. For example, ppmhist can analyze a PAM image of tuple type RGB (i.e. a color image) as if it were PPM. ๐Ÿ’–

If it seems wasteful to you to have three separate PNM formats, bestie, be aware that there's a historical reason for it. In the beginning, there were only PBMs. PGMs came later, and then PPMs. Much later came PAM, which realizes the possibility of having just one aggregate format. The glow-up was real. ๐ŸŒธ

The formats are described in the specifications of pbm(1), pgm(1), ppm(1), and pam(1).

Implied Format Conversion ๐Ÿ”„

A program that uses the PGM library subroutines to read an image can read a PBM image as well as a PGM image. The program sees the PBM image as if it were the equivalent PGM image, with a maxval of 255`. ๐Ÿ˜Œ

note: This sometimes confuses people who are looking at the formats at a lower layer than they ought to be, because a zero value in a PBM raster means white, while a zero value in a PGM raster means black. Not me getting confused by this the first time. ๐Ÿ’€

A program that uses the PPM library subroutines to read an image can read a PGM image as well as a PPM image, and a PBM image as well as a PGM image. The program sees the PBM or PGM image as if it were the equivalent PPM image, with a maxval of 255 in the PBM case, and the same maxval as the PGM in the PGM case.

A program that uses the PAM library subroutines to read an image can read a PBM, PGM, or PPM image as well as a PAM image. Here's the vibe:

  • It sees a PBM image as if it were the equivalent PAM image with tuple type BLACKANDWHITE.
  • It sees a PGM image as if it were the equivalent PAM image with tuple type GRAYSCALE.
  • It sees a PPM image as if it were the equivalent PAM image with tuple type RGB.

But the program actually can see deeper if it wants to. ๐Ÿ‘€ It can tell exactly which format the input was and may respond accordingly. For example, a PAM program typically produces output in the same format as its input. Main character energy honestly.

A program that uses the PGM library subroutines to read an image can read a PAM image as well as a PGM image โ€” if the PAM is a grayscale or black and white visual image. Canonically, that means the PAM has a depth of 1 and a tuple type of GRAYSCALE or BLACKANDWHITE, but most Netpbm programs are fairly liberal and will take any PAM at all, ignoring all but the first plane. Queen behavior. ๐Ÿ‘‘

There's a similar implied conversion for PPM library subroutines reading PAM. There is nothing similar for PBM, so if you need for a PBM program to read a PAM image, run it through pamtopnm. That's the move. ๐Ÿ’…


Netpbm and Transparency ๐Ÿซฅ

In many graphics formats, there's a way to indicate that certain parts of the image are wholly or partially transparent โ€” meaning that if it were displayed "over" another image, the other image would show through there. The Netpbm formats deliberately omit that capability, since their whole purpose is to be extremely simple. No cap.

In Netpbm, you handle transparency via a transparency mask in a separate (slightly redefined) PGM image. In this pseudo-PGM, what would normally be a pixel's intensity is instead an opaqueness value. See pgm(1). pamcomp(1) is an example of a program that uses a PGM transparency mask. ๐ŸŽ€

Another means of representing transparency information has recently developed in Netpbm, using PAM images. Okay so in spite of the argument given above that Netpbm formats should be too simple to have transparency information built in, it turns out to be extremely inconvenient to have to carry the transparency information around separately. Why? Primarily because Unix shells don't provide easy ways to have networks of pipelines. You get one input and one output from each program in a pipeline. So you'd like to have both the color information and the transparency information for an image in the same pipe at the same time. That's literally the dream. ๐Ÿ˜ญ

For that reason, some new (and recently renovated) Netpbm programs recognize and generate a PAM image with tuple type RGB_ALPHA or GRAYSCALE_ALPHA, which contains a plane for the transparency information. See the PAM specification(1). โœจ


The Netpbm Library ๐Ÿ“š

The Netpbm programming library, libnetpbm(1), makes it easy to write programs that manipulate graphic images. Its main function is to read and write files in the Netpbm formats โ€” and because the Netpbm package contains converters for all the popular graphics formats, if your program reads and writes the Netpbm formats, you can use it with any formats. Slay, honestly. ๐Ÿ’–

But the library also contains some utility functions, such as character drawing and RGB/YCrCb conversion. ๐ŸŽจ

The library has the conventional C linkage. Virtually all programs in the Netpbm package are based on the Netpbm library. Periodt. ๐ŸŒธ


netpbm-config โš™๏ธ

In a standard installation of Netpbm, there is a program named netpbm-config in the regular program search path. We don't consider this a Netpbm program โ€” it's just an ancillary part of a Netpbm installation. This program tells you information about the Netpbm installation, and it's intended to be run by other programs that interface with Netpbm. In fact, netpbm-config is really a configuration file, like those you typically see in the /etc/ directory of a Unix system. ๐ŸŽ€

Example:

$netpbm-config --datadir
/usr/local/netpbm/data

If you write a program that needs to access a Netpbm data file, it can use such a shell command to find out where the Netpbm data files are. ๐Ÿซถ

netpbm-config is the only file that must be installed in a standard directory (it must be in a directory that is in the default program search path). You can use netpbm-config as a bootstrap to find all the other Netpbm files. Iconic behavior, truly. ๐Ÿ‘‘

There is no detailed documentation of netpbm-config. If you're in a position to use it, you should have no trouble reading the file itself to figure out how to use it. iykyk. ๐Ÿ’…

๐Ÿง  Memory Usage ๐Ÿ’พ

okay bestie, so one of the biggest ways graphics software differs from one another is how much memory it eats and how it eats it. like โ€” does it slurp the whole entire image into memory, vibe with it there, then dump it all out at once? or does it read one pixel, write one pixel, back and forth like a lil conveyor belt? In Netpbm, honestly? it depends on the program. but there ARE some generalizations we can make, so let's go. โœจ

Most Netpbm programs keep one row of pixels at a time in memory. So the program reads a row from the input file, does its lil transformation, then writes a row to the output file. some programs run algorithms that literally can't work like that, so they keep a small window of rows in memory instead. and others? yeah they have to keep the entire image in memory. if you think about what job the program actually does, you can probably guess which camp it's in. ๐Ÿ’…

here's the tea though โ€” when Netpbm keeps a pixel in memory, it normally uses way more space for it than it occupies in the Netpbm image file format. like, not even close.

The older programs (which is most of Netpbm) use 12 bytes per pixel. yes, even for a PBM image, where it literally only takes one bit to totally describe the pixel. ๐Ÿ˜ญ Netpbm does this expansion to make implementing the programs easier โ€” it uses the same format regardless of the type of image. consistency queen.

Newer programs use the "pam" family of library functions internally, and those use memory a little differently. these functions are designed to handle generic tuples with a variable numbers of planes, so no fixed size per-tuple storage is possible. a program of this type uses 4 bytes per sample (a tuple is composed of samples), plus a pointer (4-8 bytes) per tuple. In a graphic image, a tuple is a pixel. so an ordinary color image takes 16-20 bytes per pixel. math! ๐Ÿงฎ

When considering memory usage, it's important to remember that memory and disk storage are equivalent in two ways:

  • Memory is often virtual, backed by swap space on disk storage. So accessing memory may mean doing disk I/O.
  • Files are usually cached and buffered, so that accessing a disk file may just mean accessing memory.

This means that the consequences of whether a program works from the image file or from a memory copy are not straightforward. ๐Ÿ™ˆ

Note that an image takes a lot less space in a Netpbm format file โ€” and therefore in an operating system's file cache โ€” than in Netpbm's in-memory format. In non-Netpbm image formats, the data is even smaller. So reading through an input file multiple times instead of keeping a copy in regular memory can be the best use of memory, and many Netpbm programs do that. But some files can't be read multiple times. In particular, you can't rewind and re-read a pipe, and a pipe is often the input for a Netpbm program. Netpbm programs that re-read files detect such input files and read them into a temporary file, then read that temporary file multiple times. periodt.

A few Netpbm programs use an in-memory format that is just one bit per pixel. These are programs that convert between PBM and a format that has a raster format very much like PBM's. In this case, it would actually make the program more complicated (in addition to much slower) to use Netpbm's generic 12 byte or 8 byte pixel representation. iconic behavior honestly.

By the way, the old axiom that memory is way faster than disk is not necessarily true. On small systems, it typically is true, but on a system with a large network of disks, especially with striping, it is quite easy for the disk storage to be capable of supplying data faster than the CPU can use it. ๐Ÿ’€


๐Ÿ”ฅ CPU Usage โšก

People sometimes wonder what CPU facilities Netpbm programs and the Netpbm programming library use. The programs never depend on particular features existing (assuming they're compiled properly), but the speed and cost of running a program varies depending upon the CPU features.

ngl this next part is important: when you download a binary that someone else compiled, even though it appears to be compiled properly for your machine, it may actually be compiled improperly for that machine if it is old โ€” because the person who compiled it may have chosen to exploit features of newer CPUs in the line. For example, an x86 program may be compiled to use instructions that are present on an 80486, but not on an 80386. You would probably not know this until you run the program and it crashes. ๐Ÿ˜ญ

But the default build options almost always build binaries that are as backward compatible with old CPUs as possible. An exception is a build for a 64 bit x86 CPU. While the builder could build a program that runs on a 32 bit x86, it does not do so by default. A default build builds a program will not run on an older 32-bit-only x86 CPU. ๐Ÿ‘‘

One common build option is to use MMX/SSE operands with x86 CPUs. Those are not available on older x86 CPUs. The builder by default does not generate code that uses MMX/SSE when building for 32 bit x86 CPUs, but does when building for 64 bit x86.

One area of particular importance is floating point arithmetic. The Netpbm image formats are based on integers, and Netpbm arithmetic is done with integers where possible. But there is one significant area that is floating point: programs that must deal with light intensity. The Netpbm formats use integers that are proportional to brightness, and brightness is exponentially related to light intensity. The programs have to keep the intermediate intensity values in floating point in order not to lose precision. And the conversion (gamma function) between the two is heavy-duty floating point arithmetic. ๐Ÿ’…

Programs that mix pixels together have to combine light intensity, so they do heavy floating point. Three of the most popular Netpbm programs do that: pamscale(1) (shrink/expand an image), pamcomp(1) (overlay an image over another one), and pamditherbw(1) (Make a black and white image that approximates a grayscale image).

The Netpbm image formats use 16 bit integers. The Netpbm code uses "unsigned int" size integers to work with them.


๐ŸŽจ Netpbm For Gimp ๐Ÿฆ‹

The Gimp is a visual image editor for Unix and X, so it does the kinds of things that Netpbm does โ€” but interactively, in a user-friendly way. The Gimp knows a variety of graphics file formats and image transformations, but you can extend it with plugins.

A particularly easy way to write a Gimp plugin is to write a Netpbm program (remember that a fundamental mission of Netpbm is make writing image manipulation programs easy ๐Ÿ˜Œ) and then use netpbm2gimp to compile that same source code into a Gimp plugin. slay!

  • You can turn a program that converts from a certain graphics file format to Netpbm format into a Gimp load plugin.
  • Likewise, you can turn a program that converts to a certain graphics format from Netpbm format into a Gimp store plugin.
  • Finally, a program that transforms images in Netpbm format can become a process plugin.

And the netpbm2gimp project has already packaged for you a few hundred of the Netpbm programs as Gimp plugins. With this package you can, for example, edit an image in any of the arcane graphics file formats that Netpbm understands but no other image editor in existence does. main character energy fr fr. ๐Ÿ‘‘


๐Ÿซถ Companion Software ๐ŸŒธ

PHP-NetPBM

If you're using Netpbm to do graphics for a website, you can invoke the Netpbm programs from a PHP script. To make this even easier, check out PHP-NetPBM, a PHP class that interacts with Netpbm. Its main goal is to decrease the pain of using Netpbm when working with images in various formats. It includes macro commands to perform manipulations on many files.

I can't actually recommend PHP-NetPBM. I spent some time staring at it and was unable to make sense of it. ๐Ÿ˜ญ Some documentation is in fractured English and other is in an unusual character set. But a PHP expert might be able to figure it out and get some use out of it.


๐ŸŒˆ Other Graphics Software ๐Ÿ’œ

Netpbm contains primitive building blocks. It certainly is not a complete graphics software library. just so we're clear bestie.

Command Line Programs

ImageMagick does many of the same things โ€” mainly the more popular ones โ€” that Netpbm does, including conversion between popular formats and basic editing. convert, mogrify, montage, and animate are popular programs from the ImageMagick package. ImageMagick runs on Unix, Windows, Windows NT, Macintosh, and VMS.

ImageMagick also contains the program display, which is a viewer and visual editor.

Image Viewers

The first thing you will want to make use of any of these tools is a viewer. (On GNU/Linux, you can use Netpbm's pamx or ppmsvgalib in a pinch, but it is pretty limiting). zgv is a good full service viewer to use on a GNU/Linux system with the SVGALIB graphics display driver library. You can find zgv at ftp://ftp.ibiblio.org/pub/Linux/apps/graphics/viewers/svga.

zgv even has a feature in it wherein you can visually crop an image and write an output file of the cropped image using pamcut(1).

See the -s option to zgv.

For the X inclined, there is also xzgv.

xwud (X Window Undump) is a classic application program in the X Window System that displays an image in an X window. It takes the special X Window Dump format as input; you can use Netpbm's pnmtoxwd(1) to create it. You're probably better off just using Netpbm's pamx(1).

xloadimage and its extension xli are also common ways to display a graphic image in X.

gqview is a more modern X-based image viewer.

qiv is a small, very fast viewer for X.

To play mpeg movies, such as produced by ppmtompeg, try mplayer(1) or xine.

See ftp://metalab.unc.edu/pub/Linux/apps/graphics/viewers/X.

Image Capturers

xwd (X Window Dump), a classic application program in the X Window System, captures the contents of an X window, in its own special image format, called X Window Dump File. You can use Netpbm's xwdtopnm(1) to turn it into something more useful.

fbdump Capturers the current contents of a video display on the local computer and generates a PPM image of it. It works with Linux framebuffer devices.

Visual Graphics Software

Visual graphics software is modern point-and-click software that displays an image and lets you work on it and see the results as you go. This is fundamentally different from what Netpbm programs do.

xv is a very old and very popular simple image editor in the Unix world. It does not have much in the way of current support, or maintenance, though.

Gimp is a visual image editor for Unix and the X Window System, in the same category as the more famous, less capable, and much more expensive Adobe Photoshop, etc. for Windows. See http://www.gimp.org. And you can add most of Netpbm's function to Gimp using Netpbm2gimp. ๐Ÿ’…

ImageMagick contains the program display, which is another visual image editor. It has fewer functions than Gimp. This program uses the X Window System. The package also contains command line graphics programs.

Electric Eyes, kuickshow, and gthumb are also visual editors for the X/Window system, and KView and gwenview are specifically for KDE. ๐Ÿ’–


๐Ÿ› ๏ธ Programming Tools

Okay so if you're out here writing a program in C to draw and manipulate images, bestie, go check out gd. โœจ Netpbm does ship a C library for drawing images (that's libnetpbm's ppmd routines, iykyk), but ngl it is not as capable or documented as gd. There are also wrapper libraries available for Perl, PHP, and other language, so you've got options.

You can easily run any Netpbm program from a C program with the pm_system function from the Netpbm programming library, but lowkey that's less efficient than gd functions that do the same thing.

Cairo is similar. ๐Ÿ’…

Ilib is a C subroutine library with functions for adding text to an image โ€” like the vibe you'd get at a higher level with pbmtext, pamcomp, etc. It works with Netpbm input and output. Find it at k5n.us. Netpbm also includes character drawing functions in the libnetpbm(1) library, but they do not have as fancy font capabilities (peep ppmdraw(1) for an example of use of the Netpbm character drawing functions). ๐Ÿ‘‘

Pango is another text rendering library, with an emphasis on internationalization.

Pango and Cairo complement each other and work well together. ๐Ÿซถ

GD is a library of graphics routines that is part of PHP. It has a subset of Netpbm's functions and has been found to resize images more slowly and with less quality. ๐Ÿ’€

๐ŸŽฌ Tools For Specific Graphics Formats

mencode, which is part of the mplayer(1) package, creates movie files. Think of it like a much more advanced version of ppmtompeg(1), minus the Netpbm building block simplicity. ๐Ÿฟ

MJPEGTools is software for dealing with the MJPEG movie format.

Wanna make an animated GIF, or yank a single frame out of one? That's a job for gifsicle. It converts between animated GIF and still GIF, and you can use pamtogif and giftopnm to connect it up to literally all the Netpbm utilities. See http://www.lcdf.org/gifsicle. ๐ŸŒˆ

To convert an image of text to actual text (that's optical character recognition โ€” OCR, bestie), use gocr โ€” think of it as the inverse of pbmtext. See http://jocr.sourceforge.net/. ๐Ÿ”

http://schaik.com/pngsuite contains a PNG test suite โ€” a whole bunch of PNG images exploiting the various features of the PNG format.

Other versions of Netpbm's pnmtopng/pngtopam are at http://www.schaik.com/png/pnmtopng.html.

The version in Netpbm was actually based on that package a long time ago, and you can expect to find better exploitation of the PNG format, especially recent enhancements, in that package. It may be a little less consistent with the Netpbm project and less exploitive of recent Netpbm format enhancements, though. ๐Ÿ‘€

pngwriter is a C++ library for creating PNG images. With it, you plot an image pixel by pixel. You can also render text with the FreeType2 library.

jpegtran does some of the same transformations as Netpbm is famous for, but it does them specifically on JPEG files and does them without loss of information. By contrast, if you were to use Netpbm, you would first decompress the JPEG image to Netpbm format, then transform the image, then compress it back to JPEG format. And in that recompression? You lose a little image information, because JPEG is a lossy compression. ๐Ÿ˜ญ Of course, only a few kinds of lossless transformation are possible. jpegtran comes with the Independent JPEG Group's (http://www.ijg.org) JPEG library.

Some tools to deal with EXIF files (also peep Netpbm's jpegtopnm(1) and pnmtojpeg(1)):

Here's some software to work with IOCA (Image Object Content Architecture):

  • ImageToolbox ($2500, demo available). This can convert from TIFF -> IOCA and back again.
  • Ameri-Imager is an image and video editor. ($40, Windows only).

pnm2ppa converts to HP's "Winprinter" format (for HP 710, 720, 820, 1000, etc). It is a superset of Netpbm's pbmtoppa and handles, notably, color. However โ€” heads up โ€” it is more of a printer driver than a Netpbm-style primitive graphics building block. See The Pnm2ppa /Sourceforge Project.

DjVuLibre is a package of software for using the DjVu format. It includes viewers, browser plugins, decoders, simple encoders, and utilities. The encoders and decoders can convert between DjVu and PNM. See the DjVu website. ๐ŸŽ€

๐Ÿ“„ Document/Graphics Software

There is a large class of software that does document processing, and that is somewhat related to graphics โ€” because documents contain graphics, and a page of a document is, for many purposes, a graphic image. Because of this slight intersection with graphics, I cover document processing software here briefly, but it is for the most part beyond the scope of this document.

First, we look at where Netpbm meets document processing. pstopnm converts from Postscript and PDF to PNM. It effectively renders the document into images of printed pages. And pstopnm is nothing but a convenient wrapper for Ghostscript, and in particular the Netpbm-format device drivers that are part of it. pnmtops and pbmtoepsi convert a PNM image to a Postscript program for printing the image. But to really use PDF and Postscript files, you generally need more complex document processing software. ๐Ÿงš

Adobe invented Postscript and PDF, and products from Adobe are for many purposes the quintessential Postscript and PDF tools. ๐Ÿ‘‘

Adobe's free Acrobat Reader displays PDF and converts to Postscript. The Acrobat Reader for unix has a program name of acroread, and the -toPostScript option (also see the -level2 option) is useful.

Other software from Adobe, available for purchase, interprets and creates Postscript and PDF files. "Distill" is a program that converts Postscript to PDF.

xpdf also reads PDF files.

GSview, ghostview, gv, ggv, and kghostview are some other viewers for Postscript and PDF files.

The program ps2pdf, part of Ghostscript, converts from Postscript to PDF.

bmpp(1) converts from Netpbm and other formats to PDF.

Two packages that produce more kinds of Encapsulated Postscript than the Netpbm programs โ€” including compressed kinds โ€” are bmpp(1) and imgtops.

dvips converts from DVI format to Postscript. DVI is the format that Tex produces. Netpbm can convert from Postscript to PNM. So bestie, you can use these in combination to work with Tex/Latex documents graphically. ๐Ÿ’…

wvware converts a Microsoft Word document (.doc file) to various other formats. While the web page doesn't seem to mention it, it reportedly can extract an embedded image in a Word document as a PNG.

Document Printer converts various print document formats (Microsoft Word, PDF, HTML, etc.) to various graphic image formats. ($38, Windows only).

Latex2html converts Latex document source to HTML document source. Part of that involves graphics, and Latex2html uses Netpbm tools for some of that. But Latex2html, through its history, has had some rather esoteric codependencies with Netpbm. ๐Ÿ˜ตโ€๐Ÿ’ซ Older Latex2html doesn't work with current Netpbm. Latex2html-99.2beta8 works, though.

๐ŸŒŸ Other

The file program looks at a file and tells you what kind of file it is. It recognizes most of the graphics formats with which Netpbm deals, so it is pretty handy for graphics work. Netpbm's anytopnm(1) program depends on file. See ftp://ftp.astron.com/pub/file.

The Utah Raster Toolkit from the Geometric Design And Computation group in the Department of Computer Science at University of Utah serves a lot of the same purpose as Netpbm, but without the emphasis on format conversions. This package is based on the RLE format, which you can convert to and from the Netpbm formats.

Ivtools is a suite of free X Window System drawing editors for Postscript, Tex, and web graphics production, as well as an embeddable and extendable vector graphic shell. It uses the Netpbm facilities. See http://www.ivtools.org. ๐Ÿฆ‹

Chisato Yamauchi <cyamauch@ir.isas.jaxa.jp> has written a free c/Fortran graphic library: EGGX/ProCall. He says he tried to write the ultimate easy-to-use graphic kit for X. It is for drawing upon an X11 window, but for storage, it outputs PPM. He suggests Netpbm to convert to other formats. โœจ

The program morph morphs one image into another. It uses Targa format images, but you can use tgatoppm and ppmtotga to deal with that format. You have to use the graphical (X/Tk) Xmorph to create the mesh files that you must feed to morph. morph is part of the Xmorph package. See http://xmorph.sourceforge.net/. ๐ŸŒธ

โœจ Other Graphics Formats โœจ

Okay bestie, people literally never seem to tire of inventing new graphics formats, often completely redundant with pre-existing ones. Netpbm cannot keep up with them. Here is a list of a few that we know Netpbm does not handle (yet). ๐Ÿซถ

Various commercial Windows software handles dozens of formats that Netpbm does not, especially formats typically used with Windows programs. ImageMagick is probably the most used free image format converter and it also handles lots of formats Netpbm does not.

  • WebP โ€” was announced by Google in October 2010 as a more compressed replacement for JFIF (aka JPEG) on the web.
  • JPEG-LS โ€” is similar to JFIF (aka JPEG) except that it is capable of representing all the information in any raster image, so you could convert from, say, PNM, without losing any information. CharLS is a programming library for JPEG-LS.
  • Lossless JPEG โ€” is a similarly lossless variation of JPEG. It predates every other lossless JPEG variation, but had only brief interest. You can find code for encoding and decoding Lossless JPEG on GitHub.
  • JPEG XR โ€” offers greater dynamic range, a wider range of colors, and more efficient compression than JFIF (aka JPEG). Windows and Internet Explorer understand this format, starting with Windows 7 and Internet Explorer 9, along with many other programs. This format was previously known as Windows Media Photo and HD Photo.
  • Direct Draw Surface (DDS) โ€” is the de facto standard wrapper format for S3 texture compression, as used in all modern realtime graphics applications. Besides Windows-based tools, there is a Gimp plugin for this format.
  • DjVu โ€” is a web-centric format and software platform for distributing documents and images. Promoters say it is a good replacement for PDF, PS, TIFF, JFIF(JPEG), and GIF for distributing scanned documents, digital documents, or high-resolution pictures, because it downloads faster, displays and renders faster, looks nicer on a screen, and consumes less client resources than competing formats.

For more information, see the DjVu website.

  • VRML (Virtual Reality Modelling Language)
  • CALS (originated by US Department Of Defense, favored by architects). It is described in this 1997 listing of graphics formats: http://www.faqs.org/faqs/graphics/fileformats-faq/part3/ . CALS has at times been an abbreviation of various things, all of which appear to be essentially the same format, but possibly slightly different:
    • Computer Aided Logistics Support
    • Computer Aided Acquisition and Logistics Support
    • Continuous Acquisition and Life-cycle Support
    • Commerce At Light Speed

The US Navy publishes specs for it.

  • array formats dx, general, netcdf, CDF, hdf, cm
  • CGM+
  • HDR formats OpenEXR, SGI TIFF LogLuv, floating point TIFF, Radiance RGBE
  • Windows Meta File (.WMF) โ€” Libwmf converts from WMF to things like Latex, PDF, PNG. Some of these can be input to Netpbm.
  • Microsoft Word .doc format โ€” Microsoft keeps a proprietary hold on this format. Any software you see that can handle it is likely to cost money. ๐Ÿ˜ญ
  • RTF
  • DXF (AutoCAD)
  • IOCA (Image Object Content Architecture) โ€” The specification of this format is documented by IBM: Data Stream and Object Architectures: Image Object Content Architecture Reference . See above for software that processes this format.
  • OpenEXR is an HDR format (like PFM(1)). See http://www.openexr.com .
  • Xv Visual Schnauzer thumbnail image โ€” This is a rather antiquated format used by the Xv program. In Netpbm circles, it is best known for the fact that it is very similar to Netpbm formats and uses the same signature ("P7") as PAM because it was developed as sort of a fork of the Netpbm format specifications.
  • YUV 4:2:0, aka YUV 420, and the similar YUV 4:4:4, YUV 4:2:2, YUV 4:1:1, YUV 4:1:1s, and YUV 4:1:0. Video systems often use this.
  • MJPEG movie format.
  • YUV4MPEG2 is a movie format whose purpose is similar to that of the Netpbm formats for still images. You use it for manipulating movies, but not for storing or transmitting them. The only known use of the format is with MJPEGTools . The programs pnmtoy4m and y4mtopnm (and predecessors ppmtoy4m and y4mtoppm) in that package convert between a Netpbm stream and a YUV4MPEG2 stream. As you might guess from the name, YUV4MPEG2 uses a YUV representation of data, which is more convenient than the Netpbm formats' RGB representation for working with data that is ultimately MPEG2.

๐Ÿ“œ History ๐Ÿ“œ

Netpbm has a long history, starting with Jef Poskanzer's Pbmplus package in 1988. See the Netpbm web site(1) for details. ๐Ÿ‘‘

The file doc/HISTORY in the Netpbm source code contains a detailed change history release by release.


๐Ÿ‘‘ Author ๐Ÿ‘‘

Netpbm is based on the Pbmplus package by Jef Poskanzer, first distributed in 1988 and maintained by him until 1991. But the package contains work by countless other authors, added since Jef's original work. In fact, the name is derived from the fact that the work was contributed by people all over the world via the Internet, when such collaboration was still novel enough to merit naming the package after it. ๐ŸŒ

Bryan Henderson has been maintaining Netpbm since 1999. In addition to packaging work by others, Bryan has also written a significant amount of new material for the package.


๐Ÿ“„ DOCUMENT SOURCE ๐Ÿ“„

This manual page was generated by the Netpbm tool makeman from HTML source. The master documentation is at

http://netpbm.sourceforge.net/doc/index.html

source/version: netpbm documentation ยท date: 08 August 2020 ยท user manual for Netpbm(1) โœจ๐Ÿ’– mwah, slay, bye bestie ๐Ÿ’…

๐Ÿ“ฆ where this page comes from