Bitmap File Format Conversion: any2ppm

The any2ppm program converts bitmap files from the Portable Pixmap (PPM), Windows BMP, and GIF formats into the Portable Pixmap P3 (text) or P6 (binary) formats, or the uncompressed 24 bits-per-pixel BMP binary format. With Tcl/Tk 8.6 or later the Portable Network Graphics (PNG) format is also supported. Additional formats may be available if the Tcl/Tk Img package is installed on your system. (Note: OOMMF support for BMP requires Tk 8.0 or later.)

Launching
The any2ppm launch command is:

tclsh oommf.tcl any2ppm [standard options] [-f] [-format fmt] \
   [-noinfo] [-o outfile] [infile ...]
where
-f
Force output. If the -o option is not specified, then the output filename is automatically generated by stripping the extension, if any, off of each input filename, and appending a format-specific extension (e.g., .ppm). If -f is specified, that generated filename is used for the output filename. If -f is not specified, then a check is made to see if the generated filename already exists. If so, then an additional “-000” or “-001” ... suffix is appended to create an unused filename. If the input is coming from stdin, i.e., there is no input filename, then the default output is to stdout.
-format fmt
Output file format. The default is PPM or P3 which is the Portable Pixmap P3 (text) format; use P6 to get the binary PPM P6 output. Setting fmt to BMP will produce files in the uncompressed Windows BMP 24 bits-per-pixel format. Under Tcl/Tk 8.6 and later the Portable Network Graphics format can be selected by setting fmt to PNG. If the Tcl/Tk Img package is installed, then additional formats, such as PNG (for pre-Tcl/Tk 8.6), JPEG and TIFF, will be available. The default output file extension depends on the format selected, e.g., .ppm for PPM files and .bmp for BMP files.
-noinfo
Suppress writing of progress information to stderr.
-o outfile
Write output to outfile; use “-” to pipe output to stdout. Note that if outfile is specified, then all output will go to this one file; in this case it is unlikely that one wants to specify more than one input file.
infile ...
List of input files to process. If none, or if an infile is the empty string, then read from stdin.
Note: If the output is to stdout, and the selected output format is anything other than PPM, then the output is first written to a temporary file before being copied to stdout. Under normal operation the temporary file will be automatically deleted, but this is not guaranteed if the program terminates abnormally. Tk Requirement: any2ppm uses the Tk image command in its processing. This requires that Tk be properly initialized, which in particular means that a valid display must be available. This is not a problem on Windows, where a desktop is always present, but on Unix this means that an X server must be running. The Xvfb virtual framebuffer can be used if desired. (Xvfb is an X server distributed with X11R6 that requires no display hardware or physical input devices.)


OOMMF Documentation Team
September 27, 2024