aspjpeg 半透明描边的实现函数

'参数说明
'big 原图路径(相对)
'small 生成图路径(相对)
'width_s 生成后宽度(数值型)
'height_s生成后高度(数值型)
'images/Alpha.jpg 为一个像素的白色块
'w 为边框宽度(数值型)

function get_img(byval big,byval small,byval width_s,byval height_s,byval w)
If IsObjInstalled("Persits.Jpeg") Then
dim Jpeg,Path
dim x1,y1,x2,y2
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Path = Server.MapPath(big)
Jpeg.Open Path
Jpeg.Interpolation = 2
Jpeg.Quality = 100
' 设置缩略图大小(这里比例设定为50%)
if Jpeg.OriginalWidth/Jpeg.OriginalHeight>=width_s/height_s then
if Jpeg.OriginalWidth>width_s then
Jpeg.height=height_s
Jpeg.width=(Jpeg.Originalwidth*height_s)/Jpeg.Originalheight
else
Jpeg.Width=Jpeg.OriginalWidth
Jpeg.Height=Jpeg.OriginalHeight
end if
else
if Jpeg.Originalheight>height_s then
Jpeg.Width=width_s
Jpeg.Height=(Jpeg.OriginalHeight*width_s)/Jpeg.OriginalWidth
else
Jpeg.Width=Jpeg.OriginalWidth
Jpeg.Height=Jpeg.OriginalHeight
end if
end if
x1=(Jpeg.Width-width_s)/2
y1=(Jpeg.height-height_s)/2
x2=x1+width_s
y2=y1+height_s
'切图
jpeg.crop x1,y1,x2,y2

Set Jpeg2 = Server.CreateObject("Persits.Jpeg")
Jpeg2.Open Server.MapPath("images/Alpha.jpg")

'上下
Jpeg2.Width=Jpeg.Width-2*w
Jpeg2.Height=w
Jpeg.DrawImage w,0, Jpeg2, 0.5, &HFF0000
Jpeg.DrawImage w,(Jpeg.Height-w), Jpeg2, 0.5, &HFF0000
'左右
Jpeg2.Width=w
Jpeg2.Height=Jpeg.Height
Jpeg.DrawImage 0,0, Jpeg2, 0.5, &HFF0000
Jpeg.DrawImage (Jpeg.Width-w),0, Jpeg2, 0.5, &HFF0000
' 保存缩略图到指定文件夹下
Jpeg.Save Server.MapPath(small)
' 注销实例
Set Jpeg = Nothing
get_img=small
else
get_img=big
end if
end function

'==================================================
'判断服务器是否支持该组件
'==================================================
Function IsObjInstalled(byval strClassString)
On Error Resume Next
IsObjInstalled = False
Err = 0
Dim xTestObj
Set xTestObj = Server.CreateObject(strClassString)
If Err = 0 Then IsObjInstalled = True
If Err = -2147352567 Then IsObjInstalled = True
Set xTestObj = Nothing
Err = 0
End Function 

  

原文地址:https://www.cnblogs.com/uuxanet/p/3282840.html