Hi,
Is there a way of wordwrapping text in MagickWand for PHP? The forums reveal little helpful stuff....
Thanks
Word Wrapping in MagickWand
Re: Word Wrapping in MagickWand
Use the caption: image format to wrap your text or roll your own with MagickQueryFontMetrics().
Re: Word Wrapping in MagickWand
Hi,
I want to avoid mixing ImageMagick commands in with the MagickWand API (Plus I can't do exec commands on my web server). I know I can roll my own, but I am sure having the caption: functionality built into the code would be far faster than anything I can write in PHP to do this.. Are there any plans to add it in to a future release?
I'll post up my solution once I work it out anyway.
Thanks
I want to avoid mixing ImageMagick commands in with the MagickWand API (Plus I can't do exec commands on my web server). I know I can roll my own, but I am sure having the caption: functionality built into the code would be far faster than anything I can write in PHP to do this.. Are there any plans to add it in to a future release?
I'll post up my solution once I work it out anyway.
Thanks
Re: Word Wrapping in MagickWand
We have no plans to add word wrapping to ImageMagick other than the caption: format which performs a rudimentary word wrapping, see http://www.imagemagick.org/Usage/text/#caption. Note, you can access the caption: format directly with MagickReadImage().
-
- Posts: 1015
- Joined: 2005-03-21T21:16:57-07:00
Re: Word Wrapping in MagickWand
This C program uses MagickWand and caption: to generate wordwrapped text from a file. It should be easy to adapt it to PHP.
The call to MagickSetSize sets the required width of the image (250).
Pete
The call to MagickSetSize sets the required width of the image (250).
Pete
Code: Select all
#include <windows.h>
#include <wand/magick_wand.h>
void test_wand(LPTSTR lpCmdLine)
{
MagickWand *mw;
MagickWandGenesis();
mw = NewMagickWand();
MagickSetSize(mw,250,100);
MagickReadImage(mw, "caption:@caption_text.txt");
MagickWriteImage(mw,"caption.gif");
mw = DestroyMagickWand(mw);
}
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
See my message in this topic for a link to a zip of all the files.
Re: Word Wrapping in MagickWand
Sorry I am still a newbie to this, maybe I am doing something wrong, but:
<?php
session_start();
$mw = NewMagickWand();
MagickSetSize($mw,250,100);
MagickReadImage($mw, "caption:HELLO WORLD");
#MagickEchoImageBlob($mw);
MagickWriteImage($mw,"caption.gif");
?>
1) I can't blob the result (i.e. I must write it to an image)
2) I see the filename prepended to my caption
Please can you tell me why?
Thanks
<?php
session_start();
$mw = NewMagickWand();
MagickSetSize($mw,250,100);
MagickReadImage($mw, "caption:HELLO WORLD");
#MagickEchoImageBlob($mw);
MagickWriteImage($mw,"caption.gif");
?>
1) I can't blob the result (i.e. I must write it to an image)
2) I see the filename prepended to my caption
Please can you tell me why?
Thanks