How to create round corner and drop shadow by convert?
How to create round corner and drop shadow by convert?
How to create round corner and drop shadow? I tried but the speed is very slow on creating shadow. Gaussian blur cost too much time. Thanks!
http://picasaweb.google.com/waveletboy/ ... 7339123554
http://picasaweb.google.com/waveletboy/ ... 7339123554
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to create round corner and drop shadow by convert?
It might be nice if you gave us some information about what your command line is like?
Have you tried -shadow
http://www.imagemagick.org/Usage/convolve/#shadow
Have you tried -shadow
http://www.imagemagick.org/Usage/convolve/#shadow
Re: How to create round corner and drop shadow by convert?
I need three steps to create such picture.
convert -size 800x600 xc:none -draw "roundRectangle 0,0 800,600 15,15" -fill white input.JPG -compose SrcIn -composite +compress inter_001.png
convert inter_001.png ( +clone -background black -shadow 80x5+8+8 ) +swap -background none -layers merge +repage +compress inter_002.png
convert -size 830x630 xc:white -draw "image Over 6,6, 0,0 'inter_002.png'" +compress final.png
Is it possible to do it with one line? Thanks.
convert -size 800x600 xc:none -draw "roundRectangle 0,0 800,600 15,15" -fill white input.JPG -compose SrcIn -composite +compress inter_001.png
convert inter_001.png ( +clone -background black -shadow 80x5+8+8 ) +swap -background none -layers merge +repage +compress inter_002.png
convert -size 830x630 xc:white -draw "image Over 6,6, 0,0 'inter_002.png'" +compress final.png
Is it possible to do it with one line? Thanks.
fmw42 wrote:It might be nice if you gave us some information about what your command line is like?
Have you tried -shadow
http://www.imagemagick.org/Usage/convolve/#shadow
Re: How to create round corner and drop shadow by convert?
Code: Select all
convert <input file> \
-fill none -draw "matte 0,0 reset" \
-tile <input file> \
-draw "roundRectangle -1,-1 <width>,<height> 30,30" \
( +clone -background black -shadow 80x5+10+10 ) \
+swap -background none -layers merge \
+repage <output file>
Re: How to create round corner and drop shadow by convert?
You are magic!
fockjef wrote:Code: Select all
convert <input file> \ -fill none -draw "matte 0,0 reset" \ -tile <input file> \ -draw "roundRectangle -1,-1 <width>,<height> 30,30" \ ( +clone -background black -shadow 80x5+10+10 ) \ +swap -background none -layers merge \ +repage <output file>
Re: How to create round corner and drop shadow by convert?
I just tested this to see is it working and for some reason i getting black box.Any idea why?
Re: How to create round corner and drop shadow by convert?
I am also getting a black box. Anyone have any ideas why? I have JPEG, JPEG-2000, PNG, and TIFF support.
Re: How to create round corner and drop shadow by convert?
Apparently this only happens on JPEGs. It works fine to add shadows to PNGs, but those aren't that web-friendly. Converting the PNG back to the JPEG also results in the bad drop shadow. Any thoughts?
Re: How to create round corner and drop shadow by convert?
The solution is this:
Notice I changed "-background none" to "-background white." Because JPEGs don't have transparency, the transparent portions get converted to black if the background is set to none. If you have "-background white," it'll flatten the transparency into the white background, producing the correct result.
Code: Select all
convert <file>.jpg \( +clone -background black -shadow 60x5+10+10 \) +swap -background white -layers merge +repage <output>.jpg
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How to create round corner and drop shadow by convert?
The "RoundedRectangle" solution is an early solution for generating anti-aliased rounded corners on images. But as you knwo you need at least one pass first to get the image size.
A different solution generates the masking image by drawing a small corner and flip/flopping it around.
See IM Examples, Thumbnails, Rounded Corners...
http://www.imagemagick.org/Usage/thumbnails/#rounded
You can add to that command with the shadowing stuff and do BOTH image processing sequences (corners and shaodwing) in the one convert command.
A different solution generates the masking image by drawing a small corner and flip/flopping it around.
See IM Examples, Thumbnails, Rounded Corners...
http://www.imagemagick.org/Usage/thumbnails/#rounded
You can add to that command with the shadowing stuff and do BOTH image processing sequences (corners and shaodwing) in the one convert command.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How to create round corner and drop shadow by convert?
What OS are you using?
What version of IM are you using?
what errors do you get?
What image are you trying?
What version of IM are you using?
what errors do you get?
What image are you trying?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: How to create round corner and drop shadow by convert?
Would anyone know how to do the same but with a background image instead of having a white background?pinstripe wrote:The solution is this:
Notice I changed "-background none" to "-background white." Because JPEGs don't have transparency, the transparent portions get converted to black if the background is set to none. If you have "-background white," it'll flatten the transparency into the white background, producing the correct result.Code: Select all
convert <file>.jpg \( +clone -background black -shadow 60x5+10+10 \) +swap -background white -layers merge +repage <output>.jpg
I tried:
Code: Select all
convert <file>.jpg \( +clone -background black -shadow 60x5+10+10 \) +swap -texture mytexture.gif -layers merge +repage <output>.jpg
If possible, I would prefer the image (and its shadow) not to begin at the top left corner but be offset by few pixels (e.g. +5+5).
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to create round corner and drop shadow by convert?
try this using the IM internal images netscape: and logo:
infile1="netscape:"
infile2="logo:"
ww=`convert $infile1 -ping -format "%w" info:`
hh=`convert $infile1 -ping -format "%h" info:`
wwm1=`convert xc: -format "%[fx:$ww-1]" info:`
hhm1=`convert xc: -format "%[fx:$hh-1]" info:`
convert $infile1 \
\( +clone -threshold "100%" -fill white -draw "roundrectangle 1,1 $wwm1,$hhm1 25,25" \) \
-alpha off -compose CopyOpacity -composite \
-background none -compose Over -gravity center -extent ${ww}x${hh} \
\( +clone -background black -shadow 60x4+4+4 \) +swap \
-background none -flatten \
$infile2 +swap -gravity center -composite netscape_rounded_shadow_logo.png
first line after the 6 variables are defined is input image infile1=netscape
second line makes a black image from the netscape: and draws a white roundrectangle
third line puts the white and black roundrectange as the alpha channel of the netscape image
fourth line adds a black shadow
fifth line flattens (combines) the shadow with the rounded netscape
sixth line overlays the shadowed rounded netscape over the infile2=logo: image
infile1="netscape:"
infile2="logo:"
ww=`convert $infile1 -ping -format "%w" info:`
hh=`convert $infile1 -ping -format "%h" info:`
wwm1=`convert xc: -format "%[fx:$ww-1]" info:`
hhm1=`convert xc: -format "%[fx:$hh-1]" info:`
convert $infile1 \
\( +clone -threshold "100%" -fill white -draw "roundrectangle 1,1 $wwm1,$hhm1 25,25" \) \
-alpha off -compose CopyOpacity -composite \
-background none -compose Over -gravity center -extent ${ww}x${hh} \
\( +clone -background black -shadow 60x4+4+4 \) +swap \
-background none -flatten \
$infile2 +swap -gravity center -composite netscape_rounded_shadow_logo.png
first line after the 6 variables are defined is input image infile1=netscape
second line makes a black image from the netscape: and draws a white roundrectangle
third line puts the white and black roundrectange as the alpha channel of the netscape image
fourth line adds a black shadow
fifth line flattens (combines) the shadow with the rounded netscape
sixth line overlays the shadowed rounded netscape over the infile2=logo: image
Re: How to create round corner and drop shadow by convert?
Thanks fmw42. Your script looks to work. However, when I replace the infile variables by actual files, I get the following errors:fmw42 wrote:try this using the IM internal images netscape: and logo: [...]
Code: Select all
convert: unable to open image `../bkgd_photo.jpg': No such file or directory.
convert: no such image `p_cotegaspesie5s.jpg'.
convert: missing an image filename `netscape_rounded_shadow_logo.png'.
Re: How to create round corner and drop shadow by convert?
Post your code.
I pressume you are not adding : to your image name ? This is only for built in Image Magick images.
I pressume you are not adding : to your image name ? This is only for built in Image Magick images.