Cubby
Cubby

Reputation: 156

ImageMagick: Vertically Center Text?

I'm trying to vertically center text in an image using ImageMagick.

For example, I want an image that's 200 pixels high with the word, "TEST," vertically centered in the image.

And I don't want to specify the width of the image. I want ImageMagick to compute the image width based upon the width of the text.

The -extent parameter requires both width and height so I can't use that.

I'm using ImageMagick 6.4.0 01/19/10 Q16 for Cygwin. This appears to be the latest Cygwin version.

Thanks!

Upvotes: 1

Views: 2710

Answers (1)

moropus
moropus

Reputation: 3782

Don't specify width in -size parameter and use label:

convert -size x200 -background red -gravity Center \ 
        -pointsize 10 label:"TEST" test.png

Upvotes: 2

Related Questions