Search code examples
imagemagickimagemagick-convert

convert text with leading space to image using imagemagick


I'm trying to convert a text label into image using imagemagick's convert util following the guide at official page

I'm using the following command.

convert -background lightblue -pointsize 72 label:" spaces " label.gif

Although my text as leading whitespace, the output image has no space in the front. Spaces are getting trimmed. Trailing spaces have no issue though. I've tried the solution given at this SO question too in vain.

enter image description here


Solution

  • While I had typed this question and was waiting to post it, I figured out a way by guessing ;-)

    The solution is simply to escape the first space with blackslash.

    convert -background lightblue -pointsize 72 label:"\ spaces " spaces.gif

    enter image description here