Click here to Skip to main content
Click here to Skip to main content
Go to top

Josh The Egg and The Return of the Shadows

, 30 Sep 2004
Rate this:
Please Sign up or sign in to vote.
Shadow: a program to add drop shadows to images.

Introduction

The standard way to add a drop shadow to an image is to fire up GIMP or Photoshop, add a background layer, add a transparent layer, select a rectangular area the size of the image you want to give a drop shadow, blur it, add a new transparent layer, paste the image in the layer, move the layer with the blurred shadow a bit to the right and to the bottom and finally flatten the layers. If you know how to use GIMP or Photoshop, this is no big deal. If you never did this before, follow the steps in, say, 40 tutorials and you will have a good basic understanding of how to use these graphic programs. Take a look at Wintris, a T*tris Clone for Windows I've written. You can find Wintris on my site. The background of Wintris was painted in GIMP 1.x. Nice, innit? But if you don't have the time to learn how to use these programs, or you don't want to learn them just for adding a simple shadow to an image, maybe there's an easier way...

Shadow is a fascinating program which can add drop shadows to images. It's a command line utility written in C#. Because it is a command line program, you can add drop shadows to images in batch. Suppose you have a site with 4000 thumbnail images, you could add a drop shadow to all these images in seconds. Shadow is based on GPaint, my program to generate Google-like logos.

To demonstrate the capabilities of Shadow, let's put Josh The Egg to work. Josh was born in Microsoft Expression, a wonderful vector graphics program. Here's a picture of Josh:

 

Usage

If you invoke Shadow without any arguments, it will display the options:

 

If you provide a file name on the command line and no options, Shadow will add a drop shadow to the image and put the image on a white background:

C:\>shadow josh.jpg

 

If you don't want to modify the input file, you can specify an output file:

C:\>shadow josh.jpg josh-with-shadow.jpg

Options

  • Option -s: shadow width

    The width of the shadow is specified in pixels. If you want a shadow of 20, you invoke shadow like this:

    C:\>shadow -s:20 josh.jpg joshs.jpg

     

  • Option -b: border width

    The background of the picture of Josh The Egg is white. If you add a drop shadow to this picture and you put it on a white page, the edges of the picture are not clearly visible. A border can fix this problem:

    C:\>shadow -b: josh.jpg joshb.jpg

     

  • Option -m: margin

    The margin is the area around the actual picture which exposes the background. The margin is expressed in pixels. Note that I've set the attribute border of the <img> tag to 1.

    C:\>shadow -m:20 josh.jpg joshm.jpg

     

  • Option -r: shadow direction

    You can change the shadow direction by specifying the -r option on the command line. It's argument can be 0, 1, 2 or 3:

    -rBlush | :O -r:1 -r:2 -r:3
  • Option -t: shadow transparency

    Shadow uses the concept of layers, just like in GIMP or Photoshop. You can change the opacity of the shadow layer by specifying a number from 0.0 to 1.0 as an argument of the -t parameter:

    C:\>shadow -t:0.5 josh.jpg josht.jpg

     

  • Option -a: background color

    You can change the color of the background specifying the color in hexadecimal notation. Invoking Shadow like this will put Josh on a green background:

    C:\>shadow -a:00FF00 josh.jpg josha.jpg

     

  • Option -c: shadow color

    If you live on Mars, maybe you appreciate a red shadow:

    C:\>shadow -c:FF0000 josh.jpg joshc.jpg

     

  • Option -d: border color

    Changing the border color is also a piece of cake (don't forget to specify a border width!). Note that the quality of the image is influenced by the image format. The red border in this example looks a bit dirty. When the image is saved as a BMP file, the border color is ok.

    C:\>shadow -b:2 -d:FF0000 josh.jpg joshd.jpg

     

  • Option -n: no soft shadow

    If you don't want a soft shadow, you can turn it of by specifying the -n parameter on the command line:

    C:\>shadow -b:1 -n josh.jpg joshn.jpg

     

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Mike Finnegan

Belgium Belgium
No Biography provided

Comments and Discussions

 
GeneralMy vote of 5 Pinmembermanoj kumar choubey26-Feb-12 21:23 
Generalgiving image an inner shadow PinmemberYtseJam825-Mar-07 5:47 
GeneralRe: giving image an inner shadow Pinmemberq1234567895-Mar-07 21:47 
GeneralNatural World Shades PinmemberSaied Javadi8-Jul-06 3:55 
Questiongiving a shadowed image a transparent background? Pinmemberrickengle3-Feb-06 4:21 
AnswerRe: giving a shadowed image a transparent background? Pinmemberq1234567894-Feb-06 3:26 
GeneralRe: giving a shadowed image a transparent background? Pinmemberrickengle5-Feb-06 17:38 
GeneralRe: giving a shadowed image a transparent background? Pinmemberq1234567896-Feb-06 1:34 
GeneralRe: giving a shadowed image a transparent background? Pinmemberrickengle6-Feb-06 1:47 
GeneralRe: giving a shadowed image a transparent background? Pinmemberq1234567896-Feb-06 5:06 
GeneralRe: giving a shadowed image a transparent background? Pinmemberrickengle6-Feb-06 5:44 
GeneralRe: giving a shadowed image a transparent background? Pinmemberq1234567896-Feb-06 23:13 
GeneralRe: giving a shadowed image a transparent background? Pinmemberrickengle9-Feb-06 16:53 
GeneralBlur improvement PinmemberKosta Cherry13-Oct-05 19:30 
GeneralRe: Blur improvement PinsussAnonymous13-Oct-05 23:01 
GeneralRe: Blur improvement PinmemberKosta Cherry14-Oct-05 4:40 
GeneralRe: Blur improvement PinmemberKosta Cherry14-Oct-05 4:43 
GeneralRe: Blur improvement PinmemberKosta Cherry14-Oct-05 4:43 
GeneralA Note about Performance PinsussAnonymous7-Oct-04 23:03 
GeneralRe: A Note about Performance Pinmembercnurse21-Oct-04 21:04 
GeneralRe: A Note about Performance PinmemberHardy10-Mar-06 5:11 
GeneralCSS alternative PinmemberPeterSteen30-Sep-04 22:33 
GeneralRe: CSS alternative PinsussAnonymous1-Oct-04 0:38 
GeneralNice tutorial PinsussAnonymous30-Sep-04 3:17 
GeneralRe: Nice tutorial PinmemberColin Angus Mackay30-Sep-04 3:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140916.1 | Last Updated 30 Sep 2004
Article Copyright 2004 by Mike Finnegan
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid