Rotate around center - Distort SRT

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
johnfl68
Posts: 33
Joined: 2012-07-09T18:31:26-07:00
Authentication code: 13

Rotate around center - Distort SRT

Post by johnfl68 »

Hello:

I'm trying to get a arrow png to rotate to a direction around the center.

I tried rotate, but that seems to rotate around the corner.

I have found talk about using Distort SRT instead, but there seem to be no good Perl examples for use.

I tried this:

Code: Select all

my $windicon = Image::Magick->new;
$windicon->Read(filename => "/arrows/arrow-white2.png");
$windicon->Set(background => 'transparent');
$windicon->Distort(virtual-pixel=>'transparent', method=>'ScaleRotateTranslate', $windBearing);
In which Perls 'use strict' had a hissy about:

Code: Select all

Bareword "virtual" not allowed while "strict subs" in use
So anyone have any ideas on how this is supposed to work in perl?

Is there anyplace with better documentation for using Image::Magick in perl then here? There doesn't really seem to be any good documentation or resources around for using IM in perl unfortunately.

Any help is greatly appreciated.

Thanks!

John
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Rotate around center - Distort SRT

Post by fmw42 »

I tried rotate, but that seems to rotate around the corner.
I am not a Perlmagick user.

However, rotate should rotate about the center, unless you have some strange virtual canvas in your input png and then it will rotate about the center of the virtual canvase. Try removing the virtual canvas from the input before rotating. In command line it is +repage. In the API's it is likely something like page (0,0) or setpage (0,0). I am not sure of the API syntax.
johnfl68
Posts: 33
Joined: 2012-07-09T18:31:26-07:00
Authentication code: 13

Re: Rotate around center - Distort SRT

Post by johnfl68 »

fmw42 - for what ever reason, using rotate seems to use a convoluted method to create the rotation, and depending on the degree's of rotation, does not give good effects:

viewtopic.php?f=1&t=17792#p67335

In the case of what I am doing, it is a circle icon with an arrow in the center of the circle. The circle is uniform and centered in a 50x50 png, however using rotate, the circle is sometime off center based on the where between 0-360 the rotation is.

From everything I have read, Distort SRT is the way to go, but I have yet to find any perl examples of use on line, after several hours of searching.

Hopefully someone will know the answer.

John
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Rotate around center - Distort SRT

Post by fmw42 »

Yes that is the half pixel issue that Anthony points out that he has built into the distort operators. But I do not know how the do it in any API including Perlmagick. I just use the command line. Sorry I cannot help further. I can only refer you to http://www.imagemagick.org/script/perl-magick.php and distort section
Post Reply