getImageWidth (); $height = $im->getImageHeight (); if ($long == "Original") $long = max ($width, $height); if ($aspect_ratio > 1) $sw = $long; else $sw = $long * $aspect_ratio; $sh = $sw / $aspect_ratio; $im->setImageVirtualPixelMethod ($vp); if ($db != 0) { if ($aspect_ratio < 1) $ar = pow (1 / $aspect_ratio, 2); else $ar = pow ($aspect_ratio, 2); if ($db > 0) $ddx = $ddy = 1 - ($ar + 1) * $db; else { $ddx = 1 - $db * $ar; $ddy = 1 - $db; } if ($aspect_ratio > 1) $args = array (0, $db, 0, $ddx, 0, $db, 0, $ddy); else $args = array (0, $db, 0, $ddy, 0, $db, 0, $ddx); $im->distortImage (Imagick::DISTORTION_BARREL, $args, false); } if (isset ($fourpoint) and $fourpoint == "on") { if (isset ($stretchlock) and $stretchlock == "on") $stretchy = $stretchx; $width_new = (sqrt (pow ($cx[3] - $cx[0], 2) + pow ($cy[3] - $cy[0], 2)) + sqrt (pow ($cx[2] - $cx[1], 2) + pow ($cy[2] - $cy[1], 2))) / 2; $stx = (100 + $stretchx) / 100; $height_new = (sqrt (pow ($cx[1] - $cx[0], 2) + pow ($cy[1] - $cy[0], 2)) + sqrt (pow ($cx[2] - $cx[3], 2) + pow ($cy[2] - $cy[3], 2))) / 2; $sty = (100 + $stretchy) / 100; $minx = round (((($cx[0] + $cx[1]) / 2) + $sx - $stretchx * $width_new / 200) / $scale); $maxx = $minx + round ($stx * $width_new / $scale); $miny = round (((($cy[0] + $cy[3]) / 2) + $sy - $stretchy * $height_new / 200) / $scale); $maxy = $miny + round ($sty * $height_new / $scale); for ($i = 0; $i < 4; $i++) { $scx[$i] = round ($cx[$i] / $scale); $scy[$i] = round ($cy[$i] / $scale); } $points = array ($scx[0], $scy[0], $minx, $miny, $scx[1], $scy[1], $minx, $maxy, $scx[2], $scy[2], $maxx, $maxy, $scx[3], $scy[3], $maxx, $miny); $im->distortImage (Imagick::DISTORTION_PERSPECTIVE, $points, false); } if ($rotate != 0) $im->rotateImage ($gcolour, $rotate); $im->resizeImage ($sw, $sh, Imagick::FILTER_SINC, 0.7); return $im; } extract ($_POST); $b = "\r\n"; for ($i = 2; $i < 640 / 3; $i++) if (640 % $i == 0 and 480 % $i == 0) $gridarray[] = $i; $gcarray = array ("black", "white", "gray", "yellow", "green", "red", "blue", "cyan", "pink"); $vparray = array ("black", "white", "gray", "edge", "mirror", "transparent"); if (isset ($grfile_new) and $grfile_new) { $grfile = $grfile_new; unset ($scale, $gcolour, $virtualpixel, $savetosize, $cx, $cy, $sx, $sy, $rotate, $db, $grid, $fourpoint, $stretchx, $stretchy, $orix, $oriy, $aspect_ratio); } if (!isset ($gcolour)) $gcolour = "black"; if (!isset ($virtualpixel)) $virtualpixel = "black"; if (!isset ($savetosize)) $savetosize = 640; if (!isset ($rotate)) $rotate = 0; if (!isset ($db)) $db = 0; if (!isset ($sx)) $sx = 0; if (!isset ($sy)) $sy = 0; if (!isset ($stretchx)) $stretchx = 0; if (!isset ($stretchy)) $stretchy = 0; switch ($virtualpixel) { case "black": $vp = imagick::VIRTUALPIXELMETHOD_BLACK; break; case "white": $vp = imagick::VIRTUALPIXELMETHOD_WHITE; break; case "gray": $vp = imagick::VIRTUALPIXELMETHOD_GRAY; break; case "edge": $vp = imagick::VIRTUALPIXELMETHOD_EDGE; break; case "mirror": $vp = imagick::VIRTUALPIXELMETHOD_MIRROR; break; case "transparent": $vp = imagick::VIRTUALPIXELMETHOD_TRANSPARENT; break; } $corners = array ("Upper Left", "Lower Left", "Lower Right", "Upper Right"); echo "$b"; echo "$b"; echo "Lee Traynor's Correctrix$b"; echo "$b"; echo "$b"; echo "$b"; echo "$b"; echo "

Lee Traynor's Correctrix

$b"; echo "
$b"; echo "$b"; if (isset ($grfile) and $grfile) { if (!isset ($scale)) { $im = new Imagick ($grfile); $width = $im->getImageWidth (); $height = $im->getImageHeight (); $aspect_ratio = $width / $height; if ($aspect_ratio > 1) $sw = 1280; else $sw = round (1280 * $aspect_ratio); $sh = round ($sw / $aspect_ratio); $scale = $width / $sw; $im->resizeImage ($sw, $sh, Imagick::FILTER_SINC, 0.7); $im->writeImage ("Source.tif"); $im->destroy (); } $im = transform ("source.tif", 640, $scale); if (isset ($grid) and $grid != 0) { $draw = new ImagickDraw (); $draw->setStrokeColor ($gcolour); $hdist = round ($width / $grid / 2); $vdist = round ($height / $grid / 2); for ($i = 1; $i < $grid; $i++) { $draw->line ($hdist * $i, 0, $hdist * $i, $height / 2); $draw->line (0, $vdist * $i, $width / 2, $vdist * $i); } $im->drawImage ($draw); $draw->destroy (); } $im->writeImage ("Sample.png"); $im->destroy (); echo "$b"; echo "$b$b"; echo "$b$b"; echo "$b$b$b"; echo "$b"; for ($j = 0; $j < 4; $j++) { echo "$b"; echo "$b"; } echo "$b"; echo "$b"; echo "$b$b"; echo "$b$b"; echo "$b$b"; echo "$b$b"; echo "$b$b"; echo "$b$b"; echo "$b"; echo ""; echo "$b"; echo "$b"; if ($submit == "Save from Original") { $im = transform ($grfile, $savetosize, 1); $file_name = "Crtrix Samples/" . substr ($grfile, 0, strrpos ($grfile, ".")) . "_LT.png"; $im->writeImage ($file_name); $im->destroy (); } } echo "$b$b"; echo "$b"; echo "
$grfile
$b"; echo "$b$b
$b
"; if (isset ($orix) and isset ($oriy) and $orix and $oriy) echo "Origin: $orix, $oriy
"; else echo "Origin not set$b"; echo "$b$b
Four Point Transformation
$corners[$j]
X: Y:
Shift (- up/left, + down/right)
X: Y:
Grid: $b"; echo "$b"; echo "
Stretch: Lock$b
X: $b"; echo "Y: $b"; echo "
Dersch's B: $b
Virtual Pixel: $b
Save to size: $b
Rotate: °
Load Image: $b"; if (isset ($grfile)) echo "$b"; echo "
$b"; echo "
$b"; ?>