Word Wrapping in MagickWand

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply
sambessey
Posts: 22
Joined: 2008-01-04T18:26:40-07:00

Word Wrapping in MagickWand

Post by sambessey »

Hi,

Is there a way of wordwrapping text in MagickWand for PHP? The forums reveal little helpful stuff....

Thanks
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Word Wrapping in MagickWand

Post by magick »

Use the caption: image format to wrap your text or roll your own with MagickQueryFontMetrics().
sambessey
Posts: 22
Joined: 2008-01-04T18:26:40-07:00

Re: Word Wrapping in MagickWand

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Word Wrapping in MagickWand

Post 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().
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Word Wrapping in MagickWand

Post 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);
}
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.
sambessey
Posts: 22
Joined: 2008-01-04T18:26:40-07:00

Re: Word Wrapping in MagickWand

Post 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
sambessey
Posts: 22
Joined: 2008-01-04T18:26:40-07:00

Re: Word Wrapping in MagickWand

Post by sambessey »

Anyone?
nord

Post by nord »

Moved to BUGS branch
Post Reply