Copy CodeThe code is as follows:
Original image
$DST = "/upload/20120914/20120914040740-0.jpg"; Note that the picture path should be correct
Get the original picture information
$DST _info = getimagesize ($DST);
Switch ($DST _info[2])
{
Case 1:
$DST _im =imagecreatefromgif ($DST);
Case 2:
$DST _im =imagecreatefromjpeg ($DST);
Case 3:
$DST _im =imagecreatefrompng ($DST);
Case 6:
$DST _im =imagecreatefromwbmp ($DST);
Default
Die ("Unsupported file type 1"); exit;
}
Watermark Image
$SRC = "/images/shuiyin.png"; Note the path to write to
$src _info = getimagesize ($SRC);
Switch ($src _info[2])
{
Case 1:
$SRC _im =imagecreatefromgif ($SRC);
Case 2:
$SRC _im =imagecreatefromjpeg ($SRC);
Case 3:
$SRC _im =imagecreatefrompng ($SRC);
Case 6:
$SRC _im =imagecreatefromwbmp ($SRC);
Default
Die ("Unsupported file type 1"); exit;
}
Translucent format watermark
$alpha = 50;//Watermark Transparency
Imagecopymerge ($dst _im, $src _im, $dst _info[0]-$src _info[0]-10, $dst _info[1]-$src _info[1]-10,0,0, $src _info[0],$ SRC_INFO[1], $alpha);
Ways to support PNG's own transparency
Imagecopy ($dst _im, $src _im, $dst _info[0]-$src _info[0]-10, $dst _info[1]-$src _info[1]-10,0,0, $src _info[0], $src _info [1]);
Save picture
Switch ($DST _info[2]) {
Case 1:
Imagegif ($dst _im, $DST);
Case 2:
Imagejpeg ($dst _im, $DST);
Case 3:
Imagepng ($dst _im, $DST);
Case 6:
Imagewbmp ($dst _im, $DST);
Default
Die ("Unsupported file type 2"); exit;
}
Imagedestroy ($dst _im);
Imagedestroy ($src _im);
http://www.bkjia.com/PHPjc/326350.html www.bkjia.com true http://www.bkjia.com/PHPjc/326350.html techarticle Copy the code as follows://original image $dst = "/upload/20120914/20120914040740-0.jpg";//Note picture path to correct//get original picture information $dst _info = getimagesize ($ DST); S ...