Search code examples
imagemagickimagemagick-convert

I want to display two different font sizes of text in a composite image


Why do I want to display two different font sizes of text in a composite image, but only the first is displayed?

convert \( -resize "1000x1000^" -blur 50x5 "https://example.com/origin.jpg" -extent 1000x1000 -background none -fill "yellow" -colorize 40 \) \
  \( -font /var/hoge.otf -annotate +0-250 -background none -fill white -pointsize 80 -size 850x caption:"First line text in large font size" \) \
  \( -font /var/hoge.otf -annotate +0+250 -background none -fill white -pointsize 60 -size 850x caption:" Second line of text in small font size" \) \
  -gravity center -compose over -composite /var/output.jpg

Can't the annotate and caption options be used at the same time?


Solution

  • Perhaps this is what you want to do in Imagemagick. You do not need caption: and you do not need parentheses processing, just chaining of commands. I have corrected your syntax ordering and modified your command a little to add -gravity center before -annotate. I also changed the font to something that I have and the fill color to black for the text to make it show more clearly.

    convert "https://imagemagick.org/image/wizard.png" -resize "1000x1000^" -blur 50x5 -extent 1000x1000 -background none -fill "yellow" -colorize 40 \
    -font /Users/fred/Fonts/Ubuntu-Bold.ttf -background none -fill black -pointsize 60 -gravity center -annotate +0-250 "First line text in large font size" \
    -font /Users/fred/Fonts/Ubuntu-Bold.ttf -background none -fill black -pointsize 40 -gravity center -annotate +0+250 "Second line of text in small font size" \
    output.jpg
    

    enter image description here