PHP upload images and set transparent image watermark effect

Source: Internet
Author: User
Tags imagejpeg transparent image
  1. $im = imagecreatefromjpeg ($_file["Upload" ["tmp_name"]);//Picture

  2. $watermark = Imagecreatefrompng ("Smiley.png"); The path of the watermark
  3. $im _x = Imagesx ($im);
  4. $im _y = Imagesy ($im);
  5. $w _x = Imagesx ($watermark);
  6. $w _y = Imagesy ($watermark);
  7. imagecopy ($im, $watermark, $im _x-$w _x, $im _y-$w _y,0,0, $w _x, $w _y);
  8. imagejpeg ($im);//You can add a path to save a watermarked image

  9. //Use type to determine the type of the slice

  10. //switch ($_file["Upload" ["type"])
  11. //case:1
  12. //Other GD library functions
  13. //imagejpeg () corresponds to JPEG
  14. //imagegif () corresponds to GIF
  15. //imagepng () corresponds to PNG
  16. Imagedestroy ($im);

  • 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.