Skip Menu | will be shut down on March 1st, 2021.

This queue is for tickets about the Imager CPAN distribution.

Maintainer(s)' notes

Tickets for Imager are now on github at

Report information
The Basics
Id: 31244
Status: resolved
Priority: 50/
Queue: Imager

Owner: TONYC [...]
Requestors: TONYC [...]

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)

Subject: det operator for transform2 + sample
Date: Thu, 6 Dec 2007 10:32:08 +1100
To: bugs-Imager [...]
From: Tony Cook <tony [...]>
Download (untitled) / with headers
text/plain 2.1k
----- Forwarded message from Richard Fairhurst <> ----- X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on X-Spam-Level: Date: Wed, 05 Dec 2007 22:09:33 +0000 From: Richard Fairhurst <richard@xxx> To: Subject: Straightening images with transform2 X-MIME-Autoconverted: from quoted-printable to 8bit by id lB5M9lnj009169 Hello again Tony, Thought I'd let you know what I've been doing with Imager now it's working on my Mac! I've been using it to rectify ("square up") a load of roughly scanned maps, so that an arbitrary quadrilateral is resized into a square. The transform2 function is ideal for that. To make the expression shorter, I added a simple determinant function to the parser: * in regmach.h: rbc_det, /* det(ra, rb, rc, rd) -> r */ * in regmach.c: case rbc_det: nout = na*nd-nb*nc; break; Then this code to transform it: ---cut--- #!/usr/bin/perl -w # Convert quadrilateral to square use Imager; $src=Imager->new(); $src->open(file=>"oldmap_200px.jpg"); # example co-ordinates of quadrilateral $x0=12; $y0=4; # top left $x1=157; $y1=0; # top right $x2=140; $y2=150; # bottom right $x3=27; $y3=159; # bottom left $code=<<EOF; xa=((h-y)*x0+y*x3)/h; ya=((h-y)*y0+y*y3)/h; xb=((h-y)*x1+y*x2)/h; yb=((h-y)*y1+y*y2)/h; xc=((w-x)*x0+x*x1)/w; yc=((w-x)*y0+x*y1)/w; xd=((w-x)*x3+x*x2)/w; yd=((w-x)*y3+x*y2)/w; d=det(xa-xb,ya-yb,xc-xd,yc-yd); d=if(d==0,1,d); px=det(det(xa,ya,xb,yb),xa-xb,det(xc,yc,xd,yd),xc-xd)/d; py=det(det(xa,ya,xb,yb),ya-yb,det(xc,yc,xd,yd),yc-yd)/d; return getp1(px,py); EOF $newimg=Imager::transform2({ expr=>$code, width=>200, height=>200, constants=>{x0=>$x0,y0=>$y0, x1=>$x1,y1=>$y1, x2=>$x2,y2=>$y2, x3=>$x3,y3=>$y3}}, ($src)); $newimg->write(file=>"output_imager.jpg"); ---cut--- Thought you might be interested to see what people are doing with Imager - feel free to include this in the sample code. Best wishes Richard Show quoted text
----- End forwarded message -----
fixed in svn
Fixed in 0.62

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to