<%
'參數說明
'path1源圖片路徑包括圖片的名稱
'path2縮略圖的路徑包括圖片的名稱
'tp_width要生(shēng)成縮略圖的最大(dà)寬度
'tp_height要生(shēng)成縮略圖的最大(dà)高度
'調用aspjpeg path1,path2,tp_width,tp_height
function aspjpeg(path1,path2,tp_width,tp_height)
'------------生(shēng)成縮略圖
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Path = Server.MapPath(trim(path1))
set fso=server.createobject("scripting.filesystemobject")
if fso.fileexists(Path)=true then
Jpeg.Open Path
Jpeg.Width =Jpeg.OriginalWidth
Jpeg.Height =Jpeg.OriginalHeight
max_width=tp_width
max_height=tp_height
if Jpeg.OriginalWidth>max_width then
Jpeg.Width =max_width
Jpeg.Height =Jpeg.OriginalHeight * (Jpeg.Width / Jpeg.OriginalWidth)
if Jpeg.Height>max_height then
Jpeg.Height=max_height
Jpeg.Width =Jpeg.OriginalWidth * (Jpeg.Height / Jpeg.OriginalHeight)
end if
else
if Jpeg.OriginalHeight>max_height then
Jpeg.Height=max_height
Jpeg.Width =Jpeg.OriginalWidth * (Jpeg.Height / Jpeg.OriginalHeight)
end if
end if
Jpeg.Canvas.Font.Color = &H666666 ' 白(bái)色
Jpeg.Canvas.Font.Family = "Arial, Helvetica, sans-serif"
if Jpeg.Width<=80 then
Jpeg.Canvas.Font.size = 12 '文字大(dà)小(xiǎo)
else
Jpeg.Canvas.Font.size = 14 '文字大(dà)小(xiǎo)
end if
Jpeg.Canvas.Font.Bold = true '是否加粗
'Jpeg.Canvas.Font.BkMode = "Opaque"'文字背景(Opaque不透明,transparence透明)
Jpeg.Canvas.Font.Quality = 2'//水印文字的清晰度,從0~4,變換不是很大(dà),建議用2或3。
Jpeg.Canvas.Font.ShadowColor = &Hffffff '//水印文字的陰影色彩。
Jpeg.Canvas.Font.ShadowXoffset = 1 '//水印文字陰影向右偏移的像素值,輸入負值則向左偏移。
Jpeg.Canvas.Font.ShadowYoffset = 1 '//水印文字陰影向下(xià)偏移的像素值,輸入負值則向右偏移。
this_x=1
if Jpeg.Width>80 then this_x=(Jpeg.Width-80)/2
if this_x<0 then this_x=1
this_y=Jpeg.Height*6/8
Jpeg.Canvas.Print this_x,this_y, "daogou.com"'x,y坐标與水印文字
if fso.fileexists(Server.MapPath(trim(path2)))=false then
Jpeg.Save Server.MapPath(trim(path2))'生(shēng)成縮略圖并加水印
Set Jpeg = Nothing
aspjpeg_shuiyin path1
end if
end if
'------------給原圖片加水印
end function
function aspjpeg_shuiyin(path1)
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Path = Server.MapPath(trim(path1))
set fso=server.createobject("scripting.filesystemobject")
if fso.fileexists(Path)=true then
Jpeg.Open Path
Jpeg.Width =Jpeg.OriginalWidth
Jpeg.Height =Jpeg.OriginalHeight
Jpeg.Canvas.Font.Color = &H666666 ' 白(bái)色
Jpeg.Canvas.Font.Family = "Arial, Helvetica, sans-serif"
if Jpeg.Width>200 then
Jpeg.Canvas.Font.size = 20 '文字大(dà)小(xiǎo)
else
if Jpeg.Width<100 then
Jpeg.Canvas.Font.size = 12 '文字大(dà)小(xiǎo)
else
Jpeg.Canvas.Font.size = 14 '文字大(dà)小(xiǎo)
end if
end if
Jpeg.Canvas.Font.Bold = true '是否加粗
'Jpeg.Canvas.Font.BkMode = "Opaque"'文字背景(Opaque不透明,transparence透明)
Jpeg.Canvas.Font.Quality = 2'//水印文字的清晰度,從0~4,變換不是很大(dà),建議用2或3。
Jpeg.Canvas.Font.ShadowColor = &Hffffff '//水印文字的陰影色彩。
Jpeg.Canvas.Font.ShadowXoffset = 1 '//水印文字陰影向右偏移的像素值,輸入負值則向左偏移。
Jpeg.Canvas.Font.ShadowYoffset = 1 '//水印文字陰影向下(xià)偏移的像素值,輸入負值則向右偏移。
this_x=1
if Jpeg.Width>100 then this_x=(Jpeg.Width-100)/2
if this_x<0 then this_x=1
this_y=Jpeg.Height*6/8
Jpeg.Canvas.Print this_x,this_y, "daogou.com"'x,y坐标與水印文字
Jpeg.Save Path'給原圖片加水印
end if
Set Jpeg = Nothing
end function
%>
'參數說明
'path1源圖片路徑包括圖片的名稱
'path2縮略圖的路徑包括圖片的名稱
'tp_width要生(shēng)成縮略圖的最大(dà)寬度
'tp_height要生(shēng)成縮略圖的最大(dà)高度
'調用aspjpeg path1,path2,tp_width,tp_height
function aspjpeg(path1,path2,tp_width,tp_height)
'------------生(shēng)成縮略圖
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Path = Server.MapPath(trim(path1))
set fso=server.createobject("scripting.filesystemobject")
if fso.fileexists(Path)=true then
Jpeg.Open Path
Jpeg.Width =Jpeg.OriginalWidth
Jpeg.Height =Jpeg.OriginalHeight
max_width=tp_width
max_height=tp_height
if Jpeg.OriginalWidth>max_width then
Jpeg.Width =max_width
Jpeg.Height =Jpeg.OriginalHeight * (Jpeg.Width / Jpeg.OriginalWidth)
if Jpeg.Height>max_height then
Jpeg.Height=max_height
Jpeg.Width =Jpeg.OriginalWidth * (Jpeg.Height / Jpeg.OriginalHeight)
end if
else
if Jpeg.OriginalHeight>max_height then
Jpeg.Height=max_height
Jpeg.Width =Jpeg.OriginalWidth * (Jpeg.Height / Jpeg.OriginalHeight)
end if
end if
Jpeg.Canvas.Font.Color = &H666666 ' 白(bái)色
Jpeg.Canvas.Font.Family = "Arial, Helvetica, sans-serif"
if Jpeg.Width<=80 then
Jpeg.Canvas.Font.size = 12 '文字大(dà)小(xiǎo)
else
Jpeg.Canvas.Font.size = 14 '文字大(dà)小(xiǎo)
end if
Jpeg.Canvas.Font.Bold = true '是否加粗
'Jpeg.Canvas.Font.BkMode = "Opaque"'文字背景(Opaque不透明,transparence透明)
Jpeg.Canvas.Font.Quality = 2'//水印文字的清晰度,從0~4,變換不是很大(dà),建議用2或3。
Jpeg.Canvas.Font.ShadowColor = &Hffffff '//水印文字的陰影色彩。
Jpeg.Canvas.Font.ShadowXoffset = 1 '//水印文字陰影向右偏移的像素值,輸入負值則向左偏移。
Jpeg.Canvas.Font.ShadowYoffset = 1 '//水印文字陰影向下(xià)偏移的像素值,輸入負值則向右偏移。
this_x=1
if Jpeg.Width>80 then this_x=(Jpeg.Width-80)/2
if this_x<0 then this_x=1
this_y=Jpeg.Height*6/8
Jpeg.Canvas.Print this_x,this_y, "daogou.com"'x,y坐标與水印文字
if fso.fileexists(Server.MapPath(trim(path2)))=false then
Jpeg.Save Server.MapPath(trim(path2))'生(shēng)成縮略圖并加水印
Set Jpeg = Nothing
aspjpeg_shuiyin path1
end if
end if
'------------給原圖片加水印
end function
function aspjpeg_shuiyin(path1)
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Path = Server.MapPath(trim(path1))
set fso=server.createobject("scripting.filesystemobject")
if fso.fileexists(Path)=true then
Jpeg.Open Path
Jpeg.Width =Jpeg.OriginalWidth
Jpeg.Height =Jpeg.OriginalHeight
Jpeg.Canvas.Font.Color = &H666666 ' 白(bái)色
Jpeg.Canvas.Font.Family = "Arial, Helvetica, sans-serif"
if Jpeg.Width>200 then
Jpeg.Canvas.Font.size = 20 '文字大(dà)小(xiǎo)
else
if Jpeg.Width<100 then
Jpeg.Canvas.Font.size = 12 '文字大(dà)小(xiǎo)
else
Jpeg.Canvas.Font.size = 14 '文字大(dà)小(xiǎo)
end if
end if
Jpeg.Canvas.Font.Bold = true '是否加粗
'Jpeg.Canvas.Font.BkMode = "Opaque"'文字背景(Opaque不透明,transparence透明)
Jpeg.Canvas.Font.Quality = 2'//水印文字的清晰度,從0~4,變換不是很大(dà),建議用2或3。
Jpeg.Canvas.Font.ShadowColor = &Hffffff '//水印文字的陰影色彩。
Jpeg.Canvas.Font.ShadowXoffset = 1 '//水印文字陰影向右偏移的像素值,輸入負值則向左偏移。
Jpeg.Canvas.Font.ShadowYoffset = 1 '//水印文字陰影向下(xià)偏移的像素值,輸入負值則向右偏移。
this_x=1
if Jpeg.Width>100 then this_x=(Jpeg.Width-100)/2
if this_x<0 then this_x=1
this_y=Jpeg.Height*6/8
Jpeg.Canvas.Print this_x,this_y, "daogou.com"'x,y坐标與水印文字
Jpeg.Save Path'給原圖片加水印
end if
Set Jpeg = Nothing
end function
%>
文章來源:桂林唯創網絡原創 --- 轉載請标明本頁具體(tǐ)網址與出處,否則視爲侵權