ASP固定比例裁剪缩略图的方法(asp怎么设置)这都可以?

随心笔谈9个月前发布 admin
85 0


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

© 版权声明

相关文章