سؤال

I'm printing some text on an image with convert and I would like to decorate the text with a black shadow, I tried -blur or -gaussian but I cannot apply to the text, it is applied to the background image only. I need to use -draw command and not -annotate.

And this is the code I need to update for shadowing

-font "geometricslab703bt-bold-webfont.ttf" -fill White -pointsize 18 -draw "rotate -4 text 350,250 '---- mijn ideale ----'"

thanks in advance

هل كانت مفيدة؟

المحلول

A better, more flexible, way to work with text shadow is to render the shadow on a new layer. This method will allow you to manipulate the shadow-text, as needed, without affecting the background. Finally draw the actual text on top of the shadow after adjusting any geometric offsetting. Here's an example:

convert -size 280x100 pattern:SMALLFISHSCALES \
  \( xc:transparent -font "Menlo" -pointsize 32 -fill black -draw "rotate -4 text 20,60 'ImageMagick'" -blur 0x1 \) \
  -geometry +2+2   -composite \
  -font "Menlo" -fill white -pointsize 32 -draw "rotate -4 text 20,60 'ImageMagick'" \
  example.png

The escaped braces "\( \)" will create a new sub-image; which, will be applied to the background with -composite flag.

enter image description here

This solution is a little bit more labor intensive, but keeps all your effects isolated.

نصائح أخرى

You can use caption to draw text, and make a shadow layer with clone then merge the two layer.

convert logo: -resize 40%x40 \
    \( -size "80x40" -background none -gravity west  -fill green caption:"Caption text" \
    \( +clone -background navy -shadow 80x3+5+5  \) +swap -background none -layers merge +repage \) -composite \
    \( -size "80x40" -background none -gravity east  -fill green caption:"Caption text"  \
    \( +clone -background red -shadow 80x3+5+5  \) +swap -background none -layers merge +repage \) -composite \
    out.png

enter image description here

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top