error_reporting(0);
include("functions.php");
$h1 = "DJ Mike's Image Maker 2";
$h2 = "Shave";
##### Start Shave
if ( $_GET[shave] )
{
$shave_x = (int)$_GET[shave_x];
$shave_y = (int)$_GET[shave_y];
if ( $shave_x<0 )
{ $shave_x = 0; }
if ( $shave_y<0 )
{ $shave_y = 0; }
#############
$image = new Imagick($_SESSION[path]);
$size = $image->getimagepage();
$width = $size[width];
$height = $size[height];
if ( $shave_x*2 > $width ) { $error = "X is too big
"; }
if ( $shave_y*2 > $height ) { $error .= "Y is too big"; }
if ( $error )
{
$_SESSION[error] = "$error";
header("location:$self");
exit;
}
$count = 0;
foreach ($image as $frame)
{
try { $frame->shaveimage($shave_x, $shave_y); }
catch ( exception $e )
{ $error .= "X or Y was too big for frame $count
"; }
$count++;
}
if ( $error )
{
$_SESSION[error] = $error;
header("location:$self");
exit;
}
$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;
$_SESSION[shave_x] = $shave_x;
$_SESSION[shave_y] = $shave_y;
header("Location: display.php");
exit;
}
######### end Shave
include("top.php");
?>