ASP uses AspJpeg component to make transparent text watermark
Source: Internet
Author: User
Aspjpeg| Transparent Technical Support:
1, AspJpeg can be transparent to the image watermark adjustment, can not adjust the text watermark,
2, aspjpeg support binary, can jpeg.openbinary read, can jpeg.sendbinary, also can jpeg.binary assign value
Ideas:
1, the original image data binary system assigned to Tempa,
2, the text watermark processing image data binary assignment to TEMPB,
3, to TEMPB as a "picture watermark", attached to the Tempa, adjust the transparency, the output is OK
The idea is simple, and the code is simple:
<%
Localfile= "D:\apple.jpg"
Targetfile= "D:\myapple.jpg"
Dim Jpeg
Set Jpeg = Server.CreateObject ("Persits.jpeg")
If err.number=-2147221005 Then
Response.Write "No this component, please install!" Check to see if the AspJpeg component is installed
Response.End ()
End If
Jpeg.open (LocalFile) ' Open picture
If Err.Number Then
Response.Write "Open picture failed, please check the path!" "
Response.End ()
End If
Dim Tempa ' RAW image binary data
Dim TEMPB ' A picture with an opaque text watermark
Dim TEMPC ' final effect
Tempa=jpeg.binary ' assigns raw data to Tempa
' ========= plus text watermark =================
Jpeg.Canvas.Font.Color = &hfffffff ' watermark text color
Jpeg.Canvas.Font.Family = Arial ' font
Jpeg.Canvas.Font.Bold = True ' whether bold
Jpeg.Canvas.Font.Size = 35 ' font size
Jpeg.Canvas.Font.ShadowColor = &h000000 ' shadow color
Jpeg.Canvas.Font.ShadowYOffset = 1
Jpeg.Canvas.Font.ShadowXOffset = 1
Jpeg.Canvas.Brush.Solid = True
Jpeg.Canvas.Font.Quality = 5 ' Output quality
Jpeg.Canvas.PrintText JPEG.ORIGINALWIDTH/2-150,JPEG.ORIGINALHEIGHT/2, "www.Tsingfeng.com" ' watermark position and text
Tempb=jpeg.binary ' The text watermark processing value assigned to TEMPB, at this time, the text watermark does not have the opacity
' ============ Adjust text transparency ================
Set myjpeg = Server.CreateObject ("Persits.jpeg")
Myjpeg.openbinary Tempa
Set Logo = Server.CreateObject ("Persits.jpeg")
Logo.openbinary TEMPB
Myjpeg.drawimage 0,0, Logo, 0.2 ' 0.3 is transparency
Tempc=myjpeg.binary ' will assign the final result to TEMPC, and you can also generate the target picture.
Response. BinaryWrite TEMPC ' The binary output to the browser
Myjpeg.save (TargetFile)
Set tempa=nothing
Set tempb=nothing
Set tempc=nothing
Jpeg.close
Myjpeg.close
Logo.close
%>
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