Gravity center, caption and wrapped text
Posted: 2010-10-14T13:51:47-07:00
Using ImageMagick on the command line I can say
To produce precisely the output I'm looking for. What I'd like to do is the same thing but within PerlMagick so that I don't have to keep reading and writing files as I perform various other steps. Here's what I have so far:
And this produces the same output, except that the resulting text is not centered.
The only documentation on doing caption from PerlMagick that I could find used a syntax which is certainly wrong and didn't work when I tried it. (It was essentially the same as the above, only calling Write instead of Read.) I based this "read caption" syntax on some MagicWand examples, where it is claimed that this will result in centered text. Clearly something is different for PerlMagick.
So, the question: How can I make PerlMagick respect gravity in this case? How do I get multi-line, centered and word-wrapped text via PerlMagick?
Any insight you could share would be extremely helpful.
Incidental details: ImageMagick 6.6.0-4 2010-08-11 Q16, debian perlmagick package version 8:6.6.0.4-2.2
Code: Select all
convert -background '#0000' -fill white -stroke black -strokewidth 3 -gravity center -pointsize 78 -size 568x1000 caption:'Lorem ipsum etc etc' -trim out.png
Code: Select all
use strict;
use warnings;
use Image::Magick;
my $im = new Image::Magick;
my $e = $im->Set(
background => '#0000',
fill => 'white',
stroke => 'black',
strokewidth => 3,
gravity => 'center',
pointsize => 78,
size => '586x1000',
);
die $e if $e;
$e = $im->Read("caption:Lorem ipsum etc etc");
die $e if $e;
$e = $im->Trim();
die $e if $e;
$e = $im->Write('out.png');
die $e if $e;
The only documentation on doing caption from PerlMagick that I could find used a syntax which is certainly wrong and didn't work when I tried it. (It was essentially the same as the above, only calling Write instead of Read.) I based this "read caption" syntax on some MagicWand examples, where it is claimed that this will result in centered text. Clearly something is different for PerlMagick.
So, the question: How can I make PerlMagick respect gravity in this case? How do I get multi-line, centered and word-wrapped text via PerlMagick?
Any insight you could share would be extremely helpful.
Incidental details: ImageMagick 6.6.0-4 2010-08-11 Q16, debian perlmagick package version 8:6.6.0.4-2.2