Welcome to the web's most helpful Online Free computer tips and tricks website. This site contains all Latest and Cool Computer tricks as well as some Internet Tricks, Registry tricks, Orkut tricks, Windows customize and Optimization tricks, Computer Tweaks. Solve your computer problems by browsing the website for related Computer solution. All tips work well in both Windows XP as well as windows vista or win 7 operating systems. Need some Computer Help? Then this website suites your must need. These windows and internet Hacks Tricks are safe and free from any Spy ware. Learn All Basic and Advanced computer tips and tricks and be a computer master. All the computer tips at Hack2011 are very interesting and are mainly meant for education purpose. Visit my new Computer Tips Blog and leave your comments and suggestions there. Enjoy your stay and read all the articles posted here.


Add Drop Shadows To Images In Linux With One Command


If you need to quickly add a drop shadow to an image, The GIMP can do it with very little effort.  Simply open your image in The GIMP, then navigate to the Filters menu, choose the Light and Shadow submneu, and finally select the Drop Shadow option.
Choose Drop Shadow


Select your shadow options in the following dialog, which gives you the option for the shadow opacity, blur radius, and X & Y offset.
Drop Shadow Preferences
Now save the image, and bam, you’re finished creating a nice drop shadow, like this:
Shadow Example
Of course, adding shadows to a large number of images using The GIMP can take a while, as you have to repeat the process by opening each new image in turn, then deciding on a new name for each modified picture.  Wouldn’t it be easier to do this in the Terminal?
Yes it would, and of course, you can!  Thanks to Imagemagick, adding a drop shadow to an image is as simple as the following command (replace image.png with the name of the file you’re using, and image-shadow.png with the name you’d like to use for your file:
convert image.png \( +clone -background black -shadow 90×3+6+6 \) \ +swap -background none -layers merge +repage image-shadow.png
Of course, this isn’t a simple, easy-to-remember command, but what it basically does is clone your original image as a black background, add a shadow with 90 percent opacity, and a 3 pixel fuzzy border that’s offset six pixels down and to the right (just as The GIMP did in our earlier example).  It then takes the original picture, sets it on top of the fuzzy, offset shadow, merges the two together and saves it, using the original name, but with -shadow appended to it.
This isn’t a command most people will want to type into the Terminal every time they want to add a shadow to a screenshot, obviously!  Fortunately, with a little bit of scripting, this command can be added to a user’s .bashrc file, so that it can be called up and used very quickly from the Terminal.

Add The Shadow Script To Tour .bashrc File

The first thing we’ll do is open up a Terminal window.
Open Terminal
Now type the following:
gedit /home/username/.bashrc
This command opens your .bashrc file in gedit, the default text editor in GNOME Linux.  It should look something like the following:
Bashrc in gedit
Now, scroll to the very end and paste in the following block of text:

#places the image-shadow into memory drop-shadow () { out=${1%.*}-shadow.${1#*.} in=$1 echo "Finished! New file saved as $out" if [ ! -z $2 ] ; then convert $in -frame $2 $out in=$out fi convert $in \( +clone -background black -shadow 90x3+6+6 \) \ +swap -background white -layers merge +repage $out } Save your .bashrc file and restart your Terminal.  You now have a new tool available, invoked by typing “drop-shadow” (without the quotes), followed by the name of the file you want to add a shadow to, like this (replacing username with your username, and using the full path to the image, assuming you didn’t ‘cd’ into the image directory):
drop-shadow /home/username/Desktop/Example-image.png
Imagemagick then adds the shadow and saves the new file, just as with the original command, by appending “-shadow” to the original name.  The new image is saved in the same directory as the original image, which is not modified.  And you’ll get a little confirmation in the Terminal that the process was a success.
Confirmation
And that’s it.  You can now add shadows to as many images as you want, one after another, simply by typing drop-shadow and the name of the image.  All thanks to the image editing capabilities of Imagemagick and the customizability and power of Linux.

No comments:

Post a Comment