The image is automatically saved locally and watermark the image using aspjpeg.

Source: Internet
Author: User

<%
'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.

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.