Page 1 of 1
Stop image from resizing when adding shadow [solved]
Posted: 2015-06-13T17:50:11-07:00
by jauson
Is there a way to lock the canvas size so it doesnt resize the image when adding a shadow?
Images used.
http://i.imgur.com/wCz2tMf.png (catssmall.png)
http://i.imgur.com/QDD0w4K.jpg (testbg.jpg)
http://i.imgur.com/VNNAMIb.png (cats.png)
Code: Select all
convert testbg.jpg \
\( catssmall.png -set page +258+249 \) \
\( +clone -background gray5 -shadow 80x20+20+20 \) +swap -background none \
\
-layers merge +repage \
output-shadow.jpg
As you can see, the shadow adds the black area, what I'd like it to do is just create the shadow and stop at that bg images canvas size.
Also, when adding a second image and moving it, is there a way to not resize the image, but allow the image to move semi out of bounds? Crop isn't really a valid option for me.
Code: Select all
convert testbg.jpg \
\( cats.png -set page +258+249 \) \
\
-layers merge +repage \
output-move.jpg
Solution:
Use "-layers flatten"
Re: Stop image from resizing when adding shadow
Posted: 2015-06-13T18:53:43-07:00
by fmw42
You need to expand the canvas to have a shadow. You can pre-crop or resize the image by the amount of size change due to the shadow, so the result is the same size as your original
Perhaps I misunderstand what you are trying to accomplish? If so, please explain further.
Re: Stop image from resizing when adding shadow
Posted: 2015-06-13T20:36:37-07:00
by jauson
i'd like to freeze the canvas size from expanding
Re: Stop image from resizing when adding shadow
Posted: 2015-06-14T01:08:21-07:00
by Bonzo
i'd like to freeze the canvas size from expanding
As sibgo said you can not do that. You can either resize the image before adding the shadow or after.
The black area is caused as jpg does not support transparency. To stay as a jpg you would neede to add another background below the shadow the colour of your page and then save as a jpg.
Re: Stop image from resizing when adding shadow
Posted: 2015-06-14T01:16:48-07:00
by snibgo
jauson wrote:As you can see, the shadow adds the black area, what I'd like it to do is just create the shadow and stop at that bg images canvas size.
What version of M are you using? It would be helpful if you supplied your input images, so people can try to reproduce the problem.
On v6.9.1-0 on Windows 8.1 ...
Code: Select all
convert ^
-size 600x400 xc:blue ^
( rose: -set page +258+249 ) ^
( +clone -background gray5 -shadow 80x20+20+20 ) +swap -background none ^
-layers merge +repage ^
o.jpg
identify o.jpg
... I don't get a black line, and the output is the same size as the background image.
Re: Stop image from resizing when adding shadow
Posted: 2015-06-14T01:22:49-07:00
by jauson
I updated the original post with the images used. I understand the reason why the black area is there, it's a jpg image.
Using Version: ImageMagick 6.9.0-10 Q16 x64. Windows 8.1.
Will get the black area.
Code: Select all
convert \
-size 600x400 xc:blue \
\( rose: -set page +258+349 \) \
\( +clone -background gray5 -shadow 80x20+20+20 \) +swap -background none \
-layers merge +repage \
o.jpg
Re: Stop image from resizing when adding shadow
Posted: 2015-06-14T02:13:59-07:00
by snibgo
How are you running the command? Your syntax is bash. Do you use Cygwin?
Anyhow, the problem is simply that you ask for a shadow that will extend beyond the background image, so the result is larger. The cure is to make a smaller shadow, or crop, or use "-layers flatten" instead of "-layers merge".
Re: Stop image from resizing when adding shadow
Posted: 2015-06-14T02:24:31-07:00
by jauson
snibgo wrote:How are you running the command? Your syntax is bash. Do you use Cygwin?
Anyhow, the problem is simply that you ask for a shadow that will extend beyond the background image, so the result is larger. The cure is to make a smaller shadow, or crop, or use "-layers flatten" instead of "-layers merge".
Thank you snibgo.
Yes, I'm using Mintty. Also, "flatten" did the trick. I'll have to look up what the difference of flatten and merge is.
Re: Stop image from resizing when adding shadow [solved]
Posted: 2015-06-14T02:43:47-07:00
by snibgo