PHP for the image plus watermark code, PHP image watermark instance, you can set the upload file size limit, set whether to add watermark, set the watermark location, watermark string and watermark image, whether to generate a preview map and so on. example, PHP image watermark code. <title>Picture Water Stamp Program-bbs.it-home.org</title> This demo space is provided by Tuwoo, this program adopts the way of text watermark. File name: ". $destination _folder. $fname." "; echo "width:". $image _size[0]; echo "Length:". $image _size[1]; echo " Size: ". $file [" Size "]." bytes "; if ($watermark ==1) {$iinfo =getimagesize ($destination, $iinfo); $nimage =imagecreatetruecolor ($image _size[0], $image _ SIZE[1]); $white =imagecolorallocate ($nimage, 255,255,255); $black =imagecolorallocate ($nimage, 0,0,0); $red =imagecolorallocate ($nimage, 255,0,0); Imagefill ($nimage, 0,0, $white); Switch ($iinfo [2]) {Case 1: $simage =imagecreatefromgif ($destination), break, Case 2: $simage =imagecreatefromjpeg ($dest Ination); Break Case 3: $simage =imagecreatefrompng ($destination); Break Case 6: $simage =imagecreatefromwbmp ($destination); Break Default:die ("Unsupported file Types"); Exit } imagecopy ($nimage, $simage, 0,0,0,0, $image _size[0], $image _size[1]); Imagefilledrectangle ($nimage, 1, $image _size[1]-15,80, $image _size[1], $white); Switch ($watertype) {Case 1://Watermark String imagestring ($nimage, 2,3, $image _size[1]-15, $waterstring, $black); case 2:// Add watermark Picture $simage 1 =imagecreatefromgif ("Xplore.gif"); Imagecopy ($nimage, $simage 1,0,0,0,0,85,15); Imagedestroy ($simage 1); Break } switch ($iinfo [2]) {Case 1://imagegif ($nimage, $destination); imagejpeg ($nimage, $destination); 2:imagejpeg ($NIMAG); E, $destination); Break Case 3:imagepng ($nimage, $destination); Break Case 6:imagewbmp ($nimage, $destination); Imagejpeg ($nimage, $destination); Break }//overwrite the original upload file Imagedestroy ($nimage); Imagedestroy ($simage); }if ($imgpreview ==1) {echo] Picture preview: "; echo "";}}? > |