【頂】Asp無組件產生縮圖 (3)

來源:互聯網
上載者:User
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/
以上資訊與文章本文是不可分割的一部分,如果您要轉載本文章,請保留以上資訊,謝謝!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.