Hi . I need to add a two line overlay to an existing picture b.jpg, having width of 1024px with c.jpg as output:
convert B.jpg ( -background none -size 1024x -fill white -font Calibri label:"this is line1\n this is line2" ) -gravity Center -compose over -composite C.jpg
and line2 isn't showing.
What am I doing wrong?
multiple line autofit text overlay problem
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: multiple line autofit text overlay problem
For multi-line "label:", you need to specify both width and height. You could trim the result.
snibgo's IM pages: im.snibgo.com
Re: multiple line autofit text overlay problem
Thank you for your answer.
I've tried your suggestion and now the text isn't centered anymore, but instead it's aligned top left.
This is the command used:
convert B.jpg ( -background none -size 1024x768 -fill white -font Calibri label:"this is line1\n this is line2" ) -gravity Center -compose over -composite C.jpg
I've tried your suggestion and now the text isn't centered anymore, but instead it's aligned top left.
This is the command used:
convert B.jpg ( -background none -size 1024x768 -fill white -font Calibri label:"this is line1\n this is line2" ) -gravity Center -compose over -composite C.jpg
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: multiple line autofit text overlay problem
Put "-gravity Center" before "label:".
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: multiple line autofit text overlay problem
I am not sure what you mean by not centered any more. If you mean that the text image is not centered in the background because of uneven transparent borderinig, then try adding -trim +repage as
If you mean that the two lines of text are not center justified, then add -gravity center before label: as above. Or use caption: rather than label: and do not put in new lines using "\n". Adjust the width so that the autowrap breaks the text into two lines as desired.
You could also just write the text directly into image B.jpg using -annotate.
See
http://www.imagemagick.org/Usage/text/
Code: Select all
convert B.jpg ( -background none -size 1024x768 -fill white -font Calibri -gravity center label:"this is line1\n this is line2" -trim +repage ) -gravity Center -compose over -composite C.jpg
You could also just write the text directly into image B.jpg using -annotate.
See
http://www.imagemagick.org/Usage/text/
Re: multiple line autofit text overlay problem
Thank you for your answers. That solved the problem.
Now I want to make the text to look a bit 'italic' and did this:
convert B.jpg ( -background none -size 1024x768 -fill white -font Calibri -gravity center -annotate 0x20+50+50 label:"this is line1\n this is line2" -trim +repage ) -gravity Center -compose over -composite C.jpg
and got this error:
convert.exe: no images defined `C.jpg' @ error/convert.c/ConvertImageCommand/3212.
Is it possible to accomplish this using -annotate? or should I just use a font that looks italic?
Now I want to make the text to look a bit 'italic' and did this:
convert B.jpg ( -background none -size 1024x768 -fill white -font Calibri -gravity center -annotate 0x20+50+50 label:"this is line1\n this is line2" -trim +repage ) -gravity Center -compose over -composite C.jpg
and got this error:
convert.exe: no images defined `C.jpg' @ error/convert.c/ConvertImageCommand/3212.
Is it possible to accomplish this using -annotate? or should I just use a font that looks italic?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: multiple line autofit text overlay problem
Your syntax is wrong. Either use -annotate or label: but not both
Pick a pointsize and use
Adjust the +0+0 offsets as desired.
If you need the two lines of text justified, then you probably want to use label: as before, but with an italics font. Or install Pango and use pango: and select italic styling. Or do annotate twice, once for each line. See example at http://www.imagemagick.org/Usage/text/#annotate
See http://www.imagemagick.org/Usage/text/#pango
Pick a pointsize and use
Code: Select all
convert B.jpg -fill white -font Calibri -pointsize X -gravity center -annotate 0x20+0+0 "this is line1\n this is line2" C.jpg
If you need the two lines of text justified, then you probably want to use label: as before, but with an italics font. Or install Pango and use pango: and select italic styling. Or do annotate twice, once for each line. See example at http://www.imagemagick.org/Usage/text/#annotate
See http://www.imagemagick.org/Usage/text/#pango
Re: multiple line autofit text overlay problem
Using -pointsize won't allow autofit, Pango is also a bit too much, so I guess I'll go look up a more appropriate font.
Thank you all for your help.
Thank you all for your help.