simple watermark script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    simple watermark script

    sometimes its easier and faster to add a watermark with php script than with a image editing software,

    here is a very simple script which adds watermarks to your images:

    copy the php code below and upload it to your site,

    create a transparent png watermark image wm.png and upload it to the same directory as the script below.

    in the script directory create a subdirectory "upload" and chmod 0777 the upload directory.


    PHP Code:
    <?php
     
    if ((($_FILES["file"]["type"] == "image/gif")
     || (
    $_FILES["file"]["type"] == "image/jpeg")
     || (
    $_FILES["file"]["type"] == "image/pjpeg"))
     && (
    $_FILES["file"]["size"] < 900000))
       {
       if (
    $_FILES["file"]["error"] > 0)
         {
         echo 
    "Return Code: " $_FILES["file"]["error"] . "<br />";
         }
       else
         {
         
               
    $file_name 'upload/'.substr(md5(time()),0,10).'.jpg';
               
    $file imagecreatefromjpeg($_FILES["file"]["tmp_name"]);
               
               
    $watermark = @imagecreatefrompng('./wm.png');
               
    $imagewidth imagesx($file);
               
    $imageheight imagesy($file);
               
    $watermarkwidth imagesx($watermark);
               
    $watermarkheight imagesy($watermark);
               
    $startwidth = (($imagewidth $watermarkwidth)/1);
               
    $startheight = (($imageheight $watermarkheight)/1);
               
    imagecopy($file$watermark$startwidth$startheight00$watermarkwidth$watermarkheight);
               
    #imagecopymerge($file, $watermark, $startwidth, $startheight, 0, 0, $watermarkwidth, $watermarkheight, 80);
                
    imagedestroy($watermark);
               
               
    imagejpeg($file$file_name90);
               
    ImageDestroy($new);
               
    ImageDestroy($file);     
         
         
    #echo "Upload: " . $_FILES["file"]["name"] . "<br />";
         #echo "Type: " . $_FILES["file"]["type"] . "<br />";
         #echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
         #echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
        
    echo '<img src="'.$file_name.'" alt=""/>';
         
    /*if (file_exists("upload/" . $_FILES["file"]["name"]))
           {
           echo $_FILES["file"]["name"] . " already exists. ";
           }
         else
           {
           move_uploaded_file($_FILES["file"]["tmp_name"],
           "upload/" . $_FILES["file"]["name"]);
           echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
           }*/
         
    }
       }
     else
       {
       echo 
    "Invalid file";
       }
     
    ?>
    <html>
     <body>

     <form action="" method="post"
     enctype="multipart/form-data">
     <label for="file">File:</label>
     <input type="file" name="file" id="file" /> 
     <br />
     <input type="submit" name="submit" value="Submit" />
     </form>

     </body>
     </html>
     
    <?php
    if ($handle opendir('./upload/')) {
        while (
    false !== ($entry readdir($handle))) {
            if (
    $entry != "." && $entry != "..") {
                echo 
    "<a href=\"upload/$entry\">$entry</a>, \n";
            }
        }
        
    closedir($handle);
    }
    ?>
    Advertise your mobile site for FREE with AdTwirl


    #2
    tanx man..uzeful. pleaze can u upload it in zip file for download?

    Comment


      #3
      Originally posted by Junkle View Post
      tanx man..uzeful. pleaze can u upload it in zip file for download?
      the message you have entered is too short blah blah
      Attached Files
      I need some facebook likes, can you please help me
      http://facebook.com/softwarefreakin
      I noticed social media is really powerful
      Well DONE is better than well SAID

      Comment


        #4
        how its wrk when some use img bbcode..its put watermark on image of not


        ya its just for upload image watermark

        Comment


          #5
          video watermark scripts

          Comment


            #6
            Do you guys have any watermark script that is able to addapt the background and switch color ?
            like for example if background is darker use white watermark ? i know i have had found a class some time ago but i lost its tracks .
            This is ten percent luck, twenty percent skill
            Fifteen percent concentrated power of will
            Five percent pleasure, fifty percent pain

            And a hundred percent reason to remember the name!

            Comment


              #7
              Originally posted by just_m3. View Post
              Do you guys have any watermark script that is able to addapt the background and switch color ?
              like for example if background is darker use white watermark ? i know i have had found a class some time ago but i lost its tracks .
              this might help you: http://stackoverflow.com/questions/1...image-with-php
              Advertise your mobile site for FREE with AdTwirl

              Comment


                #8
                Originally posted by GumSlone View Post

                Well yeah , thanks a bunch , that is what i was looking for
                This is ten percent luck, twenty percent skill
                Fifteen percent concentrated power of will
                Five percent pleasure, fifty percent pain

                And a hundred percent reason to remember the name!

                Comment

                Working...
                X