📄 funaspjpeg.asp
字号:
<%
function makesl (basepic,newpic,sl_width,sl_height)
const currdomain="http://www.jajacool.com/" '程序所在域
const syssmallfix="" '缩略图的后缀,注意保持全局一致function makesl (basepic,newpic,sl_width,sl_height)
dim todojpeg
dim sj_width,sj_height,yg_width,yg_height,zz_width,zz_height,cq_type
dim x,y,w,h
dim basefolder,basefile
'第一步,建立aspjpeg组件,打开原图
set todojpeg = server.createobject("persits.jpeg")
todojpeg.open server.mappath(basepic)
'第二步,并给出图片高宽
sj_width=todojpeg.width
sj_height=todojpeg.height
'response.write "原图宽:"&sj_width
'response.write "<br>"
'response.write "原图高:"&sj_height
'response.write "<br>"
'第三步,根据轮显图片的宽高,裁切图片
'只裁切比缩略图大的,如果有一个边小于缩略图,返回原图
'有五种形式:等高等宽;等宽大高;等高大宽;大宽小高;大高小宽
yg_width=((sl_width*sj_height)/sl_height)
yg_height=((sl_height*sj_width)/sl_width)
'response.write "放大图应该宽:"&yg_width
'response.write "<br>"
'response.write "放大图应该高:"&yg_height
'response.write "<br>"
if sj_width>yg_width then '横向裁切
zz_width=yg_width
zz_height=sj_height
cq_type=-1
elseif sj_width=yg_width then '不裁切
zz_width=yg_width
zz_height=yg_height
cq_type=0
elseif sj_width<yg_width then '竖向裁切
zz_width=sj_width
zz_height=yg_height
cq_type=1
end if
'response.write "最终确定裁切宽:"&zz_width
'response.write "<br>"
'response.write "最终确定裁切高:"&zz_height
'response.write "<br>"
x=0
y=0
w=zz_width
h=zz_height
if cq_type=-1 then
x=cint((sj_width-yg_width)/2)
elseif cq_type=1 then
y=cint((sj_height-yg_height)/2)
end if
'response.write "x点:"&x
'response.write "<br>"
'response.write "y点:"&y
'response.write "<br>"
todojpeg.crop x,y,x+w,y+h '裁切
'第四步,缩略
todojpeg.width=sl_width
todojpeg.height=sl_height
' 第五步,保存结果
basepic=replace(basepic,"/","\")
basefolder=left(basepic,instrrev(basepic,"\"))
basefile=right(basepic,len(basepic)-instrrev(basepic,"\"))
if basefolder<>"" then
newpic=basefolder&syssmallfix&basefile
else
newpic=syssmallfix&basefile
end if
todojpeg.save server.mappath(newpic)
'第六步,释放组件对象
set todojpeg = nothing
'第七步,返回缩略图路径
makesl=newpic
end function
'response.write("<img src='"&currdomain&makesl ("a.jpg","",550,300)&"'>")
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -