pamdice
PAM password strength testing tool
TLDR
Slice a Netpbm image such that the resulting tiles have the specified height and width
Make the produced pieces overlap by the specified amount horizontally and vertically
SYNOPSIS
pamdice {-width=<width> -height=<height> | -rows=<rows> -cols=<cols>} [-xcoord=<x>] [-ycoord=<y>] [-outfileprefix=<prefix>] [-nullpad | -nonullpad] [-autoborder] [-verbose] [pamfile]
PARAMETERS
-width=<width>
Mandatory (with -height). Specifies the width of each diced image tile in pixels.
-height=<height>
Mandatory (with -width). Specifies the height of each diced image tile in pixels.
-rows=<rows>
Mandatory (with -cols). Specifies the number of rows (vertical cuts) to make. Mutually exclusive with -width/-height.
-cols=<cols>
Mandatory (with -rows). Specifies the number of columns (horizontal cuts) to make. Mutually exclusive with -width/-height.
-xcoord=<x>
Specifies the X-coordinate (horizontal) of the top-left corner of the first output image. Default is 0.
-ycoord=<y>
Specifies the Y-coordinate (vertical) of the top-left corner of the first output image. Default is 0.
-outfileprefix=<prefix>
Specifies a prefix for the output filenames. The default is 'dice'.
-nullpad
If image dimensions are not exact multiples of tile dimensions, output smaller tiles for the remainder. Mutually exclusive with -nonullpad.
-nonullpad
(Default) If image dimensions are not exact multiples, output tiles are padded with black to the specified size. Mutually exclusive with -nullpad.
-autoborder
Finds a common border around each tile to use as a cut point, rather than exact pixel dimensions. Useful for scanned images with margins.
-verbose
Provides verbose output about the processing steps.
pamfile
The input image file. If omitted, pamdice reads from standard input.
DESCRIPTION
pamdice is a Netpbm program that divides a single PAM or PNM image into a grid of smaller images. You specify the dimensions of the smaller images (width, height) or the number of rows and columns for the grid. The command outputs these smaller images, typically named with a sequential numeric suffix, to individual files. This is particularly useful for tasks such as preparing image sprites for web development, breaking down large scanned documents into individual pages, or segmenting satellite imagery for further processing.
It supports various input formats readable by Netpbm and outputs in the PAM format by default, which can then be converted to other formats using other Netpbm tools like pamtopng or pamtojpeg. pamdice can automatically calculate the number of output images based on the input image's size and the specified tile dimensions, handling any leftover pixels by either padding or discarding them, depending on the options used.
CAVEATS
pamdice works best with PAM or PNM format images. While it can read other formats via Netpbm's automatic conversion, performance is optimal with native formats.
The -autoborder option relies on finding a consistent border, which may not work effectively on all types of images, especially those without clear, uniform margins.
Using -nullpad can result in output images of varying sizes, which might require additional processing or careful handling by subsequent applications.
INPUT/OUTPUT
pamdice reads a single PAM/PNM image from a file or standard input. It writes multiple PAM images to files, named using the specified prefix and a sequential number (e.g., dice0001.pam, dice0002.pam).
DIMENSION SPECIFICATION
You must specify either -width and -height (for fixed tile dimensions) or -rows and -cols (for a fixed number of divisions). You cannot mix these two approaches.
HISTORY
pamdice is part of the Netpbm project, a toolkit for graphic file format conversion and image manipulation. Netpbm has a long history, originating from the pbmplus package created by Jef Poskanzer in the late 1980s. pamdice itself was introduced as part of the transition to the PAM (Portable Arbitrary Map) format, which generalized the existing PBM (Portable BitMap), PGM (Portable GrayMap), and PPM (Portable PixMap) formats. Its development reflects the ongoing need for efficient command-line image processing tools that can be chained together in shell scripts.