Multiple Lines Problem

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?".
Post Reply
xypho

Multiple Lines Problem

Post by xypho »

I am using ImageMagick (Version: ImageMagick 6.2.8 )

I am trying to write a script to simplify the creation of stamps. I need to be able to center multiple lines of text that have different font formatting settings that they will get from user input.

I was hoping to use something such as :

Code: Select all

convert -font helvetica -pointsize 25 label:'line 1' -font helvetica -pointsize 12 label:'line2' -gravity center -append test01.png
here is the result
Image

My text seems to justify to the left size. Is there an easy solution to fix this?

Thanks,
Xypho
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Multiple Lines Problem

Post by snibgo »

It centres for me (IM 6.6.0-8). Try an upgrade.
snibgo's IM pages: im.snibgo.com
xypho

Re: Multiple Lines Problem

Post by xypho »

I am unable to update it's a godaddy shared server so my only hope is to get it to work with another means. Any ideas how to make it work in this version
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Multiple Lines Problem

Post by fmw42 »

append was only recently made gravity sensistive (v 6.4.8-2)

you will have to create two images and then composite them together to get them centered or possibly try montage with the two images.

Godaddy is the pits. I have tried numerous times to get them to upgrade IM or provide another current version, but they just ignore my request.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Multiple Lines Problem

Post by fmw42 »

this seems to work for me

convert -font arial -pointsize 25 label:'line 1' -trim +repage tmp1.gif
convert -font arial -pointsize 12 label:'line2' -trim +repage tmp2.gif
montage tmp1.gif tmp2.gif -tile 1x -geometry +2+2 test01.png

Use the geometry to adjust the spacing between images and on its sides
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Multiple Lines Problem

Post by fmw42 »

this also works with one command line

montage -label "" \( -font arial -pointsize 25 label:'line 1' \) \
\( -font arial -pointsize 12 label:'line2' \) \
-tile 1x -geometry +0+5 test02.png


see discussion at viewtopic.php?f=3&t=16324
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Multiple Lines Problem

Post by anthony »

Quote from IM examples, Layers Append...
Before IM v6.4.7 it was much more difficult to align appended images, and generally involved using a "-flop" for right alignment. Or using "-extent" or "-border" to adjust the image width for centered aligned appends.

For example, this will work with an older 6.3.2 version of IM...

Code: Select all

  convert rose:  -background SkyBlue label:Rose \
          -background White -gravity center -extent 200x \
          -append -trim +repage   append_center_old.jpg
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply