top of page
johnathanloendorf4

.pgm File Download: The Best Software and Tools for Working with PGM Files



Below you will find a selection of sample .pgm image files for you to download. On the right there are some details about the file such as its size so you can best decide which one will fit your needs.


  • PGMB is a data directory of Binary PGM files, the binary form of the portable gray map PGM format. It is a simple gray map description. The definition is as follows: the typical file extension is ".pgm", but an extension of ".pnm" is also occasionally used.

  • A "magic number" for identifying the file type. A binary PGM file's magic number is the two characters "P5".

  • Whitespace (blanks, TABs, CRs, LFs).

  • A width, formatted as ASCII characters in decimal.

  • Whitespace.

  • A height, again in ASCII decimal.

  • Whitespace.

  • The maximum gray value, MAXVAL, again in ASCII decimal. MAXVAL must be between 0 and 255.

  • A single character of whitespace, typically a newline;

  • Width * height gray values, each stored as a plain byte, between 0 and the specified maximum value, separated by whitespace, starting at the top-left corner of the graymap, proceeding in normal English reading order. A value of 0 means black, and the maximum value means white.

Characters from a "#" to the next end-of-line are ignored (comments).




.pgm File download



  • baboon.pgm, a baboon.

  • baboon.png, a PNG version.

  • barbara.pgm.

  • barbara.png, a PNG version.

  • bird.pgm, a bird.

  • bird.png, a PNG version.

  • buffalo.pgm, a small herd of buffalo.

  • buffalo.png, a PNG version.

  • casablanca.pgm, a still from the movie "Casablanca".

  • casablanca.png, a PNG version.

  • coins.pgm, some coins.

  • coins.png, a PNG version.

  • columns.pgm, a 640x480 image of a person standing by some columns;

  • columns.png, a PNG image.

  • dewey_defeats_truman.pgm, a famously erroneous newspaper headline.

  • dewey_defeats_truman.png, a PNG version.

  • feep.pgm, a simple 7 by 24 example that displays "FEEP" in block letters.

  • feep.png, a PNG image.

  • ladyzhenskaya.pgm.

  • ladyzhenskaya.png, a PNG version.

  • lena.pgm.

  • lena.png, a PNG version.

  • lena_noisy.pgm, a "noisy" version of the lena image.

  • lena_noisy.png, a PNG version.

  • milking.pgm, a cow being milked.

  • milking.png, a PNG version.

  • mona_lisa.pgm, the Mona Lisa.

  • mona_lisa.png, a PNG version.

  • pbmlib.pgm, a file created by PBMLIB.

  • pbmlib.png, a PNG version.

  • pepper.pgm, a picture of peppers.

  • pepper.png, a PNG version.

  • roi_14.pgm, a 507 wide by 505 high image an MRI, the 14th in a sequence.11

  • roi_14.png, a PNG image.

  • snap.pgm, a snapshot of a mother and child.

  • snap.png, a PNG version.

  • surf.pgm, a beach picture.

  • surf.png, a PNG image.


  • PGMA is a data directory which contains examples of the ASCII PGM (Portable Gray Map) file format. It is a simple grayscale image description. The definition is as follows: the typical file extension is ".pgm", but an extension of ".pnm" is also occasionally used.

  • A "magic number" for identifying the file type. An ASCII PGM file's magic number is the two characters "P2".

  • Whitespace (blanks, TABs, CRs, LFs).

  • A width, formatted as ASCII characters in decimal.

  • Whitespace.

  • A height, again in ASCII decimal.

  • Whitespace.

  • The maximum gray value, again in ASCII decimal.

  • Whitespace.

  • Width * height gray values, each in ASCII decimal, between 0 and the specified maximum value, separated by whitespace, starting at the top-left corner of the graymap, proceeding in normal English reading order. A value of 0 means black, and the maximum value means white.

Characters from a "#" to the next end-of-line are ignored (comments). No line should be longer than 70 characters.


P2 # feep.ascii.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


  • apollonian_gasket.ascii.pgm, a 600 wide by 600 high image of an Apollonian gasket.

  • apollonian_gasket.png, a PNG image.

  • baboon.ascii.pgm, a 512 wide by 512 high image of a baboon.

  • baboon.png, a PNG image.

  • balloons.ascii.pgm, a 640 wide by 480 high image of a couple, with balloons.

  • balloons.png, a PNG image.

  • balloons_noisy.ascii.pgm, a 640 wide by 480 high image of a couple, with balloons, after "salt and pepper" noise has been added.

  • balloons_noisy.png, a PNG image.

  • barbara.ascii.pgm, a 512 wide by 512 high image of a woman.

  • barbara.png, a PNG image.

  • body1.ascii.pgm, a 640 wide by 480 high image of a body scan.

  • body1.png, a PNG image.

  • body2.ascii.pgm, a 640 wide by 480 high image of a body scan.

  • body2.png, a PNG image.

  • body3.ascii.pgm, a 640 wide by 480 high image of a body scan.

  • body3.png, a PNG image.

  • brain_398.ascii.pgm, a 720 wide by 486 high image of a visualization of the optical system.

  • brain_398.png, a PNG image.

  • brain_492.ascii.pgm

  • brain_492.png, a PNG image.

  • brain_508.ascii.pgm

  • brain_508.png, a PNG image.

  • brain_604.ascii.pgm, a 720 wide by 486 high image of a visualization of the optical system.

  • brain_604.png, a PNG image.

  • casablanca.ascii.pgm, a still from the movie "Casablanca";

  • casablanca.png, a PNG version;

  • coins.ascii.pgm, a 300 wide by 246 high image of 6 nickels and 4 dimes.

  • coins.png, a PNG image.

  • columns.ascii.pgm, a 640 wide by 480 high image of a person standing by some columns;

  • columns.png, a PNG image.

  • dla.ascii.pgm, an 800 by 800 image of a structure created by diffusion-limited aggregation.

  • dla.png, a PNG version.

  • dragon.ascii.pgm, a 475 wide by 460 high image of a cartoon dragon.

  • dragon.png, a PNG image.

  • f14.ascii.pgm, a 640 wide by 480 high image of an F14 fighter jet.

  • f14.png, a PNG image.

  • feep.ascii.pgm, a 24 wide by 7 high image that displays "FEEP" in block letters.

  • feep.png, a PNG image.

  • foliage.ascii.pgm, a 480 wide by 640 high image of foliage.

  • foliage.png, a PNG image.

  • fractal_tree.ascii.pgm, a photograph of a tree suggesting a fractal structure.

  • fractal_tree.png, a PNG version.

  • galaxy.ascii.pgm, a 965 wide by 965 high image containing four pictures of the same galaxy at different wavelengths.

  • galaxy.png, a PNG image.

  • gator.ascii.pgm, a 633 wide by 621 high image of Junior the Alligator.

  • gator.png, a PNG image.

  • glassware_noisy.ascii.pgm, a 320 wide by 428 high image of glassware, spotted with "salt and pepper" noise.

  • glassware_noisy.png, a PNG image.

  • hands.ascii.pgm, a 640 wide by 480 high image of hands.

  • hands.png, a PNG image.

  • handsmat.ascii.pgm

  • handsmat.png, a PNG image.

  • lena.ascii.pgm a 512 wide by 512 high image.

  • lena.png, a PNG image.

  • marcie.ascii.pgm

  • marcie.png, a PNG image.

  • mona_lisa.ascii.pgm, a 250 wide by 360 high image of the Mona Lisa.

  • mona_lisa.png, a PNG image.

  • mother_daughter.ascii.pgm, a snapshot of a mother and daughter;

  • mother_daughter.png, a PNG version;

  • mountain.ascii.pgm, a 640 wide by 480 high image of a mountain.

  • mountain.png, a PNG image.

  • pbmlib.ascii.pgm, a 600x200 image created by PBMLIB.

  • pbmlib.png, a PNG image.

  • pepper.ascii.pgm, a 256 wide by 256 high image of some peppers.

  • pepper.png, a PNG image.

  • roi_14.ascii.pgm, a 507 wide by 505 high image an MRI, the 14th in a sequence.11

  • roi_14.png, a PNG image.

  • saturn.ascii.pgm

  • saturn.png, a PNG image.

  • screws.ascii.pgm

  • screws.png, a PNG image.

  • snap.ascii.pgm, a 295 wide by 400 high snapshot of a mother and child.

  • snap.png, a PNG image.

  • surf.ascii.pgm, a 640 wide by 480 high beach picture.

  • surf.png, a PNG image.

  • totem.ascii.pgm a 640 wide by 480 high image of a totem pole.

  • totem.png, a PNG image.

  • tracks.ascii.pgm, a 300 wide by 200 high image that looks like tracks.

  • tracks.png, a PNG image.

  • venus1.ascii.pgm, a 640 wide by 480 high photo image from the surface of Venus.

  • venus1.png, a PNG image.

  • venus2.ascii.pgm a 640 wide by 480 high photo image from the surface of Venus.

  • venus2.png, a PNG image.

  • x31_f18.ascii.pgm, a 640 wide by 480 high image of X31 and F18 aircraft.

  • x31_f18.png, a PNG image.


This lab we will be writing programs that manipulate images. We will be using a format called PGM (.pgm), that is verysimple. It represents an image in a text file in which eachpixel is represented by a number from 0 and 255. 0 is black,and 255 is white. The first line of the file is P2. The second line is the width-space-height in pixels. The third is 255. From then on we get pixels values (a single number per pixel). So, for example:P24 42550 255 0 00 0 255 00 0 0 255128 128 128 128


Note: even thoughthis particular part doesn't require it, I insist that youread the file completely and store it in a 2Darray, and only then create the posterized version.Here's an example:run of programcat.pgmpostercat.pgm/$ ./part1filename: cat.pgmoutput filename: postercat.pgmThe rule for posterization I used was this: If a pixel in theoriginal has value > 128, in the new image that pixel hasvalue 255. Otherwise, it has value 0. 2ff7e9595c


0 views0 comments

Recent Posts

See All

ความคิดเห็น


bottom of page