Jump to content

Watermarking image upon upload!


smonkcaptain

Recommended Posts

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 :D

 

Jimmy Leaman.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.