Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
abs2act
Posts: 10 Joined: 2014-08-12T20:41:45-07:00
Authentication code: 6789
Post
by abs2act » 2015-01-13T15:57:20-07:00
I'm trying to create labels with different font sizes for each line.
E.g.
Code: Select all
convert -background black -fill white -size 720x480 -pointsize 50 -gravity NorthWest -font Roboto-Regular label:'TEST1\nTEST2' -extent 720x480-70+0 test.png
I would like to increase the pointsize for TEST2 to lets say 60. Any ideas?
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2015-01-13T16:08:54-07:00
abs2act
Posts: 10 Joined: 2014-08-12T20:41:45-07:00
Authentication code: 6789
Post
by abs2act » 2015-01-13T17:16:16-07:00
Thanks fmw42 for the links.
So the image doesn't turn out the way I exactly want. For example:
Code: Select all
convert -background black -fill white -size 720x480 -gravity NorthWest \
-font Roboto-Regular -pointsize 30 label:'TEST1' \
-font Roboto-Regular -pointsize 35 label:'TEST2' \
+append test.png
This creates 2 images and combines it. I want 1 image with TEST1 in the first line and TEST2 in a the second line with a different pointsize.
Something like this
Code: Select all
convert -background black -fill white -size 720x480 -gravity NorthWest \
-font Roboto-Regular -pointsize 30 label:'TEST1'\nTEST2' \
test.png
Unfortunately I can't figure out a way to change TEST2 to pointsize 35.
anthony
Posts: 8883 Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia
Post
by anthony » 2015-01-13T17:41:12-07:00
You could look at using Pango, which lets you add meta tags in the text to format it. However it has less control over font selection.
http://www.imagemagick.org/Usage/text/#pango
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2015-01-13T19:28:07-07:00
Thanks fmw42 for the links.
So the image doesn't turn out the way I exactly want. For example:
Note that label: and caption: are to create new images and then overlay them on a background image.
However, with -draw, you can put all the arguments into one -draw command and write directly to some background image.
Alternately, you can make several calls to -annotate to write each line to some background image.
snibgo
Posts: 12159 Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Post
by snibgo » 2015-01-14T01:30:23-07:00
abs2act wrote: I want 1 image with TEST1 in the first line and TEST2 in a the second line with a different pointsize.
Use "-append" instead of "+append".
abs2act
Posts: 10 Joined: 2014-08-12T20:41:45-07:00
Authentication code: 6789
Post
by abs2act » 2015-01-14T10:50:36-07:00
fmw42 - I see you what you're saying. Can you provide an example of how to use the -draw command with the context I've provided?
abs2act
Posts: 10 Joined: 2014-08-12T20:41:45-07:00
Authentication code: 6789
Post
by abs2act » 2015-01-14T10:52:04-07:00
snibgo - so that stacks the images together versus having just one image with both lines of text.
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2015-01-14T11:05:12-07:00
abs2act wrote: fmw42 - I see you what you're saying. Can you provide an example of how to use the -draw command with the context I've provided?
unix syntax (new line == \) in windows use (new line == ^)
Code: Select all
convert -size 720x480 xc:black -fill white -font Arial \
-draw "font-size 30 text 0,30 'TEST1' font-size 35 text 0,65 'TEST2'" result.png
Or use draw twice
Code: Select all
convert -size 720x480 xc:black -fill white -font Arial \
-pointsize 30 -draw "text 0,30 'TEST1'" \
-pointsize 35 -draw "text 0,65 'TEST2'" result.png
The text x,y y value needs to allow space for the pointsize (font-size) and for any space between the top and bottom text.
Or use annotate twice
Code: Select all
convert -size 720x480 xc:black -fill white -font Arial \
-pointsize 30 -annotate +0+30 "TEST1" \
-pointsize 35 -annotate +0+65 "TEST2" result.png
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2015-01-14T11:13:43-07:00
See my revised post above
abs2act
Posts: 10 Joined: 2014-08-12T20:41:45-07:00
Authentication code: 6789
Post
by abs2act » 2015-01-14T11:15:31-07:00
That's it! Thank you so much fmw42!!
Thanks to everyone else that replied. You guys rock!
abs2act
Posts: 10 Joined: 2014-08-12T20:41:45-07:00
Authentication code: 6789
Post
by abs2act » 2015-01-14T12:25:30-07:00
One last thing. So I'm trying to shift the lines x pixels over. Here's my code.
Code: Select all
convert -size 720x480 xc:black -fill white -font Arial \
-pointsize 30 -annotate +0+30 "TEST1" \
-pointsize 35 -annotate +0+65 "TEST2" \
-extent 720x480-50+0 result.png
The lines shift but for some reason I get a white bar on the left. I want the background to stay black.
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2015-01-14T16:48:11-07:00
So I'm trying to shift the lines x pixels over.
Just modify the +0 after annotate, that is the x offset from whatever -gravity you have set, which by default is northwest.
-annotate +Xoff+Yoff "your text"
So
Code: Select all
convert -size 720x480 xc:black -fill white -font Arial \
-pointsize 30 -annotate +50+30 "TEST1" \
-pointsize 35 -annotate +50+65 "TEST2" \
result.png
snibgo
Posts: 12159 Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Post
by snibgo » 2015-01-15T10:10:43-07:00
abs2act wrote: The lines shift but for some reason I get a white bar on the left. I want the background to stay black.
The white stripe comes from "-extent", which pads using the background colour. See
http://www.imagemagick.org/script/comma ... php#extent . The default background colour is white. Set it to whatever you want before "-extent".