Can anyone tell me what I'm doing wrong here? I have a convert command that used to work in an older version of IM, but is now broken on recent versions. I'm creating rounded edges with a drop shadow on a transparent background.
If I do two separate commands it works like so:
convert -size 150x113 xc:none -stroke none -draw "roundRectangle 5,5 148,111, 12,12" img_in.jpg -compose SrcIn -composite img_middle.png
and then
convert img_middle.png \( +clone -background black -shadow 80x4+3+3 \) +swap -background none -mosaic final.png
Can someone explain to me why the following, combined command will not work (I get a completely transparent image)?
convert -size 150x113 xc:none -stroke none -draw "roundRectangle 5,5 148,111, 12,12" img_in.jpg -compose SrcIn -composite \( +clone -background black -shadow 80x4+3+3 \) +swap -background none -mosaic final.png
Any help would me *most* appreciated. I've killed way too many days torturing myself over this.
Thanks!
Mike
mrubinsk@horde.org
Help with round corners and drop shadows.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Help with round corners and drop shadows.
mrubinsk wrote:Can anyone tell me what I'm doing wrong here? I have a convert command that used to work in an older version of IM, but is now broken on recent versions. I'm creating rounded edges with a drop shadow on a transparent background.
If I do two separate commands it works like so:
convert -size 150x113 xc:none -stroke none -draw "roundRectangle 5,5 148,111, 12,12" img_in.jpg -compose SrcIn -composite img_middle.png
and then
convert img_middle.png \( +clone -background black -shadow 80x4+3+3 \) +swap -background none -mosaic final.png
Can someone explain to me why the following, combined command will not work (I get a completely transparent image)?
convert -size 150x113 xc:none -stroke none -draw "roundRectangle 5,5 148,111, 12,12" img_in.jpg -compose SrcIn -composite \( +clone -background black -shadow 80x4+3+3 \) +swap -background none -mosaic final.png
Any help would me *most* appreciated. I've killed way too many days torturing myself over this.
Thanks!
Mike
mrubinsk@horde.org
I would think that adding parens to your first section (as below) should work (with or without the -respect-parenthesis), but the +clone in the second parens is cloning xc:none rather than the result of the first parens. This may be a bug. But hopefully Anthony or Magick will know for sure or and can explain why it does not work as expected.
convert -respect-parenthesis \
\( -size 150x113 xc:none -stroke none \
-draw "roundRectangle 5,5 148,111, 12,12" img_in.jpg -compose SrcIn -composite \) \
\( +clone -background black -shadow 80x4+3+3 \) \
+swap -background none -mosaic img_final.png
In the meantime, you can do this and it will work.
convert -size 150x113 xc:none -stroke none \
-draw "roundRectangle 5,5 148,111, 12,12" \
img_in.jpg -compose SrcIn -composite miff:- |\
convert - \( +clone -background black -shadow 80x4+3+3 \) \
+swap -background none -mosaic img_final.png
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Help with round corners and drop shadows.
The -composite operation should have removed all images in the current image sequence and replace them with a single composited result.
The parenthesis should not be needed. However as you are using -mosaic later
you will need to reset the -compose setting back to 'Over'.
The -respect-parenthesis may or may not do this, and the compose setting would have been inserted into the image and thus get used as -compose would have been reset to underfined.
It is a complex and obtuse problem as the IM command line API uses the images meta-data themselves to store 'global' settings like -compose instead of keeping a separate database of such settings. As such it gets messy with no clear cut division of meta-data vs working settings being used by various operations. A long term problem that will probably need a major version change to solve.
The parenthesis should not be needed. However as you are using -mosaic later
you will need to reset the -compose setting back to 'Over'.
The -respect-parenthesis may or may not do this, and the compose setting would have been inserted into the image and thus get used as -compose would have been reset to underfined.
It is a complex and obtuse problem as the IM command line API uses the images meta-data themselves to store 'global' settings like -compose instead of keeping a separate database of such settings. As such it gets messy with no clear cut division of meta-data vs working settings being used by various operations. A long term problem that will probably need a major version change to solve.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Help with round corners and drop shadows.
anthony wrote:The -composite operation should have removed all images in the current image sequence and replace them with a single composited result.
The parenthesis should not be needed. However as you are using -mosaic later
you will need to reset the -compose setting back to 'Over'.
Interesting.
This works:
convert -size 150x113 xc:none -stroke none \
-draw "roundRectangle 5,5 148,111, 12,12" img_in.jpg -compose SrcIn -composite \
-compose over \( +clone -background black -shadow 80x4+3+3 \) \
+swap -background none -mosaic img_final.png
but this loses the shadow:
convert -size 150x113 xc:none -stroke none \
-draw "roundRectangle 5,5 148,111, 12,12" img_in.jpg -compose SrcIn -composite \
\( +clone -background black -shadow 80x4+3+3 \) \
+swap -compose over -background none -mosaic img_final.png
So placement of the resetting of -compose over is very critical. I think it makes some sense now where it is placed to make it work.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Help with round corners and drop shadows.
That second example I would regard as a bug. The -compose Over is needed but it should work in both the examples given.
If either example was to break I would have expected it to be the first, and not the second. So i find it even stranger! Report this as a bug!
If either example was to break I would have expected it to be the first, and not the second. So i find it even stranger! Report this as a bug!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/