Pictures are automatically saved to local and use AspJpeg to add watermarks to pictures _ Thieves/collection

Source: Internet
Author: User
Tags save file
<%
' function function: Remote pictures are automatically saved to the local server, and a watermark is added to the image using AspJpeg
' (Note: Please create a images directory under the directory to save the temporary picture)
' This program needs to install ' aspjpeg components ' on the server or it will not work properly
' Can also only take the ' ' 22222222 ' ', which can save the picture, the second part is to increase the watermark
' Use method, save as Saveimg.asp
' Saveimg.asp?url=yun_qi_img/logo.gif can remove the picture, HOHO. Other functions that need to be added, everyone expands themselves.
' How do you get the other suffix name files? Of course I can.
' (jpg|gif|png|bmp) changed to (mp3) you know? is the filename that takes the mp3 suffix. And so on. hehe

server.scripttimeout=99999

Const savepath= "Images" Picture save path
Url=request ("url")

function Myreplace (str)
Newstr=str
Set Objregex = new REGEXP
Objregex.ignorecase = True
Objregex.global = True
Objregex.pattern = "http://(. +?) \. (jpg|gif|png|bmp) "' Define file suffix
Set matches = Objregex.execute (str)
For the match in matches
Newstr=replace (Newstr,match.value,saveimg (Match.value))
Next
Myreplace=newstr
End Function

function saveimg (URL)
Temp=split (URL, ".")
' The following is the use of time and random numbers to rename the file name
Randomize
Rannum=int (90000*RND) +10000
Filename=year (now) &month (now), &day (now), &hour (now) &minute (now), &second (now) &ranNum& "." &temp (UBound (temp))
' FileName Rename End
Set Xmlhttp=server.createobject ("Microsoft.XMLHTTP")
Xmlhttp.open "Get", Url,false
Xmlhttp.send
Img=xmlhttp. Responsebody
Set xmlhttp=nothing
Set Objadostream=server.createobject ("ADODB. Stream ")
Objadostream.open ()
Objadostream.type=1
Objadostream.write (IMG)
Objadostream.savetofile (Server.MapPath (savepath&filename))
Objadostream.seteos
Set objadostream=nothing
"" "' 222222222 '" "" ""
Saveimg=savepath&filename ' Get Save path
Dim Jpeg
Set Jpeg = Server.CreateObject ("Persits.jpeg")
Jpeg.open Server.MapPath (saveimg) ' Open the path to save the picture

' Add text watermark
Jpeg.Canvas.Font.Color = &hff0000 ' Red
Jpeg.Canvas.Font.Family = "Song Body"
Jpeg.Canvas.Font.Bold = True
Jpeg.Canvas.Print jpeg.originalwidth-200,jpeg.originalheight-50, "siyizhu.com" watermark distance from the left, the distance from the top, this is put on the right leg
' Save file
Jpeg.save Server.MapPath (saveimg) ' Save a picture after adding a watermark

' Logout Object
Set Jpeg = Nothing
End Function
%>
Pay attention to your server component support OH.

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.