日期:2014-05-16  浏览次数:21029 次

ASPJPEG按比例缩放并按指定大小裁剪修改
 按比例缩放并按指定大小裁剪(原代码是,竖的要剪掉上下部分,模的,要剪掉左右部分,模的可以接受这样,但竖的不行)
求修改-比如竖板的人物图片裁剪成方形成把头和脚都载了,能否修改成载掉图片下面部分保留上部分
function cutjpeg(byval cutfile,byval cwidth,byval cheight)
if not aspjpegobj or lcase(left(cutfile,7)) = "http://" then cutjpeg = cutfile :exit function
dim savefolder,savefile
savefolder = installdir & "uploadfile/small/" & replace(replace(replace(replace(lcase(cutfile),".jpg",""),"/",""),"uploadfile",""),".jpeg","") & "/"
savefile = savefolder & cwidth & "x" & cheight & ".jpg"
if fso.fileexists(server.mappath(savefile)) then
cutjpeg = savefile
Jpeg.Quality=100 
else
dim jpeg
dim jwidth,jheight,nwidth,nheight
dim x1,y1,x2,y2
on error resume next
set jpeg = server.createobject(strobjectjpeg)
jpeg.regkey = "48958-77556-02411"
jpeg.open server.mappath(cutfile)
jwidth = jpeg.originalwidth
jheight = jpeg.originalheight
if (jwidth/jheight)>=(cwidth/cheight) then
nwidth=cint((jwidth/jheight)*cheight):nheight=cheight
jpeg.width=nwidth:jpeg.height=nheight
x1=int((nwidth-cwidth)/2):y1=0:x2=x1+cwidth:y2=cheight

else
nwidth=cwidth:nheight=cint((jheight/jwidth)*cwidth)
jpeg.width=nwidth:jpeg.height=nheight
x1=0:y1=int((nheight-cheight)/2):x2=cwidth:y2=y1+cheight
end if
jpeg.crop x1,y1,x2,y2
jpeg.sharpen 1,130
call createfolder(savefile) ' 需要带个文件才可生成
jpeg.save server.mappath(savefile)
set jpeg = nothing
if err then
cutjpeg = cutfile : err.clear
else
cutjpeg = savefile
end if
end if
end function

------解决方案--------------------
引用:
 按比例缩放并按指定大小裁剪(原代码是,竖的要剪掉上下部分,模的,要剪掉左右部分,模的可以接受这样,但竖的不行)
求修改-比如竖板的人物图片裁剪成方形成把头和脚都载了,能否修改成载掉图片下面部分保留上部分
function cutjpeg(byval cutfile,byval cwidth,byval cheight)
if not aspjpegobj or lcase(left(cutfile,7)) = "http://" then cutjpeg = cutfile :exit function