Page 1 of 1

Discard original image when making shadow

Posted: 2015-12-10T11:46:52-07:00
by mikewhy
I'm trying to use `convert` to generate glow images for a game we are working on.

I've got most of the command done already

Code: Select all

[ ! -f input.png ] && curl -L http://bellard.org/bpg/2.png --output input.png
 
convert \
  input.png \
  -background none \
  \( +clone -background \#f0f -shadow 100x40 -channel A -level 0,70% +channel \) \
  -background none \
  +swap \
  +repage \
  -shave 80 \
  output.png
The issues is that outputs `output-0.png` and `output-1.png`, where I need `output-0.png` to really be `output.png`.

I know I can just use anything to remove the unnecessary `output-1.png` and rename the other file, but is there a way to do this in imagemagick?

Using `-layers merge` allows the original image to seep through, which we don't want and will make the file size larger.

Re: Discard original image when making shadow

Posted: 2015-12-10T11:50:36-07:00
by fmw42
convert \
input.png \
-background none \
\( +clone -background \#f0f -shadow 100x40 -channel A -level 0,70% +channel \) \
-background none \
+swap \
+repage \
-shave 80 \
output.png
I believe you left out -layers merge

Code: Select all

convert \
  input.png \
  \( +clone -background \#f0f -shadow 100x40 -channel A -level 0,70% +channel \) \
  -background none \
  +swap \
  -background none \
  -layers merge \
  +repage \
  -shave 80 \
  output.png
see http://www.imagemagick.org/Usage/blur/#shadow

Re: Discard original image when making shadow

Posted: 2015-12-10T12:18:10-07:00
by Bonzo
From the way I read the post fmw42 the OP just wants the shadow without the original image and does not need the additional layer number.

Something like this?

Code: Select all

convert.exe input.png ( +clone -background "#f0f" -shadow 100x40 -channel A -level 0,70% +channel ) -background none -delete 0 +repage -shave 80 output.png

Re: Discard original image when making shadow

Posted: 2015-12-10T12:32:27-07:00
by fmw42
Bonzo wrote:From the way I read the post fmw42 the OP just wants the shadow without the original image and does not need the additional layer number.
OK. Perhaps I misunderstood. Try

Code: Select all

convert \
input.png \
\( +clone -background \#f0f -shadow 100x40 -channel A -level 0,70% +channel \) \
-delete 0
-shave 80 \
output.png

Re: Discard original image when making shadow

Posted: 2015-12-10T12:34:25-07:00
by Bonzo
Just edited my post as you were posting fmw42

Re: Discard original image when making shadow

Posted: 2015-12-10T12:49:08-07:00
by mikewhy
`delete 0` is exactly what I am looking for, thanks so much! Here's the final command, for posterity:

Code: Select all

convert \
    input.png \
    \( +clone -background \#f0f -shadow 100x20 -channel A -level 0,70% +channel \) \
    -delete 0 \
    -shave 40 \
    output.png
aka exactly what fmw42 posted.