Syntax-Documentation Inconsistency?

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
SidShakal

Syntax-Documentation Inconsistency?

Post by SidShakal »

On the PerlMagick documentation page the following example code is given, intended to draw three red rectangles in a drawing area:

Code: Select all

   $image->Draw(fill=>'red', primitive=>'rectangle',
     points=>'20,20 100,100  40,40 200,200  60,60 300,300');
I've tried this (and several variations on this), and it seems to silently fail as if the value for 'points' is invalid.

I'm wondering then, is it the page that's wrong, or is it something on my end?

Also, here's the source to a perl script to try it yourself:

Code: Select all

#!/usr/bin/perl
use strict;
use warnings;

use Image::Magick;

my $image = Image::Magick->new;
$image->Set('size'=>'320x320');
$image->ReadImage('xc:white');

$image->Draw('fill'=>'red', 'primitive'=>'rectangle',
        'points'=>'20,20 100,100  40,40 200,200  60,60 300,300');

# To achieve what was intended by the previous line, uncomment
#   the following three:
#$image->Draw('fill'=>'red', 'primitive'=>'rectangle', 'points'=>'20,20 100,100');
#$image->Draw('fill'=>'red', 'primitive'=>'rectangle', 'points'=>'40,40 200,200');
#$image->Draw('fill'=>'red', 'primitive'=>'rectangle', 'points'=>'60,60 300,300');

# The following line may be used to display the image on the screen,
#   at least under X11
#$image->Display($ENV{'DISPLAY'});

$image->Write('output.png');
I'd appreciate any insight,
-- Sid
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Syntax-Documentation Inconsistency?

Post by magick »

Grab the ImageMagick source distribution and take a look at ImageMagick-6.4.3/PerlMagick/demo/shapes.pl. It has a working example of drawing with PerlMagick.

To determine why Draw() is failing, check for exceptions:
  • $x = $image->Draw(...);
    echo $x if "$x";
Post Reply