smonkcaptain Posted June 29, 2010 Share Posted June 29, 2010 Hey all. I'm Currently making an Upload form for my Aviation photography site. Upon upload of the photo i want to embed a watermark. I really have no idea where to start, but here is my Upload.php script for the rest of the form: <?php session_start(); $username=$_SESSION['username']; //This is the directory where images will be saved $target = "upload/"; $target = $target .basename( $_FILES['photo']['name']); //This gets all the other information from the form $genre=$_POST['genre']; $aircrafttype=$_POST['aircrafttype']; $airline=$_POST['airline']; $airport=$_POST['airport']; $country=$_POST['country']; $registration=$_POST['registration']; $connumber=$_POST['connumber']; $day=$_POST['day']; $month=$_POST['month']; $year=$_POST['year']; $remarks=$_POST['remarks']; $photo=($_FILES['photo']); $date=$day.'-'.$month.'-'.$year; foreach($_POST['tag'] as $tag){ if($tag){ $tags[] = $tag; } } $tag = implode('+',$tags); // Connects to your Database mysql_connect("77.68.105.107", "jimmyleama2", "a340a340") or die(mysql_error()) ; mysql_select_db("jimmyleama2") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO `photographs` (`Username`, `Genre`, `Aircraft Type`, `Airline`, `Country`, `Airport/Airfield`, `Registration`,`Construction #`, `Category`, `Date`, `photo`, `Remarks`) VALUES ('$username', '$genre', '$aircrafttype', '$airline', '$country', '$airport', '$registration', '$connumber', '$tag', '$date', '$photo', '$remarks')")or die(mysql_error()); //Writes the photo to the server if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) { //Tells you if its all ok echo "<center>Thankyou <strong>$username</strong> for your Upload. Your Photograph has been added to the Screening Queue. <br> Below are details of your Upload.</center>"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?> Thankyou for your help, and if any more information is needed, just ask Jimmy Leaman. Quote Link to comment https://forums.phpfreaks.com/topic/206232-watermarking-image-upon-upload/ Share on other sites More sharing options...
travo1992 Posted June 30, 2010 Share Posted June 30, 2010 Try using GD. Jus make sure your server has it enabled. I would create an image from the original image, create an image from your watermark image, copy the watermark onto the image and save over the original image. Quote Link to comment https://forums.phpfreaks.com/topic/206232-watermarking-image-upon-upload/#findComment-1078969 Share on other sites More sharing options...
harristweed Posted June 30, 2010 Share Posted June 30, 2010 This is a function I use for adding watermarks function cr_jpg ($image_name){ ini_set("memory_limit","512M"); // ceate thumbnail with copyright global $destination_path, $width, $where_temp, $where_temp2,$new_name; $dest_image="$new_name"; $image = imagecreatefromjpeg($where_temp2.$image_name); $icon = ImageCreateFromPNG("watermark.png"); $width = ImageSX($icon); $height = ImageSY($icon); ImageCopyResized($image,$icon,0,0,0,0,$width,$height,$width,$height); imagejpeg($image,$destination_path.$dest_image); ini_restore("memory_limit"); } As you see some parameters are held in variables that are set outside of the function Hope this helps Quote Link to comment https://forums.phpfreaks.com/topic/206232-watermarking-image-upon-upload/#findComment-1079079 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.