How to add watermark on image upload

Asked at 2017-01-11 21:42:43Z
  • 5 Subscribers
  • 114 Views
0

I want to add watermark on image when I upload in my PHP script. I found many components on Google but I don't know how to use like Dynamically add watermark on image upload, I don't know what value should pass to component function to add watermark. Could anybody help me.

My code.

HTML file for image uploading:

<form action="" method="post" enctype="multipart/form-data" onsubmit="return checkValidation(this);">
<fieldset>
    <p>
        <label>Select Language:</label>

        <select name="language_id" id="language_id" style="width:280px; height:25px;">

            <option value="">--Select Language--</option>

            <?php 
               while($lang_row=mysql_fetch_array($lang_result)) {
    ?>

                <option value="<?php echo $lang_row['id'];?>">
                    <?php echo $lang_row['language_name'];?>
                </option>

            <?php
                }
            ?>
        </select>
    </p>
    <p>
        <label>Select Category:</label>

        <select name="category_id" id="category_id" style="width:280px; height:25px;">

            <option value="">--Select Category--</option>

        </select>
    </p>



    <p>
        <label>Quote:</label>
        <div class="wrapper">
            <p>
                <label>Image Quote:</label>
                <input type="file" name="img_quote[]" id="img_quote[]" class="text-long" />
            </p>
            <p>
                <label>Text Quote:</label>
                <textarea name="quote[]" id="quote[]" class="text-long"></textarea>
            </p>
        </div>
    </p>

    <p>
        <div id="dynamicInput"></div>
    </p>

    <p>
        <input type="button" value="Add another Quote" onClick="addInput('dynamicInput');">
    </p>

    <p>
        <input type="submit" name="submit" value="Add Quote" />
    </p>
</fieldset>
</form>

Add image php:

<?php include("includes/header.php");

require("includes/function.php");
$kwallpaper=new  k_wallpaper;

mysql_query("SET NAMES 'utf8'");

//Get all Category 
$qry="SELECT * FROM tbl_category";
$result=mysql_query($qry);

//Get all Language
$lang_qry="SELECT * FROM tbl_language";
$lang_result=mysql_query($lang_qry); 

if(isset($_POST['submit']) and isset($_GET['add']))
{   

    $kwallpaper->addquote();

    echo "<script>document.location='manage_quotes.php';</script>"; 
    exit;

}   

?>

php function file

Image Upload

$albumimgnm=rand(0,99999)."_".$_FILES['image']['name'];
         $pic1=$_FILES['image']['tmp_name'];


           if(!is_dir('images'))
           {

                mkdir('images', 0777);
           }
          $tpath1='images/'.$albumimgnm;

             copy($pic1,$tpath1);


                    $thumbpath='images/thumbs/'.$albumimgnm;
                    $obj_img = new thumbnail_images();
                    $obj_img->PathImgOld = $tpath1;
                    $obj_img->PathImgNew =$thumbpath;
                    $obj_img->NewWidth = 72;
                    $obj_img->NewHeight = 72;
                    if (!$obj_img->create_thumbnail_images()) 
                      {
                        echo $_SESSION['msg']="Thumbnail not created... please upload image again";
                        exit;
                      }
                      else
                      {

                             $cat_result=mysql_query('UPDATE `tbl_category` SET `lid`=\''.$_POST['lid'].'\',`category_name`=\''.addslashes($_POST['category_name']).'\',`category_image`=\''.$albumimgnm.'\' WHERE cid=\''.$_GET['cat_id'].'\'');
                      }
    }

}

function deleteCategory()
{
    $del_result=mysql_query('DELETE FROM `tbl_quotes` WHERE cat_id=\''.$_GET['cat_id'].'\'');

    $img_res=mysql_query('SELECT * FROM tbl_category WHERE cid=\''.$_GET['cat_id'].'\'');
    $img_row=mysql_fetch_assoc($img_res);

        if($img_row['category_image']!="")
        {
            unlink('images/thumbs/'.$img_row['category_image']);
            unlink('images/'.$img_row['category_image']);

        }   

    $cat_result=mysql_query('DELETE FROM `tbl_category` WHERE cid=\''.$_GET['cat_id'].'\'');
}

How do I install this Dynamically add watermark on image upload on my script


0 answers in total

Answer this questsion