Page 1 of 1

Write to an image (text centered, kerning,etc)

Posted: 2013-10-01T14:12:39-07:00
by myspacee
Hello,
for job i need to write some lines on an white image. But i've some limit and rules to follow.

I want to obtain this:
Image

start from this script:
(last IM version, Windows XP)

Code: Select all

convert starting_white_template.tif -font AmplitudeComp-Regular -weight 700  -pointsize 200 -draw "gravity north fill black text 0,300 'OIL' " corpo.tif
convert corpo.tif -font AmplitudeComp-Regular -weight 700  -pointsize 200 -draw "gravity north fill black text 0,500 'FOUND' " corpo.tif
convert corpo.tif -font AmplitudeComp-Regular -weight 700  -pointsize 200 -draw "gravity north fill black text 0,700 'IN CENTRAL PARKING BLA BLA' " corpo.tif
but I need help :
- center text in my start template
- fit all text horizontally when is too long (eg: 'IN CENTRAL PARKING BLA BLA')
- better syntax as see in doc for switch 'label:' and pass my text in this way :

Code: Select all

label:'First\nSecond\nThird'
Read about Kerning, but I need help to apply this 'effect' to all my text, and not only for long one.

Thank you for your attention and help,
m.

Re: Write to an image (text centered, kerning,etc)

Posted: 2013-10-01T14:39:25-07:00
by snibgo
You could use one command, eg:

Code: Select all

convert -size 2400x1200 xc:White ^
  -gravity Center ^
  -weight 700 -pointsize 200 ^
  -annotate 0 "OIL\nFOUND\nIN CENTRAL PARK" ^
  oil.png
See also http://www.imagemagick.org/Usage/text/

Re: Write to an image (text centered, kerning,etc)

Posted: 2013-10-01T16:08:29-07:00
by fmw42
You can also try using caption: and optionally specify only the width.


convert -background white \
-gravity Center \
-weight 700 -pointsize 200 \
caption:"OIL FOUND IN CENTRAL PARK BLA BLA BLA" \
oil.png


convert -background white -size 1500x \
-gravity Center \
-weight 700 -pointsize 200 \
caption:"OIL FOUND IN CENTRAL PARK BLA BLA BLA" \
oil2.png


convert -background white -size 1500x \
-gravity Center \
-weight 700 -pointsize 200 -kerning 10 \
caption:"OIL FOUND IN CENTRAL PARK BLA BLA BLA" \
oil3.png

Re: Write to an image (text centered, kerning,etc)

Posted: 2013-10-02T01:10:19-07:00
by myspacee
Thank you both for reply.

Re-starting from snibgo syntax, but i must change strategy.
(must respect given text, can't reassemble words)

I need to create final image with fix Width and Height; this image it's a piece of my final product.
Must have W & H fix to assemble with other, given, pieces.

-- first step
I think to create a starting image with H=1000 and W=5000. This allow any phrase to fit in Width.
Then trim horizontally. From online doc i found way to trim :

Code: Select all

convert oil4.png -trim +repage trim_oneside.gif
but command trim also Height that i want to preserve, how trim white only horizontally ?

-- second step
I obtained a rectangle from first step, how use composite to center this image in another bigger one ?

thank you again for any help,
m.

Re: Write to an image (text centered, kerning,etc)

Posted: 2013-10-02T09:32:06-07:00
by snibgo
myspacee wrote:but command trim also Height that i want to preserve, how trim white only horizontally?
See http://www.imagemagick.org/Usage/crop/#trim_oneside
myspacee wrote:I obtained a rectangle from first step, how use composite to center this image in another bigger one?
Possibly with "-gravity center" and "-compose Over -composite". See http://www.imagemagick.org/Usage/compose/

Re: Write to an image (text centered, kerning,etc)

Posted: 2013-10-02T09:47:50-07:00
by fmw42
You cannot specify width and height AND pointsize and expect it to fit all the time. If you pointsize is too big, it will exceed the boundaries of the width and height.

You can specify width and height and leave off the pointsize and use caption: to make it best fit that size. The pointsize will be determined to make it fit.



convert -background white -size 2400x1200 \
-gravity Center \
-weight 700 \
caption:"OIL FOUND IN CENTRAL PARK BLA BLA BLA" \
oil4.png