img-ppm(n)

πŸ“¦
version 2.1.1 Β· 2 versions
, in fedora 43, fedora 44, nixos 26.05, nixpkgs unstable

πŸŽ€ NAME πŸŽ€

okay so bestie, this page is all about img-ppm β€” aka the Portable pixmap format (ppm) πŸ’– it's the thing that makes Tk's photo images understand PPM and PGM files, and it's genuinely so useful, no cap.


✨ SYNOPSIS ✨

package require img::ppm ?2.1?

🌸 DESCRIPTION 🌸

package require img::ppm

So here's the vibe: like every single package in Img, this one does not hand you a bunch of shiny new commands. Nope. What it does instead is extend the Tk command image that you already have, so that it can handle files holding raster images in the Portable pixmap format (ppm). More specifically, img::ppm extends Tk's photo [https://www.tcl.tk/man/tcl9.0/TkCmd/photo.html] image type. 🫢

The name of the new format handler is ppm. And this handler? It brings additional configuration options. Peep the Options section below for the full tea. β˜•

All of that means that in a call like image create photo ?name? ?options?:

  1. Image data in ppm format (options -data and -file) is detected automatically. ✨
  2. The format name ppm is recognized by the option -format.

And on top of that, the value of option -format is treated as a list, and it may contain any of the special options listed in the Options section. So you can stack them in there, bestie. πŸ’…

The package img::ppm is a sub-package of Img. You can load it as a part of the complete Img support, via package require Img, or you can just grab it on its own, via package require img::ppm. Either way, she's ready. πŸ¦‹


🌈 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.

Here's the whole read/write situation, and yes it's giving very much a chart πŸ“Š β€” look at her:

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    |
πŸ’€ not the PGM's being read-only on the write side. she reads, she does not write. iconic behaviour honestly.

πŸ’… OPTIONS πŸ’…

The handler provides the following options:

  • -verbose bool β€” this one works for reading AND writing. Available since version 1.4.0. If you set it to true, extra info about the image you read or wrote gets printed to stdout. Default is false.
  • -scanorder string β€” reading only, bestie. Available since version 1.4.0. This specifies the scanline order of the input image. Possible values: TopDown or BottomUp. Default is TopDown.
  • -min double β€” reading only. Available since version 1.4.0. Specifies the minimum pixel value to be used for mapping 16-bit input data to 8-bit image values. If it's not specified, or if it's negative, then it's the minimum value found in the image data. 🫢
  • -max float β€” reading only. Available since version 1.4.0. Specifies the maximum pixel value to be used for mapping 16-bit input data to 8-bit image values. If it's not specified, or if it's negative, then it's the maximum value found in the image data. πŸ’–
  • -gamma double β€” reading only. Available since version 1.4.0. Specifies a gamma correction to be applied when mapping 16-bit input data to 8-bit image values. Default is 1.0.
  • -ascii bool β€” writing only, so don't come at her trying to use it for reads. Available since version 1.4.0. If set 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). πŸŽ€

πŸ”₯ 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

(go read them all, the whole friend group is serving 🫢)


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 β€” she's been serving since way back (the copyright line goes all the way from 1995 through 2025, we love a legacy icon) and she's still out here making your PPM's work. periodt. πŸ’…βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from
  • fedora 43: tkimg 2.1.1-1.fc43 Β· TCL AND libtiff AND HPND-Pbmplus AND URT-RLE AND IJG AND libpng-2.0 AND libpng-1.6.35 AND (BSD-4-Clause OR GPL-2.0-or-later) AND BSD-4-Clause AND MIT AND Zlib
  • fedora 43: tkimg 2.1.1-1.fc43 Β· TCL AND libtiff AND HPND-Pbmplus AND URT-RLE AND IJG AND libpng-2.0 AND libpng-1.6.35 AND (BSD-4-Clause OR GPL-2.0-or-later) AND BSD-4-Clause AND MIT AND Zlib
  • fedora 44: tkimg 2.1.0-2.fc44 Β· TCL AND libtiff AND HPND-Pbmplus AND URT-RLE AND IJG AND libpng-2.0 AND libpng-1.6.35 AND (BSD-4-Clause OR GPL-2.0-or-later) AND BSD-4-Clause AND MIT AND Zlib
  • fedora 44: tkimg 2.1.0-2.fc44 Β· TCL AND libtiff AND HPND-Pbmplus AND URT-RLE AND IJG AND libpng-2.0 AND libpng-1.6.35 AND (BSD-4-Clause OR GPL-2.0-or-later) AND BSD-4-Clause AND MIT AND Zlib
  • fedora 44: tkimg 2.1.1-1.fc44 Β· TCL AND libtiff AND HPND-Pbmplus AND URT-RLE AND IJG AND libpng-2.0 AND libpng-1.6.35 AND (BSD-4-Clause OR GPL-2.0-or-later) AND BSD-4-Clause AND MIT AND Zlib
  • fedora 44: tkimg 2.1.1-1.fc44 Β· TCL AND libtiff AND HPND-Pbmplus AND URT-RLE AND IJG AND libpng-2.0 AND libpng-1.6.35 AND (BSD-4-Clause OR GPL-2.0-or-later) AND BSD-4-Clause AND MIT AND Zlib
  • nixos 26.05: tkimg 2.1.1
  • nixpkgs unstable: tkimg 2.1.1
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms