Function MakePic(sourcpic,newwidth,newheight,destpic)
On error resume next
MakePic=false
Set Jpeg = Server.CreateObject(“Persits.Jpeg”)
if Err then
response.Write (“錯(cuò)誤:空間沒(méi)安裝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