ppmtopj
Convert PPM image files to JPEG
TLDR
Convert a PPM file to an HP PaintJet file
Move the image in the x and y direction
Explicitly specify a gamma value
SYNOPSIS
ppmtopj [options] [ppmfile]
PARAMETERS
ppmfile
The path to the input PPM image file. If not specified, ppmtopj reads the PPM data from standard input.
-resolution res
Sets the desired output resolution in dots per inch (dpi). Common values include 300, 600, or 1200. This must match a resolution supported by the target printer.
-rle
Enables Run-Length Encoding (RLE) compression for the PCL 5 output. This can reduce file size and transmission time to the printer.
-norle
Disables Run-Length Encoding (RLE) compression for the PCL 5 output. Output will be uncompressed raster data.
-forcebw
Forces the output to be monochrome (black and white). Also accessible via -monochrome or -gray.
-color1
Outputs 1-bit color (monochrome) PCL 5 data. This is equivalent to -forcebw.
-color4
Outputs 4-bit color (16 colors) PCL 5 data.
-color8
Outputs 8-bit color (256 colors) PCL 5 data. This is typically the highest color depth supported for PCL 5 images.
-xpos x
Sets the horizontal position of the image origin on the page in dots.
-ypos y
Sets the vertical position of the image origin on the page in dots.
-width w
Scales the image to the specified width in dots. The height is scaled proportionally unless -height is also used.
-height h
Scales the image to the specified height in dots. The width is scaled proportionally unless -width is also used.
-magnification factor
Applies a magnification factor to the image. For example, -magnification 2 would double the image size.
-center
Centers the image horizontally and vertically on the page.
-landscape
Sets the page orientation to landscape. The image will be rotated appropriately.
-portrait
Sets the page orientation to portrait (the default). The image will be oriented for portrait printing.
-nocompress
Prevents any compression of the image data in the PCL 5 output. This is equivalent to -norle.
-nobatch
Disables batch mode, which can sometimes improve compatibility with older printers.
-nodither
Disables dithering for color reduction. When converting to a lower color depth, this might result in banding or loss of detail.
-gamma val
Applies gamma correction to the image before conversion. val is a floating-point number (e.g., 0.5, 2.0).
-brightness val
Adjusts the brightness of the image before conversion. val is a floating-point number.
-contrast val
Adjusts the contrast of the image before conversion. val is a floating-point number.
-deviceready
Optimizes the PCL 5 output for faster processing on the printer device. This might involve using specific PCL 5 features.
-verbose
Enables verbose output, showing progress and detailed information during conversion.
-help
Displays a brief help message and exits.
-version
Displays the version information of ppmtopj and exits.
DESCRIPTION
ppmtopj is a command-line utility from the Netpbm toolkit designed to convert Portable Pixmap (PPM) image files into the Hewlett-Packard Printer Command Language (PCL) 5 format.
PCL 5 is a printer control language primarily used by HP LaserJet printers and compatible devices. This conversion allows users to directly print PPM images on these printers by sending the generated PCL 5 output to the printer.
The tool reads a PPM image from standard input (or a specified file) and writes the PCL 5 data to standard output. It supports various options to control the output, including resolution, color depth (monochrome, 4-bit, 8-bit color), image positioning, scaling, and compression. ppmtopj is particularly useful in scripting and automated workflows where images need to be prepared for direct printing without a graphical interface.
CAVEATS
The output of ppmtopj is specifically PCL 5, which is understood primarily by HP LaserJet printers and compatible devices. It is not a universal image format.
The effective resolution and color depth depend on the capabilities of the target printer. For optimal results, ensure the chosen -resolution and color depth options are supported by your printer.
Some advanced PCL 5 features might not be fully utilized or supported by ppmtopj, focusing instead on core raster image printing.
INPUT AND OUTPUT
ppmtopj typically reads PPM (Portable Pixmap) image data from standard input (stdin) if no input file is specified. The resulting PCL 5 (Printer Command Language) data is written to standard output (stdout). This allows for flexible piping with other commands, such as cat or lp/lpr.
USAGE EXAMPLES
To convert image.ppm to 300 DPI, 8-bit color PCL 5 and save it to a file:ppmtopj -resolution 300 -color8 image.ppm > printer.pcl
To convert image.ppm to 600 DPI monochrome PCL 5 and send it directly to a printer via lp:cat image.ppm | ppmtopj -resolution 600 -forcebw | lp -d your_printer_queue
HISTORY
ppmtopj is part of the Netpbm project, a comprehensive toolkit for manipulating graphic images. Netpbm evolved from the original Pbmplus package, created by Jef Poskanzer in the late 1980s. The philosophy behind Netpbm tools is to provide simple, pipeable utilities for basic image transformations. ppmtopj was developed to address the need for direct conversion of portable pixmap format images into a format suitable for widely available HP LaserJet printers, enabling command-line driven printing workflows on Unix-like systems.