Skip to content

A command-line utility for converting images to Netpbm.

License

Notifications You must be signed in to change notification settings

SilasBerger/netpbm-converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Netpbm Converter

A command-line utility for converting images to Netpbm.

Usage

Initial setup

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Converting an image

Command format: convert.py <magic_number> <input_path>

Usage examples:

python convert.py P1 ./example_data/images/cat.jpg # creates ./example_data/images/cat.pbm (black & white)
python convert.py P2 ./example_data/images/dog.jpg # creates ./example_data/images/dog.pgm (grayscale)
python convert.py P3 ./example_data/images/capibara.jpg # creates ./example_data/images/capibara.ppm (full RGB)

Features

Supported Netpbm formats

Type Magic number Extension Colors
Portable BitMap P1 (ASCII) .pbm 0-1 (black & white)
Portable GrayMap P2 (ASCII) .pgm 0-255 (grayscale)
Portable PixMap P3 (ASCII) .ppm 0-255 per RGB channel

Limitations

  • No support for magic numbers P4 - P6 (raw binary)
  • No support for multibyte GrayMap

Useful links

Image sources