Page 1 of 1

multiple line autofit text overlay problem

Posted: 2015-07-01T05:10:49-07:00
by magatyb
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?

Re: multiple line autofit text overlay problem

Posted: 2015-07-01T07:13:25-07:00
by snibgo
For multi-line "label:", you need to specify both width and height. You could trim the result.

Re: multiple line autofit text overlay problem

Posted: 2015-07-01T08:48:38-07:00
by magatyb
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

Re: multiple line autofit text overlay problem

Posted: 2015-07-01T09:05:20-07:00
by snibgo
Put "-gravity Center" before "label:".

Re: multiple line autofit text overlay problem

Posted: 2015-07-01T09:08:53-07:00
by fmw42
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

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
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/

Re: multiple line autofit text overlay problem

Posted: 2015-07-01T09:33:05-07:00
by magatyb
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?

Re: multiple line autofit text overlay problem

Posted: 2015-07-01T10:43:47-07:00
by fmw42
Your syntax is wrong. Either use -annotate or label: but not both

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
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

Re: multiple line autofit text overlay problem

Posted: 2015-07-01T10:58:43-07:00
by magatyb
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.