Need help to watermark my pictures on upload

Discussion in 'PHP' started by toykin2010, Jan 22, 2011.

  1. #1
    what do i edit to add watermark on upload?
    <?php
    /* $Id: upload.php,v 1.2 2005-11-17 08:02:51-07 brian Exp brian $ */
    // vim: expandtab sw=4 ts=4 sts=4:
    ########################################################################
    ## Built2Go PHP RateMyPhoto v1.0                                      ##
    ## ----------------------------------------------------------------   ##
    ## Copyright © Big Resources, Inc. All Rights Reserved.               ##
    ## This software must be used in accordance with its licensing        ##
    ## terms and conditions at: http://www.built2go.com/faq.php           ##
    ##                                                                    ##
    ## This file may not be redistributed in whole or significant part.   ##
    ## ---------------- BUILT2GO IS NOT FREE SOFTWARE -----------------   ##
    ########################################################################
    session_start();
    require("config.php");
    include_once("$full_path_to_public_program/session.php");
    
    include("templates/main.html.php");
    include("templates/leftside.html.php");
    include("templates/newimage_header.html");
    if(($_SESSION['userid'] AND $_SESSION['pass']) AND ($_COOKIE['id'] AND $_COOKIE['username'])) {
       if($_SESSION['disabled']){
           echo "<td valign=\"top\"><div class=\"error\">$DisabledUser</div>";
           include("templates/newheader_end.html");
           include("templates/footer.html.php");
           exit;
        }
        if (isset($_POST['addpic'])){
    
            for ($i=0; $i<count($_FILES["Ifile"]["tmp_name"]); $i++){
                if (is_uploaded_file($_FILES["Ifile"]["tmp_name"][$i])){
                    $ext = substr(strrchr($_FILES['Ifile']['name'][$i],"."),1);
                    $size = @getimagesize($_FILES["Ifile"]["tmp_name"][$i]);
                    if(!in_array($_FILES["Ifile"]["type"][$i],$ImageFormat) OR (strstr($_FILES["Ifile"]["name"][$i],"..")!="")){
                        $imageerror= "<div class=\"error\">$NotCorrectFormat</div>\n";
                    }elseif ($_FILES["Ifile"]['size'][$i]==0){
                        $imageerror= "<div class=\"error\">$ToSmallUpload</div>\n";
                    
                    } elseif ($_FILES["Ifile"]["size"][$i]>MAXFILE_SIZE) {
                        $imageerror= "<div class=\"error\">$ToBigUpload[0]</div>\n";
                    } else {
                        $fp = fopen($_FILES["Ifile"]["tmp_name"][$i], "rb");
                        $fcontents = fread ($fp, filesize ($_FILES["Ifile"]["tmp_name"][$i]));
                        $sec = date("s");
                        // add 1 to the seconds so the files will have different names.
                        $sec = $sec + $i;
                        $date=date("Y")."-".date("m")."-".date("d")."".date("H")."-".date("i")."-".$sec;
                        $newname= $_SESSION['id']."_".$date.".".$ext;
                        $file1=fopen($upload_dir."/".$newname,"w");
    	                fputs($file1,$fcontents);
    	                fclose($file1);
                         $local_pic = $newname;
    
                    }
    
                    if (empty($imageerror)){
                        // might have to check for multiple images that are the same.
                        // make sure they can't upload the exact same image and if the image is already there.
                        // see if admin disabled comments, if not get the user choice
                       $comment = ($AdminAllowComments)?valid_id($_POST['comment']):$AdminAllowComments;
                       $U = "INSERT into $pic_tbl (picid,pic_userid,picture,dateadded,ncat,status,comment)
                       VALUES ('','{$_SESSION['id']}','$local_pic','".time()."', '{$_SESSION['gender']}','$SetPending','$comment') ";
                       //echo $U;
                       mysql_query($U) or die(mysql_error());
                       
                       $ImageEmail = str_replace("{USER}", $get_email["userid"],$ImageSubmissionEmail);
                       
                       SendUserEmail($get_email["email"],$ImageSubmissionEmailSubject,$ImageEmail);
                       $success .= str_replace("{IMG_UPLOAD}" ,$local_pic ,$SuccessFile);
                    } else {
                        $fail .= str_replace("{IMG_UPLOAD}" ,$_FILES["Ifile"]["name"][$i] ,$FailedFile);
                    }
    
                }
    
            }
            echo "<div class=\"txt_dgreen_bold02\">$imageerror<br />$fail<br />$success<br />$upload_success</div>";
    
        } else {
    
                    echo "<div class=\"error\">$NoPicture</div>\n";
                    include("templates/newheader_end.html");
                    include("templates/upld_form.html.php");
                    include("templates/footer.html.php");
                    exit;
        }
    
    }
    
    include("templates/newheader_end.html");
    include("templates/footer.html.php");
    ?>
    
    PHP:

     
    toykin2010, Jan 22, 2011 IP
  2. G3n3s!s

    G3n3s!s Active Member

    Messages:
    325
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #2
    there are a lot of classes to add watermarks ... look though google
     
    G3n3s!s, Jan 23, 2011 IP