ASP wsImage组件添加水印的实用代码(4)
objStream.Position=theStart-1
stemp=""
for i=1 to theLen
if objStream.EOS then Exit for
c=ascB(objStream.Read(1))
If c > 127 Then
if objStream.EOS then Exit for
stemp=stemp&Chr(AscW(ChrB(AscB(objStream.Read(1)))&ChrB(c)))
i=i+1
else
stemp=stemp&Chr(c)
End If
Next
subString=stemp
End function
Function inString(theStart,varStr)
dim i,j,bt,theLen,str
InString=0
Str=toByte(varStr)
theLen=LenB(Str)
for i=theStart to objStream.Size-theLen
if i>objstream.size then exit Function
objstream.Position=i-1
if AscB(objstream.Read(1))=AscB(midB(Str,1)) then
InString=i
for j=2 to theLen
if objstream.EOS then
inString=0
Exit for
end if
if AscB(objstream.Read(1))<>AscB(MidB(Str,j,1)) then
InString=0
Exit For
end if
next
if InString<>0 then Exit Function
end if
next
End Function
Private function GetFileName(FullPath)
If FullPath <> "" Then
GetFileName = mid(FullPath,InStrRev(FullPath, "\")+1)
Else
GetFileName = ""
End If
End function
function toByte(Str)
dim i,iCode,c,iLow,iHigh
toByte=""
For i=1 To Len(Str)
c=mid(Str,i,1)
iCode =Asc(c)
If iCode<0 Then iCode = iCode + 65535
If iCode>255 Then
iLow = Left(Hex(Asc(c)),2)
iHigh =Right(Hex(Asc(c)),2)
toByte = toByte & chrB("&H"&iLow) & chrB("&H"&iHigh)
Else
toByte = toByte & chrB(AscB(c))
End If
Next
End function
%>
3---------------------------------------------------------------------------------------
用asp组件Persits.Jpeg给图片加水印,生成缩略图
复制代码 代码如下:
<%
FileName="1.jpg"
Set Jpeg = Server.CreateObject("Persits.Jpeg")
' 获取源图片路径
Path = Server.MapPath(FileName)
' 打开源图片
'response.write(Path)
Jpeg.Open Path
' 设定生成缩略图细节 这里有很多种设定方法 下面的方法是先判断宽高比 然后按比例缩放
If Jpeg.OriginalWidth / Jpeg.OriginalHeight > 1 then
Jpeg.Width = 98
Jpeg.Height = int((98/Jpeg.OriginalWidth)*Jpeg.OriginalHeight)
elseif Jpeg.OriginalWidth / Jpeg.OriginalHeight < 1 then
Jpeg.Width = 98
Jpeg.Height= int((98/Jpeg.OriginalWidth)*Jpeg.Height)
end if
' 设定锐化效果
Jpeg.Sharpen 1, 130
' 向指定路径生成缩略图
Response.Write Server.MapPath(".")
Jpeg.Save Server.MapPath(".")&"\small\"&filename
'response.write filename1
'response.write Server.MapPath("uploadpic/small")&"\"&filename1
' 注意这两个Session
'Session("PPP0")=GP_curPath&FileName
'Session("PPP1")=GP_curPath&"small"&FileName
Set Jpeg = Nothing
'自动产生缩掠图结束
'大图片打水印开始
' 建立实例
Set Jpeg = Server.CreateObject("Persits.Jpeg")
' 打开目标图片
Path = Server.MapPath(FileName)
内容版权声明:除非注明,否则皆为本站原创文章。