欢迎光临
我们一直在努力

Asp无组件生成缩略图 (3)-ASP教程,组件开发

建站超值云服务器,限时71元/月

3.定义缩略图尺寸

  这部分代码就是仁者见仁,智者见智了。首先,我们需要规定缩略图显示尺寸范围,譬如:300×260,代码可以这样写:
<%
dim pxwidth,pxheight
dim pp //proportion
if pwidth=0 or pwidth=”” then
pxwidth=0
pxheight=0
else
pp=formatnumber(pwidth/pheight,2) //长宽比
end if
if pwidth>=pheight then
if pwidth>=300 then
pxwidth=300
pxheight=formatnumber(300/pp,0)
else
pxwidth=pwidth
pxheight=pheight
end if
else
if pheight>=260 then
pxheight=260
pxwidth=formatnumber(260*pp,0)
else
pxwidth=pwidth
pxheight=pheight
end if
end if
%>

  将上面的代码紧接第二步写下即可。调用时代码如下:
<img src=<%=curfilename%> border=”0″ width=<%=pxwidth%>
height=<%=pxheight%>>

  至于图片格式可以用得到,图片尺寸可以写成
<%
response.write pxwidth&”x”&pxheight
%>

  图片大小可以用fso.getfilesize(filename)来实现,而点击次数可以简单地用sql语句实现,具体编码就不再累述了。

  这样,一个无组件生成缩略图程序就写好了,可能有点拿来主义,不过只要大家能将方法掌握相信还是有很大提高的。

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » Asp无组件生成缩略图 (3)-ASP教程,组件开发
分享到: 更多 (0)