Gravity center, caption and wrapped text

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
sorpigal

Gravity center, caption and wrapped text

Post by sorpigal »

Using ImageMagick on the command line I can say

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
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:

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;
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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Gravity center, caption and wrapped text

Post by anthony »

Well you are quite correct in that gravity does not appear to work.

The documentation lists gravity with capitals, but it should be case-insensitive, and using capitals does not make any difference.

From my understanding it should work.

Moving this topic to 'Bugs'.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Gravity center, caption and wrapped text

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.6.5-6 Beta available by sometime tomorrow. Thanks.
Post Reply