ppmshadow
Create a drop shadow for an image
TLDR
Add simulated shadows to a PPM image
[b]lur the image by the specified number of pixels
Specify the displacement of the simulated light source to the left and the top of the image
SYNOPSIS
ppmshadow [-x xoffset] [-y yoffset] [-color color] [-opacity opacity] [-pm] [-threshold threshold] [-fade radius] [-background color] [-fadecolor color] [-nofade] [input_file]
PARAMETERS
-x xoffset
Specifies the horizontal offset of the shadow in pixels. Positive values move the shadow to the right.
-y yoffset
Specifies the vertical offset of the shadow in pixels. Positive values move the shadow downwards.
-color color
Sets the color of the shadow. Can be a color name (e.g., 'black', 'grey') or a hex triplet (e.g., '#RRGGBB'). Default is black.
-opacity opacity
Defines the transparency of the shadow as a floating-point value from 0.0 (fully transparent) to 1.0 (fully opaque). Default is 1.0.
-pm
Enables permuted shadow for better translucency, especially when the shadow's color differs significantly from the background.
-threshold threshold
An integer value (0-255) used to distinguish the object from the background. Pixels darker than this threshold are considered part of the object that casts the shadow. Default is 127.
-fade radius
Applies a fade effect to the shadow, causing it to become more transparent at its edges over a specified radius in pixels. Default is 0 (no fade).
-background color
Specifies the background color used for areas not considered part of the object. This is important for objects extracted based on the threshold.
-fadecolor color
Sets the color the shadow fades to when the -fade option is used. Default is the shadow color.
-nofade
Explicitly disables any shadow fading, even if a fade radius is implied or set by other options.
DESCRIPTION
ppmshadow is a command-line utility from the Netpbm project designed to add a simulated shadow effect to an input PPM (Portable Pixmap) image. This tool enhances visual depth, making objects within the image appear to float or stand out. It provides various options to customize the shadow's appearance, including its horizontal and vertical offset, color, opacity, and fade characteristics. The command determines which parts of the image constitute the 'object' (and thus cast a shadow) versus the 'background' based on pixel intensity relative to a threshold. Typically, ppmshadow reads an image from standard input or a specified file and writes the modified image to standard output, making it highly suitable for use in Unix-like pipelines for automated image processing workflows.
CAVEATS
ppmshadow operates solely on Netpbm (PPM) images, which do not inherently support alpha channels for transparency. Its method of separating foreground from background relies on a simple color threshold, which may not always produce ideal results for complex images with subtle color variations or existing transparency. The shadow effect is a basic simulation and not a physically accurate rendering of light and shadow.
TYPICAL USAGE IN PIPELINES
Like most Netpbm tools, ppmshadow is designed to integrate seamlessly into shell pipelines. An image can be piped from another Netpbm utility (e.g., jpegtopnm) into ppmshadow, and its output can then be piped to another utility (e.g., pnmtojpeg) to convert it to a different format or perform further manipulations.
Example: jpegtopnm image.jpg | ppmshadow -x 5 -y 5 -color black -opacity 0.6 -fade 3 | pnmtojpeg > shadow_image.jpg
This command converts a JPEG to PPM, adds a black, semi-transparent, fading shadow, and converts it back to JPEG.
HISTORY
ppmshadow is a component of the comprehensive Netpbm package, a suite of graphics utilities that traces its origins back to the Pbmplus package, initially developed by Jef Poskanzer in the late 1980s. Its inclusion reflects the Unix philosophy of providing small, specialized tools that can be chained together for more complex tasks. The command’s development has focused on maintaining compatibility and robustness within the Netpbm ecosystem, providing a reliable command-line option for adding basic graphical effects without requiring complex graphical user interfaces.