Click here to Skip to main content
11,480,938 members (61,986 online)
Click here to Skip to main content

Josh The Egg and The Return of the Shadows

, 30 Sep 2004 97.9K 514 50
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 Pin
manoj kumar choubey26-Feb-12 22:23
membermanoj kumar choubey26-Feb-12 22:23 
Generalgiving image an inner shadow Pin
YtseJam825-Mar-07 6:47
memberYtseJam825-Mar-07 6:47 
GeneralRe: giving image an inner shadow Pin
q1234567895-Mar-07 22:47
memberq1234567895-Mar-07 22:47 
GeneralNatural World Shades Pin
Saied Javadi8-Jul-06 4:55
memberSaied Javadi8-Jul-06 4:55 
Questiongiving a shadowed image a transparent background? Pin
rickengle3-Feb-06 5:21
memberrickengle3-Feb-06 5:21 
AnswerRe: giving a shadowed image a transparent background? Pin
q1234567894-Feb-06 4:26
memberq1234567894-Feb-06 4:26 
GeneralRe: giving a shadowed image a transparent background? Pin
rickengle5-Feb-06 18:38
memberrickengle5-Feb-06 18:38 
GeneralRe: giving a shadowed image a transparent background? Pin
q1234567896-Feb-06 2:34
memberq1234567896-Feb-06 2:34 
GeneralRe: giving a shadowed image a transparent background? Pin
rickengle6-Feb-06 2:47
memberrickengle6-Feb-06 2:47 
GeneralRe: giving a shadowed image a transparent background? Pin
q1234567896-Feb-06 6:06
memberq1234567896-Feb-06 6:06 
GeneralRe: giving a shadowed image a transparent background? Pin
rickengle6-Feb-06 6:44
memberrickengle6-Feb-06 6:44 
GeneralRe: giving a shadowed image a transparent background? Pin
q1234567897-Feb-06 0:13
memberq1234567897-Feb-06 0:13 
GeneralRe: giving a shadowed image a transparent background? Pin
rickengle9-Feb-06 17:53
memberrickengle9-Feb-06 17:53 
GeneralBlur improvement Pin
Kosta Cherry13-Oct-05 20:30
memberKosta Cherry13-Oct-05 20:30 
GeneralRe: Blur improvement Pin
Anonymous14-Oct-05 0:01
sussAnonymous14-Oct-05 0:01 
GeneralRe: Blur improvement Pin
Kosta Cherry14-Oct-05 5:40
memberKosta Cherry14-Oct-05 5:40 
GeneralRe: Blur improvement Pin
Kosta Cherry14-Oct-05 5:43
memberKosta Cherry14-Oct-05 5:43 
GeneralRe: Blur improvement Pin
Kosta Cherry14-Oct-05 5:43
memberKosta Cherry14-Oct-05 5:43 
GeneralA Note about Performance Pin
Anonymous8-Oct-04 0:03
sussAnonymous8-Oct-04 0:03 
GeneralRe: A Note about Performance Pin
cnurse21-Oct-04 22:04
membercnurse21-Oct-04 22:04 
GeneralRe: A Note about Performance Pin
Hardy10-Mar-06 6:11
memberHardy10-Mar-06 6:11 
GeneralCSS alternative Pin
PeterSteen30-Sep-04 23:33
memberPeterSteen30-Sep-04 23:33 
GeneralRe: CSS alternative Pin
Anonymous1-Oct-04 1:38
sussAnonymous1-Oct-04 1:38 
GeneralNice tutorial Pin
Anonymous30-Sep-04 4:17
sussAnonymous30-Sep-04 4:17 
GeneralRe: Nice tutorial Pin
Colin Angus Mackay30-Sep-04 4:45
memberColin Angus Mackay30-Sep-04 4: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 | Terms of Use | Mobile
Web04 | 2.8.150520.1 | Last Updated 30 Sep 2004
Article Copyright 2004 by Mike Finnegan
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid