PHP to add text watermark to the picture before, here we introduce how to make picture watermark, in fact, the principle is the same, the difference lies in the second step, the operation of the picture we want to get the watermark picture information
The specific implementation code is given below:
!--? php/* Open picture *///1. Configure picture path $SRC = "bg.jpg"; get picture basic information//2 = $info ($SRC); /3. Get the type by number $type = Image_type_to_extension ($info [2],false);//4. Create Picture $fun = "Imagecreatefrom". $type;//5. Copy to Memory $image = $fun ($SRC);/* manipulate picture *///1. Set watermark Path $imagemark = "Dog.jpg";//2. Get basic information about watermark images $info2 = getimagesize ($imageMark);//3. Get type by number type2 = image_type_to_extension ($info 2[2],false);//4. Create an image $fun2 = "Imagecreatefrom" in memory. $type 2;//5. Copy to Memory $water = $fun 2 ($imageMark);//6. Merge Picture Imagecopymerge ($image, $water, 0, 0, 2[0], $info 2[1], 30);//7. Destroy Watermark picture Imagedestroy ($ water);/* Output picture *///browser output header ("Content-type:". $info [' MIME ']); $fun = "image". $type; $fun ($image);//Save Picture $fun ($image, ' Bg_dog. ' $TYPE);/* Destroy Picture */imagedestroy ($image);
Note that the encoding is UTF8 no BOM
Copyright notice: This article for Bo Master original article, without Bo Master permission not reproduced.