<?PHP
	$img = $_REQUEST['img'];
	$x = $_REQUEST['x'];
	$y = $_REQUEST['y'];
	$x2 = $_REQUEST['x2'];
	$y2 = $_REQUEST['y2'];
	if (substr($img, -4, 4) == ".jpg" or substr($img, -4, 4) == ".JPG") {
		header("Content-type: image/jpeg");
		$src = imagecreatefromjpeg($img);
	} else if (substr($img, -4, 4) == ".png" or substr($img, -4, 4) == ".PNG") {
		header("Content-type: image/png");
		$src = imagecreatefrompng($img);
	}
	if (!$src) die("Unable to locate src image at $src");
	$out = imagecreatetruecolor($x2, $y2);
	imagecopyresampled($out, $src, 0, 0, 0, 0, $x2, $y2, $x, $y);
	imagejpeg($out);
	imagedestroy($out);
?>
