<?php/* the method of adding text watermark to the picture */$dst _path = ' http://f4.topitme.com/4/15/11/1166351597fe111154l.jpg '; $dst = imagecreatefromstring (file_get_contents ($DST _path));/*imagecreatefromstring ()--Creates a new image from the image stream in the string, Returns an image identifier that expresses an image Image format from a given string that is automatically monitored as long as PHP supports jpeg,png,gif,wbmp,gd2.*/$font = './t1.ttf '; $black = imagecolorallocate ($DST, 0, 0, 0); Imagefttext ($DST, 20, 0, 10, 30, $black, $font, ' hello world! '); *imagefttext ($img, $size, $angle, $x, $y, $color, $fontfile, $text) $img the image resource returned by the image creation function size to use the font size of the watermark angle (angle) The tilt angle of the text, If the 0 degree represents the text from left to right, if it is 90 degrees from the beginning of the first text of the x, y watermark text, color is the color of the watermark text fontfile, you want to use the path of the TrueType font */list ($dst _w, $dst _h, $dst _ Type) = getimagesize ($dst _path),/*list (mixed $varname [, mixed $ ...] --Assigning values in an array to some variables like array (), this is not a real function, but a language structure, and List () assigns a set of variables in one step *//*getimagesize () what information can be obtained? The GetImageSize function returns all information about the image, including size, type, and so on */switch ($dst _type) { case 1://gif &nBsp; header ("Content-type:image/gif"); Imagegif ($DST); break; case 2://jpg header ("Content-type:image/jpeg"); imagejpeg ($DST); break; case 3://png header ("Content-type:image/png"); imagepng ($DST); break; default: break; /*imagepng--exporting images to a browser or file in PNG format imagepng () exports the GD image Stream (image) to the callout output in PNG format (typically a browser) , or if you give the filename with filename, output it to the file */}imagedestroy ($DST); >
Zhongzhiyuan Nanjing 904727147, Jiangsu
PHP Add text watermark to image