Introduction to the sample code for adding watermarks to Images Using Asp

Source: Internet
Author: User

The input parameter is the image path to be processed. You can adjust the parameter as needed or add other parameters.

Text watermark instance code

  1. Function WordWatermark (ImagePath)
  2. Dim Image
  3. Set Image = Server. CreateObject ("Persits. Jpeg") create an object
  4. Image. Open server. mappath (ImagePath) Image Location
  5. Image. Canvas. Font. Color = & H000000 Color, which is set to: Black
  6. Image. Canvas. Font. Family = "" set the Font
  7. Whether to set Image. Canvas. Font. Bold = False to Bold
  8. Image. Canvas. Font. Size = 26 Font Size
  9. Image. Canvas. Font. Quality = 4 text definition
  10. Image. Canvas. Print Image. OriginalWidth/2-170, Image. OriginalHeight-30, "watermark text" watermark text
  11. Image. Save server. mappath (ImagePath) Save the file
  12. Set Image = Nothing
  13. End Function
  14. Image Watermark
  15. Function ImageWatermark (ImagePath)
  16. Set Image = Server. CreateObject ("Persits. Jpeg ")
  17. Determine the image path to add a watermark
  18. PhotoPath = Server. MapPath (ImagePath)
  19. Image. Open PhotoPath
  20. Enable watermark image
  21. Set Logo = Server. CreateObject ("Persits. Jpeg ")
  22. LogoPath = Server. MapPath ("logo.jpg") watermark image
  23. Logo. Open LogoPath
  24. Logo. Width = 121 watermark image size
  25. Logo. Height = 50
  26. Transition_Color = & h0066cc
  27. Place the watermark in the uploaded Image
  28. Image. DrawImage Image. width-150, Image. height-59, Logo, 1, Transition_Color, 90
  29. Here, you can change the watermark position (photo. width-210, photo. height-40 here I am in the bottom right corner of the image) and the watermark transparency.
  30. Save the added watermark image
  31. Image. Save Server. MapPath (ImagePath)
  32. Set Photo = Nothing
  33. End Function

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.