Search code examples
javaimagemagickimagemagick-convert

Java + ImageMagick: how to figure out height of text based on width?


I'm using ImageMagick with Java in my project. I have a command:

 convert -background lightblue  -fill blue  -font Tahoma -pointsize 36 -size 320x caption:'This is a very long caption line.' caption.gif

This command will create an image named "caption.gif"
The image's width is 320px.
Is there any way that I can figure out the image's height without creating image. Thanks!


Solution

  • Yes, you can do this:

    convert -font Tahoma -pointsize 36 -size 320x caption:'This is a very long caption line.' -format "%h" info:
    88