PHP Image Watermark

Source: Internet
Author: User
Tags watermark images
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.