Drop shadows

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
stamatefilip
Posts: 4
Joined: 2013-09-19T11:44:57-07:00
Authentication code: 6789

Drop shadows

Post by stamatefilip »

Hi,

Can anyone give me the commands to apply drop shadows to series on transparent png images? Basically, I want the script to go through all the png files in a folder, apply a drop shadow effect and then save and overwrite the previous image (which has no shadows).
I'd like the commands for Windows, if possible.

Thank you,
Filip.
stamatefilip
Posts: 4
Joined: 2013-09-19T11:44:57-07:00
Authentication code: 6789

Re: Drop shadows

Post by stamatefilip »

Ok, so this

Code: Select all

convert image.png ( -clone 0 -background black -shadow 80x3+0+8 ) -reverse -background none -layers merge +repage image.png
gives me what I want for one image. All I need is how to apply it to an entire folder.
Of course, any other suggestions on a better command would be welcomed.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Drop shadows

Post by snibgo »

For shadows in IM, see http://www.imagemagick.org/Usage/blur/#shadow

For looping through files in Windows, type "help for" or "forfiles /?".
snibgo's IM pages: im.snibgo.com
stamatefilip
Posts: 4
Joined: 2013-09-19T11:44:57-07:00
Authentication code: 6789

Re: Drop shadows

Post by stamatefilip »

Yeah, sorry, but I can't figure it out.

In other words.. can anyone write it for me? :oops:
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Drop shadows

Post by Bonzo »

I am not a Windows expert but try this untested code on a TEST FOLDER of images and see what happens:

Code: Select all

::Turn of displaying the code on the screen
 @echo off

 :: Read all the png images from the directory, modify and save with the same name
 for %%f in (%1\*.png) do ( convert "%%f"  ( -clone 0 -background black -shadow 80x3+0+8 ) -reverse -background none -layers merge +repage "%1.png" )
I have just tried and it does not work!
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Drop shadows

Post by snibgo »

Your use of %1 is incorrect. Command on the same line as "for" mustn't be bracketed. Brackets are for putting the command on a separate line. For example, put one of these in a command file, and ALWAYS call it with the name of a directory.

Code: Select all

for %%f in (%1\*.png) do %IM%convert "%%f" ( -clone 0 -background black -shadow 80x3+0+8 ) -reverse -background none -layers merge +repage "%%f"

for %%f in (%1\*.png) do (
  %IM%convert "%%f" ^( -clone 0 -background black -shadow 80x3+0+8 ^) -reverse -background none -layers merge +repage "%%f"
)
snibgo's IM pages: im.snibgo.com
stamatefilip
Posts: 4
Joined: 2013-09-19T11:44:57-07:00
Authentication code: 6789

Re: Drop shadows

Post by stamatefilip »

@snibgo

That sort of works... it just seems to make several copies of the results, plus some files which only contain shadows. And the original files remain intact.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Drop shadows

Post by Bonzo »

Brackets are for putting the command on a separate line.
I will have to check that out when I have time snibgo as I have a couple of examples on my website similar to the code I posted.
Post Reply