Page 1 of 1

Drop shadow without alerting size of original image?

Posted: 2011-11-03T00:17:26-07:00
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!

Re: Drop shadow without alerting size of original image?

Posted: 2011-11-03T00:54:07-07:00
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

Re: Drop shadow without alerting size of original image?

Posted: 2011-11-04T10:10:06-07:00
by Greywey
Thanks very much it works great!