error_reporting(0); include("functions.php"); $h1 = "DJ Mike's Image Maker 2"; $h2 = "Crop/Chop/Splice"; ## if ( $_GET[action] == "Reset" ) { header("location:$self"); exit; } # if all vars set, make image if ( $_GET[ul_x] && $_GET[ul_y] && $_GET[lr_x] && $_GET[lr_y] && $_GET[action] ) { $ul_x = (int)$_GET[ul_x]; $ul_y = (int)$_GET[ul_y]; if ( $ul_x < 1 ) { $ul_x = 1;} if ( $ul_y < 1 ) { $ul_y = 1;} $lr_x = (int)$_GET[lr_x]; $lr_y = (int)$_GET[lr_y]; $w = (int)abs($ul_x - $lr_x); $h = (int)abs($ul_y - $lr_y); $image = new Imagick($_SESSION[path]); ################## if ( $_GET[action] == "Splice" ) { foreach ($image as $frame) { $frame->spliceimage( $w, $h, $ul_x, $ul_y); } } ################## if ( $_GET[action] == "Chop" ) { foreach ($image as $frame) { $frame->chopimage( $w, $h, $ul_x, $ul_y); } } ################## if ( $_GET[action] == "Crop" ) { foreach ($image as $frame) { $frame->cropimage( $w, $h, $ul_x, $ul_y); } } ################## # Reset geometry foreach ($image as $frame) { $frame->setimagepage( $w, $h, 0, 0); } $format = strtolower( $image->getimageformat() ); $path = "temp/$ID.$_SESSION[views].$format"; $frames = $image->getNumberImages(); if ( $frames > 1) { $image->writeImages("$path", TRUE); } else { $image->writeImage("$path"); } # save settings $_SESSION[path] = $path; header("Location: display.php"); exit; # end crop } ############ step 2 # if 2nd coorids not set, set var for form if ( $_GET[crop_image_x] && $_GET[crop_image_y] && $_GET[ul_x] && $_GET[ul_y] && !$_GET[lr_x] && !$_GET[lr_y] ) { $ul_x = $_GET[ul_x]; $ul_y = $_GET[ul_y]; $lr_x = $_GET[crop_image_x]; $lr_y = $_GET[crop_image_y]; header("location:$self?ul_x=$ul_x&ul_y=$ul_y&lr_x=$lr_x&lr_y=$lr_y"); exit; } # Step 1. # Vars shouldn't be set at this point # if 1st coorids not set, set vars for form if ($_GET[crop_image_x] && $_GET[crop_image_y] && !$_GET[ul_x] && !$_GET[ul_x] && !$_GET[lr_x] && !$_GET[lr_x] ) { $ul_x = $_GET[crop_image_x]; $ul_y = $_GET[crop_image_y]; header("location:$self?ul_x=$ul_x&ul_y=$ul_y"); exit; } ?>
include("style.txt"); ?>You can crop, chop or splice an image two ways; enter the cooridinates or point and click. Entering the cooridinates is more precise, point and click is easier.