Deskew() in Perl

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
romey-rome
Posts: 3
Joined: 2011-01-15T02:57:05-07:00
Authentication code: 8675308

Deskew() in Perl

Post by romey-rome »

Hi,

Can someone explain this:

Deskew geometry=>string,threshold=>double

I don't understand what it's looking for. I always got the results I got from the command line with simply -deskew 40%, but I'm unsure how to get the same results with PerlMagick (geometry of what? threshold of 0.0-1.0, or 0-100, ?).

Thanks!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Deskew() in Perl

Post by magick »

Use $image->Deskew('40%'). If you use the threshold parameter it is scaled from 0 to QuantumRange. For the Q16 version of ImageMagick, use a value from 0 to 65535.
romey-rome
Posts: 3
Joined: 2011-01-15T02:57:05-07:00
Authentication code: 8675308

Re: Deskew() in Perl

Post by romey-rome »

Thanks for the reply.

Unfortunately, that was the first thing I tried. I get my tif, but it does no Deskewing.

Code: Select all

sub do_magick {
        my $im = Image::Magick->new;
        my $ppm = $_[0];
        $im->Read($ppm);
        $im->Deskew('40%');
        $im->Write($basenm . "_pldk.tif");
}
ImageMagick-6.6.7-0
ImageMagick-perl-6.6.7-0
ImageMagick-devel-6.6.7-0
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Deskew() in Perl

Post by magick »

ImageMagick cannot deskew every image. It is sensitive to the image and the threshold. Post a URL to your image here so we can reproduce the problem and trace why ImageMagick does not discover the deskewing factor.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Deskew() in Perl

Post by fmw42 »

From my limited experience with -deskew (in command line) it works best for images rotated or skewed less than 5 degrees. Above that the results are problematic. I have an unrotate bash shell script that works for larger rotations (see link below). But I have no idea how to convert it to PerlMagick.
romey-rome
Posts: 3
Joined: 2011-01-15T02:57:05-07:00
Authentication code: 8675308

Re: Deskew() in Perl

Post by romey-rome »

I'll try to get a non-company document working sample.

Just to add, the document I am trying in Perl deskews perfectly with convert.
Post Reply