Drop shadow without alerting size of original image?

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
Greywey
Posts: 6
Joined: 2011-11-03T00:10:24-07:00
Authentication code: 8675308

Drop shadow without alerting size of original image?

Post by Greywey »

Hi, I have a drop shadow command-line code. It takes a transparent image, makes a shadow, but it changes the size of the original image when saving to a new image. How can I make it so that the original image of some unknown size is not changed, the shadow effect should just get cropped if it goes over.

Code: Select all

convert.exe a.png ( +clone -background black -shadow 80x3+5+5 ) +swap -background none -layers merge +repage a_shadow.png
Thanks very much!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Drop shadow without alerting size of original image?

Post by anthony »

To preserve the original image size, don't swap, and use DstOver, instead the defautl Over composition.
You would also use a 'flatten' or compostion instead of a 'merge'

Code: Select all

convert.exe a.png ( +clone -background black -shadow 80x3+5+5 ) ^
             -compose DstOver -composite   a_shadow.png
This was actually the original usage of the shadow image. The use of 'merge' was added to prevent the shadow image from being clipped.

Note the use of '^' as a line continuation character in DOS. this is the same function as '\' under UNIX shell scripting.
The next line however must start with some space indentation characters.

See IM examples, Windows Usage Examples
http://www.imagemagick.org/Usage/windows/#dos
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Greywey
Posts: 6
Joined: 2011-11-03T00:10:24-07:00
Authentication code: 8675308

Re: Drop shadow without alerting size of original image?

Post by Greywey »

Thanks very much it works great!
Post Reply