ASP no component generation thumbnails (3)

Source: Internet
Author: User
Thumbnail | No component 3. Define thumbnail dimensions

This part of the code is the beholder, the benevolent. First, we need to specify the size range of the thumbnail display, such as: 300x260, the code can write this:
<%
Dim Pxwidth,pxheight
Dim Pp '//proportion
If pwidth=0 Or pwidth= "" Then
Pxwidth=0
Pxheight=0
Else
Pp=formatnumber (pwidth/pheight,2) '//aspect ratio
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
%>

Write the above code immediately after the second step. The code for the call is as follows:
border= "0" width=<%=pxwidth%>
Height=<%=pxheight%>>

As for the picture format can be used to get, picture size can be written
<%
Response.Write pxwidth& "X" &pxheight
%>

Picture size can be implemented with fso.getfilesize (filename), and the number of clicks can be implemented simply with the SQL statement, the specific code is no longer tired.

In this way, a component-free thumbnail program is written, it may be a bit copycat, but as long as we can master the method of trust is still a great improvement.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.