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.');
????}
????if?(empty($_POST['watermark']))?{
????????die('Please?enter?some?text?for?your?watermark.');
????}
????$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.');
????}
????switch($_POST['color'])?{
????????case?'black':
????????????$color?=?imagecolorallocate($image,?0,?0,?0);
????????????break;
????????case?'red':
????????????$color?=?imagecolorallocate($image,?255,?0,?0);
????????????break;
????????case?'blue':
????????????$color?=?imagecolorallocate($image,?0,?0,?255);
????????????break;
????????case?'yellow':
????????????$color?=?imagecolorallocate($image,?255,?255,?0);
????????????break;
????????case?'green':
????????????$color?=?imagecolorallocate($image,?0,?255,?0);
????????????break;
????????case?'white':
????????default:
????????????$color?=?imagecolorallocate($image,?255,?255,?255);
????}
????//?Add?text?to?image
????imagestring($image,?3,?5,?imagesy($image)-20,?$_POST['watermark'],?$color);
????//?Display?image
????header('Content-type:?image/jpeg');
????imagejpeg($image);
????die();
}
//?Display?the?upload?form:
?>
????
????????Image?Watermarker
????
????
????
????????