For PHP image upload with PHP watermark Instance code, a complete example of PHP upload pictures, need to refer to a friend. 1, send.html File Uploader
File Upload Select a file to upload:
2, receive img_receive.php
File name: ". $destination _folder. $fname." "; echo "width:". $image _size[0]; echo "Length:". $image _size[1]; echo " Size: ". $file [" Size "]." bytes "; if ($watermark ==1)//1 to add watermark {$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 ($destination); 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, $wate Rstring, $black); Break Case 2://Watermark Image $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); Break Case 2:imagejpeg ($nimage, $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 ""; } } |