zoukankan      html  css  js  c++  java
  • 【顶】Asp无组件生成缩略图 (3)

    3.定义缩略图尺寸

      这部分代码就是仁者见仁,智者见智了。首先,我们需要规定缩略图显示尺寸范围,譬如:300x260,代码可以这样写:
    <%
    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语句实现,具体编码就不再累述了。

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


    文章整理:站长天空 网址:http://www.z6688.com/
    以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!
  • 相关阅读:
    centos 安装netstat
    du 常见的命令
    CentOS7 安装Python3.6.8
    Alpine安装telnet
    TypeError: 'NoneType' object is not callable
    docker中删除dead状态的容器
    监控进程,线程shell脚本
    pyinstaller打包py成exe后音乐文件播放异常pygame.error failed to execute script
    lambda expressions
    Domain logic approaches
  • 原文地址:https://www.cnblogs.com/pricks/p/1660051.html
Copyright © 2011-2022 走看看