Page 1 of 1
Word Wrapping in MagickWand
Posted: 2008-12-16T13:47:57-07:00
by sambessey
Hi,
Is there a way of wordwrapping text in MagickWand for PHP? The forums reveal little helpful stuff....
Thanks
Re: Word Wrapping in MagickWand
Posted: 2008-12-16T17:00:28-07:00
by magick
Use the caption: image format to wrap your text or roll your own with MagickQueryFontMetrics().
Re: Word Wrapping in MagickWand
Posted: 2008-12-17T04:53:28-07:00
by sambessey
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
Re: Word Wrapping in MagickWand
Posted: 2008-12-17T06:49:21-07:00
by magick
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().
Re: Word Wrapping in MagickWand
Posted: 2008-12-17T09:11:12-07:00
by el_supremo
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
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);
}
Re: Word Wrapping in MagickWand
Posted: 2008-12-20T15:37:30-07:00
by sambessey
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
Re: Word Wrapping in MagickWand
Posted: 2008-12-26T11:50:56-07:00
by sambessey
Anyone?
Posted: 2009-01-16T14:38:00-07:00
by nord
Moved to BUGS branch