Click here to Skip to main content
11,717,883 members (81,132 online)
Click here to Skip to main content

Josh The Egg and The Return of the Shadows

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


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:



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


  • 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



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


About the Author

Mike Finnegan
Belgium Belgium
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
manoj kumar choubey26-Feb-12 21:23
membermanoj kumar choubey26-Feb-12 21:23 
Generalgiving image an inner shadow Pin
YtseJam825-Mar-07 5:47
memberYtseJam825-Mar-07 5:47 
GeneralRe: giving image an inner shadow Pin
q1234567895-Mar-07 21:47
memberq1234567895-Mar-07 21:47 
GeneralNatural World Shades Pin
Saied Javadi8-Jul-06 3:55
memberSaied Javadi8-Jul-06 3:55 
Questiongiving a shadowed image a transparent background? Pin
rickengle3-Feb-06 4:21
memberrickengle3-Feb-06 4:21 
AnswerRe: giving a shadowed image a transparent background? Pin
q1234567894-Feb-06 3:26
memberq1234567894-Feb-06 3:26 
GeneralRe: giving a shadowed image a transparent background? Pin
rickengle5-Feb-06 17:38
memberrickengle5-Feb-06 17:38 
GeneralRe: giving a shadowed image a transparent background? Pin
q1234567896-Feb-06 1:34
memberq1234567896-Feb-06 1:34 
GeneralRe: giving a shadowed image a transparent background? Pin
rickengle6-Feb-06 1:47
memberrickengle6-Feb-06 1:47 
GeneralRe: giving a shadowed image a transparent background? Pin
q1234567896-Feb-06 5:06
memberq1234567896-Feb-06 5:06 

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 | Terms of Use | Mobile
Web04 | 2.8.150901.1 | Last Updated 30 Sep 2004
Article Copyright 2004 by Mike Finnegan
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid