The PPM (or Portable Pix Map) image format is encoded in human-readable text. Below is a brief synopsis of the format which will aid you in being able to load a PPM image. If you are interested in more information, the formal image specification can be found here.
Sample ppm file:
P3 4 4 255 0 0 0 100 0 0 0 0 0 255 0 255 0 0 0 0 255 175 0 0 0 0 0 0 0 0 0 0 0 0 0 15 175 0 0 0 255 0 255 0 0 0 0 0 0 255 255 255
P3 4 4 255
The image body contains the actual picture information as a series of RGB values. Each pixel of the image is a tiny, colored square. In the PPM file, each pixel is defined by a triplet of values representing how much red, green, and blue (RGB) are present. So, the first pixel, which has a value of 0 0 0, is black, and the last pixel, 255 255 255, is white. r By varying the levels of the RGB values you can come up with any color in between.
Note that color values must be separated by a space, but after that any additional whitespace is ignored by the image viewer. In the sample ppm above we used additional whitespace to format the pixel values so that it is easy for a human to understand, but the computer doesn't care if everything is on one line, if there is one line of RGB values per line of the image, or some mix. You should not assume one line in the file corresponds to one line in the image.
The example image above would look something like this:
Keep in mind, each square is one pixel, so the real thing is much smaller (the rendered image was blown up by 5000%).
As an aside, while PPM files are easy to view as text
(you can use vim, emacs, or Notepad, for instance), they are highly
inefficient. Most modern image formats use some form of compression
to reduce the amount of information stored (and consequently, their size)
while preserving the image appearance. One modern use for PPM is an
intermediate format when converting images from one type to another.
On lab computers, there are many programs for viewing PPM files. ImageMagick can be invoked on the command line:
$ display image.ppmYou can also XV or GIMP. On your home computers, you may need to download an image viewer such as Irfanview.
To generate a PPM image from an image in your photo library, do the following in GIMP:
$ gimp image.jpg