<%
'Function function: the remote image is automatically saved to the local server, and the image is added with a watermark using aspjpeg.
'(Note: Create the images directory in the directory to save the temporary image)
'Ben Program You must install the "aspjpeg component" on the server. Otherwise, the image cannot be used properly.
'You can also take only the sections above '''''000000''', save the image, and add the watermark in the second part.
'Use methods, save as saveimg. asp
'Saveimg. asp? Url = http://siyizhu.com/logo.gif can take a piece of it, Hoho. Other functions that need to be added, you can expand it yourself
'How do I obtain files with other extension names? Of course.
'(JPG | GIF | PNG | BMP) to (mp3). Do you understand? The name of the file with the MP3 suffix.
Server. scripttimeout = 99999
Const savepath = "Images" 'image storage 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) "'defines the file suffix
set matches = objregex.exe cute (STR)
for each match in matches
newstr = Replace (newstr, match. value, saveimg (match. value)
next
myreplace = newstr
end function
function saveimg (URL)
temp = Split (URL ,". ")
'here is the name of the renamed file by time and random number
randomize
rannum = int (90000 * RND) + 10000
filename = year (now) & month (now) & Day (now) & hour (now) & minute (now) & Second (now) & rannum &". "& temp (ubound (temp)
'after renaming the file name
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 'save path
dim JPEG
set JPEG = server. createobject ("persits. JPEG ")
JPEG. open Server. mappath (saveimg) 'open the path to save the image
'Add a text watermark
JPEG. Canvas. Font. Color = & hff0000 'red
JPEG. Canvas. Font. Family = ""
JPEG. Canvas. Font. Bold = true
JPEG. Canvas. Print jpeg. OriginalWidth-200, JPEG. OriginalHeight-50, "siyizhu.com" 'watermark from the left, from the top, this is placed in the right bottom foot
'Save the file
JPEG. Save server. mappath (saveimg) 'Save the watermark image
'Logout object
Set JPEG = nothing
End Function
%>
Pay attention to the support of your server components.