PerlMagick distort() syntax

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

PerlMagick distort() syntax

Post by Ryland »

When I use the following command line:

Code: Select all

convert checks.png -matte -virtual-pixel transparent -distort Perspective "0,0,25,25 0,90,0,90 90,0,70,25 90,90,90,65" checks_distort.png
It distorts the image correctly, but when I use the same parameters in PerlMagick:

Code: Select all

use Image::Magick;

$checks = Image::Magick->new;
$checks->Set(size=>"90x90",matte=>"True");
$checks->Read('checks.png');

$checks->Distort(virtual-pixel=>"transparent", distort=>"Perspective", points=>"0,0,25,25 0,90,0,90 90,0,70,25 90,90,90,65");

$checks->Write("PNG24:checks_distort.png");
It returns the source image unchanged. What am I doing wrong?

I'm using ActivePerl 5.8.8 and ImageMagick 6.3.6 Q16 under Windows XP Pro.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: PerlMagick distort() syntax

Post by magick »

Use an array instead of a string: points=>[0,0,25,25 0,90,0,90 90,0,70,25 90,90,90,65].
Ryland

Re: PerlMagick distort() syntax

Post by Ryland »

magick wrote:Use an array instead of a string: points=>[0,0,25,25 0,90,0,90 90,0,70,25 90,90,90,65].
That causes a bunch of syntax errors. I replaced the spaces in the array with commas and that got rid of the syntax errors, but then the script still didn't work.

This is one of the most frustrating things about ImageMagick for me. Why doesn't the PerlMagick API use the same parameter names and values as the command line version? I can't count the number of times I've had this kind of problem.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: PerlMagick distort() syntax

Post by magick »

This works for us (we're using ImageMagbick 6.4.0-7):
  • $image->Distort('virtual-pixel'=>"transparent", type=>"Perspective", points=>[0,0,25,25,0,90,0,90,90,0,70,25,90,90,90,65]);
Ryland

Re: PerlMagick distort() syntax

Post by Ryland »

I just updated my IM install to 6.4.0-6, and now it doesn't work at all:

"Can't locate Image/Magick.pm in @INC (@INC contains: C:/Perl/site/lib C:/Perl/lib .) at affine.pl line 3."

so apparently the PerlMagick module didn't even get installed. When I try to install it manually, it says:

"ppm install failed: The PPD does not provide code to install for this platform."
Ryland

Re: PerlMagick distort() syntax

Post by Ryland »

OK, I managed to get PerlMagick installed (thanks to the "PerlMagic ppm install fails on Windows 2003 server and XP" thread a few threads below this one) and now the distort works.

My point still stands, though, it's ridiculous to have different parameter names and values between the command line and the Perl API. Why use a string for the points parameter in the command line version and an array of doubles in the API? That makes no sense.

Not to mention that in the PerlMagick documentation, the parameter is just given as "double". Not string, not array of doubles, just double.

http://www.imagemagick.org/script/perl-magick.php
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: PerlMagick distort() syntax

Post by magick »

We fixed the documentation so that the points parameter for Distort() states that it expects an array of floats. Thanks.
Post Reply