img-raw(n)
π img-raw β bestie's guide to the Raw data format (raw) π
okay so. you found the img-raw manual page, in the Img section, and honestly? you're about to have a great time. let's get into it π«Ά
β¨ NAME β¨
img-raw β Raw data format (raw). that's it, that's the name, no notes π
πΈ SYNOPSIS πΈ
package require img::raw ?2.1?
π¦ DESCRIPTION π¦
so first things first, bestie:
package require img::raw
Like all the packages in Img, this one does not hand you brand new commands. no new toys. instead it extends the Tk command image that you already know and love, so that it supports files holding raster images in the Raw data format (raw). and more specifically, img::raw extends Tk's photo image type (yeah, [that one](https://www.tcl.tk/man/tcl9.0/TkCmd/photo.html), the iconic one π).
The name of the new format handler is raw. This handler brings new extra configuration options, and if you want the full breakdown, go look at the Options section, it's all laid out there.
so all of that means that in a call like
image create photo ?name? ?options?
here's the tea:
- Image data in raw format (the options
-dataand-file) is detected automatically. no cap. - The format name
rawis recognized by the option-format.
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 sneak them in right there.
heads up, bestie π β the packageimg::rawis not loaded when you do apackage require Img. you have to load it explicitly, withpackage require img::raw. she does not come as a freebie.
π SUPPORTED TYPES π
This format handler supports the following image types for reading:
Grayscale (1 channel), Grayscale-Alpha (2 channels), Truecolor (3 channels) and Truecolor-Alpha (4 channels) images using the following data types:
- 64-bit floating point values
- 32-bit floating point values
- 32-bit unsigned integer values
- 16-bit unsigned integer values
- 8-bit unsigned integer values
This format handler supports the following image types for writing:
Truecolor (3 channels) and Truecolor-Alpha (4 channels) images using 8-bit integer values.
There are two supported file format versions:
One containing the raw binary data only, and the other one with a 7 line ASCII header of the following form:
Magic=RAW File format identifier. Fixed value.
Width=128 Image width in pixels.
Height=128 Image height in pixels.
NumChan=1 Possible values: 1, 2, 3 or 4.
ByteOrder=Intel Possible values: "Intel" or "Motorola".
ScanOrder=TopDown Possible values: "TopDown" or "BottomUp".
PixelType=byte Possible values: "double", "float", "int", "short" or "byte".
For a more detailed description of the file format versions and functions to read the data with Matlab or GNU Octave, see the PAWT File Format Documentation (link: https://www.tcl3d.org/pawt/download/PawtFileFormats.pdf).
π OPTIONS π
The handler provides the following options, and yes, we're doing all of them, every single one, because we don't skip π
-verbose boolβ supported for reading and writing. Available since version1.4.0. If you set it to true, extra info about the read or written image gets printed tostdout. Default isfalse.-useheader boolβ supported for reading and writing. Available since version1.4.0. If set to true, use the file header information for reading and writing. Default istrue.-width intβ supported for reading image data without header only. Available since version1.4.0. Specify the width of the input image. Default is128.-height intβ supported for reading image data without header only. Available since version1.4.0. Specify the height of the input image. Default is128.-nchan intβ supported for reading image data without header. Available since version1.4.0. Specify the number of channels of the input image. Default is1.-numchan intβ supported for reading image data without header. Available since version2.1.0. Specify the number of channels of the input image. Default is1.-withalpha boolβ supported for reading and writing. Available since version2.1.0. If set to false, an alpha channel is ignored during reading or writing. Default istrue.-byteorder stringβ supported for reading image data without header only. Available since version1.4.0. Specify the byteorder of the input image data. Possible values:IntelorMotorola. Default is assuming the same byteorder as that of the host computer.-scanorder stringβ supported for reading and writing image data without header. Available since version1.4.0. Specify the scanline order of the input image. Possible values:TopDownorBottomUp. Default isTopDown.-pixeltype stringβ supported for reading image data without header only. Available since version1.4.0. Specify the type of the pixel values. Possible values:double,float,int,shortorbyte. Default isbyte.
real talk: RAW files are always written in byte pixel format. periodt.
-skipbytes intβ supported for reading image data without header only. Available since version1.4.14. Specify the number of bytes to skip before reading image data. Default is0.-map stringβ supported for reading only. Available since version1.4.7. Specify the mode when mapping the 16, 32 or 64-bit values to 8-bit grayscale values for displaying. Possible values:none,minmax,agc. Default mode isminmax.- If mode is set to
none, no mapping of input values is done. Use this mode if the input values are already in the range of0 ..255. When using modenone, no information about the minimum and maximum input values is gathered during reading, and therefore no verbose output is printed. On the other hand, reading the input data is faster. slay πβοΈ - Mode
minmaxmaps the minimum and maximum input data to 256 grayscale values. - Mode
agcapplies an automatic gain control algorithmn to the input values. Currently implemented for 1-channel 32-bit float images only.
- If mode is set to
-min doubleβ supported for reading only. Available since version1.4.0. Specify the minimum pixel value to be used for mapping the input data to 8-bit image values. If not specified or negative, the minimum value found in the image data. Valid for mapping mode:minmax.-max doubleβ supported for reading only. Available since version1.4.0. Specify the maximum pixel value to be used for mapping the input data to 8-bit image values. If not specified or negative, the maximum value found in the image data. Valid for mapping mode:minmax.-gamma doubleβ supported for reading only. Available since version1.4.0. Specify a gamma correction to be applied when mapping the input data to 8-bit image values. Default is1.0. Valid for mapping modes:minmaxandagc.-saturation doubleβ supported for reading only. Available since version1.4.7. The supplied value specifies the saturation value, i.e. all input values greater than the saturation value are mapped to white. If not specified or negative, do not use saturation. Valid for mapping mode:agc.-cutoff doubleβ supported for reading only. Available since version1.4.7. The supplied value specifies the cut-off value in percent. The cut-off value specifies, how many pixels from the lower and upper part of the histogram are not considered for mapping. This option is useful if there are some hot or cold spots in the image. Default is3.0. Valid for mapping mode:agc.
π SEE ALSO π
go read these too, they're all part of the family:
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
π COPYRIGHT π
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-raw, version 2.1, from the img-raw(n) manual β go forth and read some raw pixels, you absolute icon π
π¦ 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
- 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>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms