I developed a Netpbm image editor during my first year at university, which did not rely on the predefined libnetpbm library. Instead, I used only basic C libraries to implement the program. The application receives commands from the command-line, and can perform a variety of operations on PPM and PGM images, both as plain text (ASCII) and binary files.
TYPE | ASCII | BINARY | COLORS |
---|---|---|---|
GRAYSCALE | P2 | P5 | 0 - 255 (black & white shade) |
RGB | P3 | P6 | 16.777.216 (RGB) |
These are commands typed by the user
LOAD test_file
Loaded test_file
SELECT 0 1 8 10
Selected 0 1 8 10
CROP
Image cropped
SAVE my_binary_file
Saved my_binary_file
LOAD non_existent_file
Failed to load non_existent_file
LOAD color_file
Loaded color_file
GRAYSCALE
Grayscale filter applied
SEPIA
Sepia filter not available
SAVE my_plain_file ascii
Saved my_plain_file
EXIT
To generate your own PNM and PGM files, use the "convert" utility that converts png / jpeg / jpg files to these formats:
• Setup:
$ sudo apt update
$ sudo apt-get install build-essential
$ sudo apt-get install imagemagick
• Documentation: man convert
• Examples:
convert foo.jpg foo.ppm (transforms foo.jpg în foo.ppm, binary RGB)
convert foo.jpg foo.pgm (transforms foo.jpg în foo.pgm, binary grayscale)
convert foo.jpg -compress None foo.ppm (transforms foo.jpg în foo.ppm, ASCII RGB)
convert foo.jpg -compress None foo.pgm transforms foo.jpg în foo.ppm, ASCII grayscale)