Function MakePic(sourcpic,newwidth,newheight,destpic)
On error resume next
MakePic=false
Set Jpeg=Server.CreateObject(“Persits.Jpeg”)
if Err then
response.Write (“错误:空间没安装aspjpeg组件”)
response.end
end if
Jpeg.Quality=100
Jpeg.Open sourcpic
jpeg.PreserveAspectRatio=True ‘等比缩放
if jpeg.OriginalWidth/jpeg.OriginalHeight > newwidth/newheight then’太扁了,要剪掉左右部分
jpeg.Height=newheight
jpeg.crop CInt((jpeg.Width – newwidth)/2),0,CInt((jpeg.Width – newwidth)/2)+newwidth,newheight
else ‘太高了,要剪掉上下部分
jpeg.Width=newwidth
jpeg.crop 0,CInt((jpeg.Height – newheight)/2),newwidth,CInt((jpeg.Height – newheight)/2)+newheight
end if
Jpeg.Save destpic
if err.number=0 then MakePic=True
Jpeg.Close
Set Jpeg=Nothing
End function
Function MakePic(sourcpic,newwidth,newheight,destpic)
On error resume next
MakePic=false
Set Jpeg=Server.CreateObject(“Persits.Jpeg”)
if Err then
response.Write (“错误:空间没安装aspjpeg组件”)
response.end
end if
Jpeg.Quality=100
Jpeg.Open sourcpic
jpeg.PreserveAspectRatio=True ‘等比缩放
if jpeg.OriginalWidth/jpeg.OriginalHeight > newwidth/newheight then’太扁了,要剪掉左右部分
jpeg.Height=newheight
jpeg.crop CInt((jpeg.Width – newwidth)/2),0,CInt((jpeg.Width – newwidth)/2)+newwidth,newheight
else ‘太高了,要剪掉上下部分
jpeg.Width=newwidth
jpeg.crop 0,CInt((jpeg.Height – newheight)/2),newwidth,CInt((jpeg.Height – newheight)/2)+newheight
end if
Jpeg.Save destpic
if err.number=0 then MakePic=True
Jpeg.Close
Set Jpeg=Nothing
End function
© 版权声明
文章版权归作者所有,未经允许请勿转载。