if?($_POST)?{
????//?No?image?
????if?(empty($_FILES['image'])?OR?$_FILES['image']['error']?!=?UPLOAD_ERR_OK)?{
????????die?('Invalid?image?uploaded.??Please?go?back?and?try?again.');
????}
????$imagepath?=?$_FILES['image']['tmp_name'];
????//?Load?image
????$image?=?open_image($imagepath);
????if?($image?==?false)?{
????????die?('You?uploaded?an?invalid?image.?Please?go?back?and?try?again.');
????}
????//?Get?original?width?and?height
????$width?=?imagesx($image);
????$height?=?imagesy($image);
????//?Percentage?
????if?(!empty($_POST['percent'])?AND?is_numeric($_POST['percent']))?{
????????$percent?=?floatval($_POST['percent']);
????????$percent?=?$percent/100;
????????$new_width?=?$width?*?$percent;
????????$new_height?=?$height?*?$percent;
????//?New?width??Calculate?new?height
????}?elseif?(!empty($_POST['new_width'])?AND?is_numeric($_POST['new_width']))?{
????????$new_width?=?floatval($_POST['new_width']);
????????$new_height?=?$height?*?($new_width/$width);
????//?New?height??Calculate?new?width
????}?elseif?(!empty($_POST['new_height'])?AND?is_numeric($_POST['new_height']))?{
????????$new_height?=?floatval($_POST['new_height']);
????????$new_width?=?$width?*?($new_height/$height);
????//?New?height?and?new?width
????}?elseif?(!empty($_POST['height'])?AND?is_numeric($_POST['height'])?AND?!empty($_POST['width'])?AND?is_numeric($_POST['width']))?{
????????$new_height?=?floatval($_POST['height']);
????????$new_width?=?floatval($_POST['width']);
????}?else?{
????????die?('You?didn\'t?specify?any?resizing?options.');
????}????
????//?Resample
????$image_resized?=?imagecreatetruecolor($new_width,?$new_height);
????imagecopyresampled($image_resized,?$image,?0,?0,?0,?0,?$new_width,?$new_height,?$width,?$height);
????//?Display?resized?image
????header('Content-type:?image/jpeg');
????imagejpeg($image_resized);
????die();
}
//?Display?the?upload?form:
?>
????
????????Image?Resizer
????
????
????
????????