LinuxCommandLibrary

pnmtile

Combine multiple images into a larger tiled image

TLDR

Replicate an image to fill an area of the specified dimensions

$ pnmtile [width] [height] [path/to/input.pnm] > [path/to/output.pnm]
copy

SYNOPSIS

pnmtile [-width=] [-height=] [input_image [canvas_image]]

PARAMETERS

-width=cols
    Specifies the width of the output image in pixels. If not provided, and no canvas_image is given, the output width cannot be determined. If a canvas_image is provided, this defaults to the width of the canvas_image.

-height=rows
    Specifies the height of the output image in pixels. Similar to -width, if not provided and no canvas_image is given, the output height cannot be determined. If a canvas_image is provided, this defaults to the height of the canvas_image.

input_image
    The path to the image file that will be tiled. If omitted, pnmtile reads the image from standard input.

canvas_image
    (Optional) The path to a background image file onto which the input_image will be tiled. If specified, the output image will have the same dimensions as this canvas_image. If omitted, and -width and -height are not specified, pnmtile will not know the output dimensions and will produce an error.

DESCRIPTION

pnmtile is a utility from the Netpbm suite of graphics manipulation tools. It takes an input image and repeatedly copies it (tiles it) to fill a specified output size, or to fill the size of a second input image. This is particularly useful for creating background patterns, wallpapers, or repeating textures from a smaller source image. The tiling can be done without gaps, creating a seamless repetition of the source image. It reads PGM, PPM, or PBM format images as input and produces an image in the same format. If no output dimensions are specified via options or a canvas image, the command will fail.

CAVEATS

The command requires a way to determine the output dimensions (either via -width/-height options or by providing a canvas_image). Without this, it will fail. It expects Netpbm formats (PBM, PGM, PPM) as input; other formats need prior conversion. pnmtile performs simple tiling and does not offer options for spacing between tiles or starting offsets.

EXAMPLES

Here are some common ways to use pnmtile:

1. Tile an image to a specific size:
pnmtile -width=800 -height=600 small_tile.pnm > tiled_image.pnm
This command tiles 'small_tile.pnm' to create an 800x600 pixel image named 'tiled_image.pnm'.

2. Tile an image onto an existing background:
pnmtile tile.pnm background.pnm > patterned_background.pnm
Here, 'tile.pnm' is repeatedly placed over 'background.pnm'. The output image will have the same dimensions as 'background.pnm'.

3. Pipe input from another command:
jpegtopnm input.jpg | pnmtile -width=1024 -height=768 > tiled_output.pnm
This example converts a JPEG image to PNM format and then tiles it to a 1024x768 resolution.

HISTORY

pnmtile is part of the Netpbm package, which has a long history dating back to the pbmplus package created by Jef Poskanzer in 1988. Netpbm provides a fundamental set of tools for processing graphic images in various formats, emphasizing a pipeline approach where smaller, specialized tools are chained together. pnmtile serves its specific purpose within this philosophy, handling a common image manipulation task efficiently.

SEE ALSO

pnmcat(1), pnmcut(1), pnmscale(1), netpbm(1), convert(1)

Copied to clipboard