.TL Ppmshadow User Manual .SH 1 ppmshadow .LP Updated: 17 April 2005 .br Table Of Contents .SH 2 NAME .LP ppmshadow - add simulated shadows to a PPM image .SH 2 SYNOPSIS .LP \fBppmshadow\fR [\fB-b\fR \fIblur_size\fR] [\fB-k\fR] [\fB-t\fR] [\fB-x\fR \fIxoffset\fR] [\fB-y\fR \fIyoffset\fR] [\fIppmfile\fR] .SH 2 DESCRIPTION .LP .LP This program is part of Netpbm. .LP \fBppmshadow\fR adds a simulated shadow to an image, giving the appearance that the contents of the image float above the page, casting a diffuse shadow on the background. Shadows can either be black, as cast by opaque objects, or translucent, where the shadow takes on the color of the object which casts it. You can specify the crispness of the shadow and its displacement from the image with command line options. .LP \fBppmshadow\fR sees your image as a foreground on a background. The background color is whatever color the top left pixel of your image is. The background is all the pixels that are that color and the foreground is everything else. The shadow that \fBppmshadow\fR generates is a shadow of the foreground, cast on the background. .LP The shadow is the same size as the foreground, plus some fringes as determined by the \fB-b\fR option. It is truncated to fit in your image. The output image is the same dimensions as the input image. .LP You can use \fBpamcomp\fR to place a foreground image over a background before running \fBppmshadow\fR on it. You can use \fBppmmake\fR to make the background image (just an image of a solid color). .SH 2 OPTIONS .LP .RS .IP "\fB-b\fR \fIblur_size\fR" Sets the distance of the light source from the image. Larger values move the light source closer, casting a more diffuse shadow, while smaller settings move the light further away, yielding a sharper shadow. \fIblur_size\fR is the number of pixels of fringe there is on the shadow, beyond where the shadow would be if there were no blurring. .LP The default is 11 pixels. .LP Note that this option controls only the fringing effect of moving the light source closer to the object. It does not make the shadow grow or shrink as would happpen in the real world if you moved a point light source closer to and further from an object. .IP "\fB-k\fR" Keep the intermediate temporary image files. When debugging, these intermediate files provide many clues as to the source of an error. See below for a list of the contents of each file. .IP "\fB-t\fR" Consider the non-background material in the image translucent -- it casts shadows of its own color rather than a black shadow, which is default. This often results in fuzzy, difficult-to-read images but in some circumstances may look better. .IP "\fB-x\fR\fI xoffset\fR" Specifies the displacement of the light source to the left of the image. Larger settings of \fBxoffset\fR displace the shadow to the right, as would be cast by a light further to the left. If not specified, the horizontal offset is half of \fIblur_size \fR (above), to the left. .IP "\fB-y\fR\fI yoffset\fR" Specifies the displacement of the light source above the top of the image. Larger settings displace the shadow downward, corresponding to moving the light further above the top of the image. If you don't specify \fB-y\fR, the vertical offset defaults to the same as the horizontal offset (above), upward. .RE .SH 2 FILES .LP .LP Input is a PPM file named by the \fIppmfile\fR command line argument; if you don't specify \fIppmfile\fR, the input is Standard Input. .LP The output is a PPM file, written to Standard Output. .LP \fBppmshadow\fR creates a number of temporary files as it executes. It creates a new directory for them, \fB/tmp/ppmshadow\fR\fIpid\fR, where \fIpid\fR is the process ID of the \fBppmshadow\fR process. If the \fBTMPDIR\fR environment variable is set, \fBppmshadow\fR creates the directory there instead of \fB/tmp\fR. In normal operation, \fBppmshadow\fR deletes each temporary file as soon as it is done with it and leaves no debris around after it completes. To preserve the intermediate files for debugging, use the \fB-k\fR command line option. .LP The temporary files are: .RS .IP "\fBinfile.ppm\fR" A copy of the input. .IP "\fBbgmask.ppm\fR" Positive binary mask .IP "\fBconvkernel.ppm\fR" Convolution kernel for blurring shadow .IP "\fBblurred.ppm\fR" Blurred, colored shadow image .IP "\fBblurred2.ppm\fR" Blurred shadow image before coloring .IP "\fBshadow.ppm\fR" Clipped shadow image, offset as requested .IP "\fBbackground.ppm\fR" Blank image with background of source image .IP "\fBshadow.ppm\fR" Offset shadow .IP "\fBfgmask.ppm\fR" Inverse mask file .IP "\fBjustfg.ppm\fR" Just the foreground. Rest is black. Original image times inverse mask. .IP "\fBshadback.ppm\fR" Generated shadow times positive mask .IP "\fBallbutfg.ppm\fR" Everything but the foreground (foreground area is black). .RE .SH 2 LIMITATIONS .LP .LP The source image must contain sufficient space on the edges in the direction in which the shadow is cast to contain the shadow -- if it doesn't some of the internal steps may fail. You can usually expand the border of a too-tightly-cropped image with \fBpnmmargin\fR before processing it with \fBppmshadow\fR. .LP Black pixels and pixels with the same color as the image background don't cast a shadow. If this causes unintentional "holes" in the shadow, fill the offending areas with a color which differs from black or the background by RGB values of 1, which will be imperceptible to the viewer. Since the comparison is exact, the modified areas will now cast shadows. .LP The background color of the source image (which is preserved in the output) is deemed to be the color of the pixel at the top left of the input image. If that pixel isn't part of the background, simply add a one-pixel border at the top of the image, generate the shadow image, then delete the border from it. .LP If something goes wrong along the way, the error messages from the various Netpbm programs \fBppmshadow\fR calls will, in general, provide little or no clue as to where \fBppmshadow\fR went astray. In this case, Specify the \fB-k\fR option and examine the intermediate results in the temporary files (which this option causes to be preserved). If you manually run the commands that \fBppmshadow\fR runs on these files, you can figure out where the problem is. In problem cases where you want to manually tweak the image generation process along the way, you can keep the intermediate files with the \fB-k \fR option, modify them appropriately with an image editor, then recombine them with the steps used by the code in \fBppmshadow\fR. See the \fBppmshadow.doc\fR file in the Netpbm source tree for additional details and examples of the intermediate files and debugging \fBppmshadow\fR. .LP Shadows are by default black, as cast by opaque material in the image occluding white light. Use the \fB-t\fR option to simulate translucent material, where the shadow takes on the color of the object that casts it. If the contrast between the image and background is insufficient, the \fB-t\fR option may yield unattractive results which resemble simple blurring of the original image. .LP Because Netpbm used to have a maximum maxval of 255, which meant that the largest convolution kernel \fBpnmconvol\fR could use was 11 by 11, \fBppmshadow\fR includes a horrid, CPU-time-burning kludge which, if a blur of greater than 11 is requested, performs an initial convolution with an 11 x 11 kernel, then calls \fBpnmsmooth\fR (which is itself a program that calls \fBpnmconvol\fR with a 3 x 3 kernel) as many times as the requested blur exceeds 11. It's ugly, but it gets the job done on those rare occasions where you need a blur greater than 11. .LP If you wish to generate an image at high resolution, then scale it to publication size with \fBpamscale\fR in order to eliminate jagged edges by resampling, it's best to generate the shadow in the original high resolution image, prior to scaling it down in size. If you scale first and then add the shadow, you'll get an unsightly jagged stripe between the edge of material and its shadow, due to resampled pixels intermediate between the image and background obscuring the shadow. .SH 2 EXIT STATUS .LP \fBppmshadow\fR returns status 0 if processing was completed without errors, and a nonzero Unix error code if an error prevented generation of output. Some errors may result in the script aborting, usually displaying error messages from various Netpbm components it uses, without returning a nonzero error code. When this happens, the output file will be empty, so be sure to test this if you need to know if the program succeeded. .SH 2 SEE ALSO .LP \fBpnm\fR, \fBpnmmargin\fR, \fBpnmconvol\fR, \fBpamscale\fR, \fBpnmsmooth\fR, \fBppm\fR .SH 2 AUTHOR .LP John Walker August 8, 1997 .SH 2 COPYRIGHT .LP This software is in the public domain. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, without any conditions or restrictions. .br \l'5i' .SH 2 Table Of Contents .LP .IP \(bu NAME .IP \(bu SYNOPSIS .IP \(bu DESCRIPTION .IP \(bu OPTIONS .IP \(bu FILES .IP \(bu LIMITATIONS .IP \(bu EXIT STATUS .IP \(bu SEE ALSO .IP \(bu AUTHOR .IP \(bu COPYRIGHT .LP