img-ppm(3tk)

πŸ“¦
version 2.1.1 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– img-ppm πŸ’–

okay bestie, so this is the manual for img-ppm, part of the Img crew β€” it's the handler for the Portable pixmap format aka ppm. version 2.1, manual section 3tk. let's get into it πŸ¦‹


✨ NAME ✨

img-ppm β€” Portable pixmap format (ppm). that's the whole vibe. πŸŽ€


✨ SYNOPSIS ✨

package require img::ppm ?2.1?

yes the ?2.1? is optional, she's flexible like that πŸ’…


✨ DESCRIPTION ✨

so, first thing, no cap:

package require img::ppm

like literally every package in Img, this one does not hand you brand-new commands. it's not giving "new command" energy, it's giving "glow-up the command you already have" energy ✨ β€” specifically it extends the existing Tk image command so that it can handle files with raster images in the Portable pixmap format (ppm). more precisely, img::ppm extends Tk's photo image type (https://www.tcl.tk/man/tcl9.0/TkCmd/photo.html).

the new format handler's name is ppm. this handler serves up some extra configuration options. go look at the Options section for the full tea, iykyk.

all of the above means that when you make a call like

image create photo ?name? ?options?

then:

  1. image data in ppm format (the options -data and -file) gets detected automatically β€” no manual effort, she just knows πŸ”₯
  2. the format name ppm is recognized by the option -format.

plus, the value of the option -format is treated as a list, and that list may contain any of the special options listed in the Options section. so you can stack them in there, periodt.

and one more thing: the package img::ppm is a sub-package of Img. you can load it as part of the complete Img support via package require Img, or on its own via package require img::ppm. your choice, both slay πŸ’–


🌈 SUPPORTED TYPES 🌈

this handler supports the PPM (Truecolor) and PGM (Grayscale) image formats. and there are two types of PPM/PGM files: Binary and ASCII. the values stored in PPM/PGM files can be unsigned 8-bit or unsigned 16-bit values.

  • Grayscale (PGM): 8-bit and 16-bit, 1 channel per pixel. πŸ“
  • Truecolor (PPM): 8-bit and 16-bit, 3 channels per pixel. πŸ‘‘

and here's the whole read/write situation, straight up:

Image             |     Read      |     Write     |
type              | -file | -data | -file | -data |
---------------------------------------------------
PGM  8-bit ASCII  | Yes   | Yes   | No    | No    |
PGM  8-bit BINARY | Yes   | Yes   | No    | No    |
PGM 16-bit ASCII  | Yes   | Yes   | No    | No    |
PGM 16-bit BINARY | Yes   | Yes   | No    | No    |
PPM  8-bit ASCII  | Yes   | Yes   | Yes   | Yes   |
PPM  8-bit BINARY | Yes   | Yes   | Yes   | Yes   |
PPM 16-bit ASCII  | Yes   | Yes   | No    | No    |
PPM 16-bit BINARY | Yes   | Yes   | No    | No    |

so like, reading? she eats everything. writing? only the 8-bit PPM girls get to go out 😭 note that the ASCII/BINARY 16-bit PPM and all the PGM writing columns are a hard No.


πŸŽ€ OPTIONS πŸŽ€

the handler provides the following options:

  • -verbose bool β€” supported for reading and writing. available since version 1.4.0. if you set it to true, extra info about the read or written image gets printed to stdout. default is false.
  • -scanorder string β€” supported for reading only. available since version 1.4.0. specify the scanline order of the input image. possible values: TopDown or BottomUp. default is TopDown.
  • -min double β€” supported for reading only. available since version 1.4.0. specify the minimum pixel value used for mapping 16-bit input data to 8-bit image values. if it's not specified, or if it's negative, you get the minimum value found in the image data.
  • -max float β€” supported for reading only. available since version 1.4.0. specify the maximum pixel value used for mapping 16-bit input data to 8-bit image values. if it's not specified, or if it's negative, you get the maximum value found in the image data.
  • -gamma double β€” supported for reading only. available since version 1.4.0. specify a gamma correction to be applied when mapping 16-bit input data to 8-bit image values. default is 1.0.
  • -ascii bool β€” supported for writing only. available since version 1.4.0. if you set it to true, the file is written in PPM 8-bit ASCII format (P3). default is false, i.e. write in PPM 8-bit binary format (P6).
lowkey important: -scanorder, -min, -max and -gamma are read-side only, and -ascii is write-side only. don't come for her when they don't do anything on the other side, she told you upfront 🫢

🌸 SEE ALSO 🌸

img, img-bmp, img-dted, img-flir, img-gif, img-ico, img-jpeg, img-pcx, img-pixmap, img-png, img-ppm, img-ps, img-raw, img-sgi, img-sun, img-tga, img-tiff, img-window, img-xbm, img-xpm

the whole friendship circle, we love a supportive squad πŸ’œ


Copyright (c) 1995-2025 Jan Nijtmans <nijtmans@users.sourceforge.net>

Copyright (c) 2002-2025 Andreas Kupries <andreas_kupries@users.sourceforge.net>

Copyright (c) 2003-2025 Paul Obermeier <obermeier@users.sourceforge.net>


and that's the whole page bestie πŸ’– this was img-ppm version 2.1, from the img-ppm(3tk) manual, dated 2.1. stan the maintainers, they've been holding it down since 1995 🫢✨ bye!! πŸŒˆπŸŽ€πŸ’…

πŸ“¦ where this page comes from