Php uploads images and sets the transparent image watermark effect

Source: Internet
Author: User
Tags imagejpeg transparent image
Php uploads images and sets the transparent image watermark effect

  1. $ Im = imagecreatefromjpeg ($ _ file ["upload"] ["tmp_name"]); // Picture

  2. $ Watermark = imagecreatefrompng ("Smiley.png"); // watermark image path
  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 the watermark image.

  9. // Determine the slice type using type

  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.