2

I want text show in vertically in the imagick image.

For example, I have "test" text but I want the text like that:

t
e
s
t

Do you have any idea? Thanks.

Paul T.
  • 4,703
  • 11
  • 25
  • 29

1 Answers1

1

Ooops! I see you are asking for a PHP solution. I will not delete this, instead I'll leave it as it may be useful for others in future who may be looking for a command-line version.

As no-one seems to want to do a PHP version for you, here is one approach that should work - just in pseudo-code for now:

create empty output image with transparent background
for each letter in the string do
   create a new transparent image larger than necessary
   use annotateImage() to draw single letter on transparent image
   use trimImage() to get rid of superfluous space around image
   repage image with setImagePage(0, 0, 0, 0) 
   add a small transparent border around the image so letters don't touch - use borderImage()
   append this image to vertical stack with appendImages(true)
done

You can do something like this, though it is rather ugly!

printf "Vertical" | perl -pe 's/(.)/\1\n/g' |
   convert -background cyan -fill magenta -pointsize 36 -gravity center label:@- result.gif

enter image description here

I am just replacing each character with itself followed by a newline in the Perl part and then piping that into the convert command where the label:@- reads it from stdin.

Mark Setchell
  • 191,897
  • 31
  • 273
  • 432