PHP upload images and make transparent watermark code

Source: Internet
Author: User
  1. $im = Imagecreatefromjpeg ($_file["Upload" ["tmp_name"]); You want to take a picture of the example
  2. $watermark = Imagecreatefrompng ("Smiley.png"); Path of the watermark map
  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 watermark map.
  9. The type can be used to determine the genre
  10. Switch ($_file["Upload" ["type"])
  11. Case:1
  12. And then use different functions.
  13. Imagejpeg () corresponds to JPEG
  14. Imagegif () corresponds to GIF
  15. Imagepng () corresponds to PNG
  16. Imagedestroy ($im);
Copy Code
  • 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.