日期:2014-05-17 浏览次数:21071 次
<%
Function BuildSmallPic(m_path1, m_path2, n_MaxWidth, n_MaxHeight, n_Quality)
Err.Clear
'On Error Resume Next
'检 查 组件是否已经注册
Dim AspJpeg
Set AspJpeg = Server.Createobject("Persits.Jpeg")
If Err.Number <> 0 Then
Err.Clear
BuildSmallPic = "组件安装不正确!"
Exit Function
End If
' 按 比例取得缩略图宽度和高度
Dim n_picWidth, n_picHeight
Dim n_newWidth, n_newHeight
Dim extn
extn = split(m_path1, ".")
select case extn(ubound(extn))
case "jpg"
AspJpeg.Open Server.MapPath(m_path1)
n_picWidth = AspJpeg.Width
n_picHeight = AspJpeg.Height
if n_picWidth > n_MaxWidth or n_picHeight > n_MaxHeight then
if n_picWidth/n_picHeight >= n_MaxWidth/n_MaxHeight then
AspJpeg.Width = n_MaxWidth
AspJpeg.Height = n_MaxWidth/(n_picWidth/n_picHeight)
else
AspJpeg.Width = n_picWidth/n_picHeight*n_MaxHeight
AspJpeg.Height = n_MaxHeight
end if
else
AspJpeg.Width = n_picWidth
AspJpeg.Height = n_picHeight
end if
AspJpeg.Quality = n_Quality
Gif.Save Server.MapPath(m_path2) '保存
If Err.Number <> 0 Then
Err.Clear
BuildSmallPic = "Error_03"
Exit Function
End If
Set AspJpeg = Nothing
case "gif"
Set Gif = AspJpeg.Gif
Gif.Open Server.MapPath(m_path1)
n_picWidth = Gif.Width
n_picHeight = Gif.Height
if n_picWidth > n_MaxWidth or n_picHeight > n_MaxHeight then
if n_picWidth/n_picHeight >= n_MaxWidth/n_MaxHeight then
Gif.Resize n_MaxWidth, n_MaxWidth/(n_picWidth/n_picHeight)
else
Gif.Resize n_picWidth/n_picHeight*n_MaxHeight, n_MaxHeight
end if
else
Gif.Resize n_picWidth, n_picHeight
end if
Gif.DisposalMethod =2
Gif.PenColor = 235
Gif.FontFamily = "Arial"
Gif.FontSize = 8
Gif.PrintText 20,10, "www.Chinmo.net"
Gif.Save Server.MapPath(m_path2) '保存
If Err.Number <> 0 Then
Err.Clear
BuildSmallPic = "Error_03"
Exit Function
End If
Set AspJpeg = Nothing
Set Gif = Nothing
case "png"
AspJpeg.Open Server.MapPath(m_path1)
n_picWidth = AspJpeg.Width
n_picHeight = AspJpeg.Height
AspJpeg.PreserveAspectRatio = True
if n_picWidth > n_MaxWidth or n_picHeight > n_MaxHeight then
if n_picWidth/n_picHeight >= n_MaxWidth/n_MaxHeight then
AspJpeg.Width = n_MaxWidth
AspJpeg.Height = n_MaxWidth/(n_picWidth/n_picHeight)
else
AspJpeg.Width