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 "