Aspjpeg| Transparent company to do a customer, need to create images like Alibaba effect. Originally developed systems are using aspjpeg to reduce the figure, now need to deal with the picture, of course, think of this component. But later found that the use of AspJpeg watermark when the effect is always not ideal, especially the image effect, and the text watermark can not adjust the transparency also can not meet customers.
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 AA,
2, the text watermark processing image data binary assignment to BB,
3, BB as a "picture watermark", attached to AA, adjust the transparency, the output is OK
The idea is simple, and the code is simple:
<%
localfile= "d:\mytest.jpg"
targetfile= "d:mytest_text.jpg"
Dim jpeg
Set Jpeg = Server.CreateObject ("Persits.jpeg")
If-2147221005=err then
Response.Write "does not have this component, please install!" ' Check whether to install the AspJpeg component
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 AA
Aa=jpeg.binary ' assigns raw data to AA
' ========= plus text watermark =================
Jpeg.Canvas.Font.Color = &hfffffff ' watermark text color
Jpeg.Canvas.Font.Family = Arial ' font
Jpeg.Canvas.Font.Bold = True ' 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 = 4 ' output quality
Jpeg.Canvas.PrintText jpeg.originalwidth/2-100,jpeg.originalheight/2+20, ' Www.sotuku.com "' Watermark position and text
Bb=jpeg.binary ' will be assigned to the text watermark after the value of the BB, at this time, there is no opacity text watermark
' ============ tuneInteger text transparency ================
Set myjpeg = Server.CreateObject ("Persits.jpeg")
myjpeg.openbinary aa
Set Logo = Server.CreateObject ("Persits.jpeg")
logo.openbinary BB
myjpeg.drawimage 0,0, Logo, 0.2 ' 0.3 is transparency
cc= Myjpeg.binary ' assigns the final result to CC, and you can also generate a target picture of
response. BinaryWrite cc ' Converts the binary output to the browser
Myjpeg.save (targetfile)
Set aa=nothing
Set bb=nothing
Set cc=nothing
Jpeg. Close
Myjpeg.close
Logo.close
%>
Effect Chart: