ASCII Portable Gray Map (PGM) Files
Read and Write Utilities

PGMA_IO is a C library which reads and writes files in the ASCII Portable Gray Map (PGM) format for 2D grayscale graphics information.

There are many graphics programs, such as XV and GIMP, that can display images in this format, or translate them to other formats such as BMP, GIF, JPEG, MacPaint, X Window, and so on.


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


PGMA_IO is available in a C version and a C++ version and a FORTRAN77 version and a FORTRAN90 version and a MATLAB version.

Related Data and Programs:

MRI_TO_PGM, a C program which converts the binary data in an MRI file to a sequence of ASCII Portable Gray Map (PGM) image files.

PBMA_IO, a C library which handles the ASCII Portable Bit Map (PBM) format.

PGMA, a data directory which contains examples of ASCII Portable Gray Map (PGM) files.

PGMA_TO_PGMB, a C++ program which converts an ASCII Portable Gray Map (PGM) file to a binary PGM file.

PGMB_IO, a C++ library which handles the binary Portable Gray Map (PGM) format.

PGMB_TO_PGMA, a C++ program which converts a binary Portable Gray Map (PGM) file to an ASCII PGM file.

PPMA_IO, a C library which can read or write ASCII Portable Pixel Map (PPM) graphics files.


  1. the NETPBM homepage.

Source Code:

Examples and Tests:

List of Routines:

You can go up one level to the C source codes.

Last revised on 04 June 2010.