<input type= "reset" name= "Submit" value= "reset"/>
</div></td>
</tr>
</table>
</div>
<div align= "center" ></div></td>
</tr>
<tr>
<td> </td>
</tr><input type= "hidden" name= ' action ' value= ' Doup ' >
<tr>
<TD height= "background=" Image/top.gif > </td>
</tr>
<tr>
<td> </td>
</tr>
</table>
</form>
<br>
<a href=http://www.webjx.com target=_blank> Web Teaching Network webjx.com</a>
?
if ($_post[' action ']== ' Doup ')
{
$uptypes =array (' image/jpg ', ' image/jpeg ', ' image/pjpeg ', ' image/gif '); Upload picture file type list
$wFile =$_files[' upfile '];//get file path
$waterimg = "water.gif";//Watermark Picture Path
Print_r ($wFile);
if (In_array ($wFile [' type '], $uptypes))
{//Check file type, if the uploaded file is a jpg or GIF picture then add watermark
if (Strstr ($wFile [' type '], "JP"))
{///If upload picture type is jpg,pjpeg,jpeg, read target file with Imagecreatefromjpeg
$im = Imagecreatefromjpeg ($wFile [' tmp_name ']);
$wfilew =imagesx ($im);//Get the width of the picture
$wfileh =imagesy ($im);//Get the picture high
}
Else
{//Otherwise, if the uploaded picture type is GIF, read the target file with Imagecreatefromgif
$im = Imagecreatefromgif ($wFile [' tmp_name ']);
$wfilew =imagesx ($im);//Get the width of the picture
$wfileh =imagesy ($im);//Get the picture high
}
Set Blending mode
Imagealphablending ($im, true);
Read Watermark File
$im 2 = imagecreatefrompng ($waterimg);//If the watermark picture is JPG, then this can be changed to $IM2 = Imagecreatefromjpeg ($waterimg)
$white = Imagecolorallocate ($im 2, 255, 255, 255);
Imagecolortransparent ($im 2, $white); Set the transparent color, these two can not
$waterw =imagesx ($im 2);//Get the width of the watermark picture
$waterh =imagesy ($im 2);//Get watermark Picture High
Random water prints to the picture
$randval = rand (0,9);//Generate a random number between 0-9
if ($randval ==0| | $randval ==3| | $randval ==2| | $randval ==8| | $randval ==7) {//Here you can also improve your placement
$WIMGX =5; $wimgy =5;//in upper left corner
}else{
$WIMGX = $wfilew $waterw; $wimgy = $wfileh;
}
Copy Watermark to target file
Imagecopy ($im, $im 2, $WIMGX, $wimgy, 0, 0, $waterw, $waterh);
Output picture
if (Strstr ($wFile [' type '], "JP")) {//Ibid.
Imagejpeg ($im, $wFile [' tmp_name ']);
}else{
Imagegif ($im, $wFile [' tmp_name ']);
}
Imagedestroy ($im);
Imagedestroy ($im 2);
Copy ($wFile [' Tmp_name '], $wFile [' name ']); Upload
}
else echo "picture does not match!! ";
}
?>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service