选择显示字体大小

利用fso取得bmp,jpg,png,gif文件信息

<%
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: bmp, gif, jpg and png :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: :::
'::: this function gets a specified number of bytes from any :::
'::: file, starting at the offset (base 1) :::
'::: :::
'::: passed: :::
'::: flnm => filespec of file to read :::
'::: offset => offset at which to start reading :::
'::: bytes => how many bytes to read :::
'::: :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
function getbytes(flnm, offset, bytes)
dim objfso
dim objftemp
dim objtextstream
dim lngsize
on error resume next
set objfso = createobject("scripting.filesystemobject")

' first, we get the filesize
set objftemp = objfso.getfile(flnm)
lngsize = objftemp.size
set objftemp = nothing
fsoforreading = 1
set objtextstream = objfso.opentextfile(flnm, fsoforreading)
if offset > 0 then
strbuff = objtextstream.read(offset - 1)
end if
if bytes = -1 then ' get all!
getbytes = objtextstream.read(lngsize) 'readall
else
getbytes = objtextstream.read(bytes)
end if
objtextstream.close
set objtextstream = nothing
set objfso = nothing
end function

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: :::
'::: functions to convert two bytes to a numeric value (long) :::
'::: (both little-endian and big-endian) :::
'::: :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
function lngconvert(strtemp)
lngconvert = clng(asc(left(strtemp, 1)) + ((asc(right(strtemp, 1)) * 256)))
end function
function lngconvert2(strtemp)
lngconvert2 = clng(asc(right(strtemp, 1)) + ((asc(left(strtemp, 1)) * 256)))
end function

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: :::
'::: this function does most of the real work. it will attempt :::
'::: to read any file, regardless of the extension, and will :::
'::: identify if it is a graphical image. :::
'::: :::
'::: passed: :::
'::: flnm => filespec of file to read :::
'::: width => width of image :::
'::: height => height of image :::
'::: depth => color depth (in number of colors) :::
'::: strimagetype=> type of image (e.g. gif, bmp, etc.) :::
'::: :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
function gfxspex(flnm, width, height, depth, strimagetype)
dim strpng
dim strgif
dim strbmp
dim strtype
strtype = ""
strimagetype = "(unknown)"
gfxspex = false
strpng = chr(137) & chr(80) & chr(78)
strgif = "gif"
strbmp = chr(66) & chr(77)
strtype = getbytes(flnm, 0, 3)
if strtype = strgif then ' is gif
strimagetype = "gif"
width = lngconvert(getbytes(flnm, 7, 2))
height = lngconvert(getbytes(flnm, 9, 2))
depth = 2 ^ ((asc(getbytes(flnm, 11, 1)) and 7) + 1)
gfxspex = true
elseif left(strtype, 2) = strbmp then ' is bmp
strimagetype = "bmp"
width = lngconvert(getbytes(flnm, 19, 2))
height = lngconvert(getbytes(flnm, 23, 2))
depth = 2 ^ (asc(getbytes(flnm, 29, 1)))
gfxspex = true
elseif strtype = strpng then ' is png
strimagetype = "png"
width = lngconvert2(getbytes(flnm, 19, 2))
height = lngconvert2(getbytes(flnm, 23, 2))
depth = getbytes(flnm, 25, 2)
select case asc(right(depth,1))
case 0
depth = 2 ^ (asc(left(depth, 1)))
gfxspex = true
case 2
depth = 2 ^ (asc(left(depth, 1)) * 3)
gfxspex = true
case 3
depth = 2 ^ (asc(left(depth, 1))) '8
gfxspex = true
case 4
depth = 2 ^ (asc(left(depth, 1)) * 2)
gfxspex = true
case 6
depth = 2 ^ (asc(left(depth, 1)) * 4)
gfxspex = true
case else
depth = -1
end select

else
strbuff = getbytes(flnm, 0, -1) ' get all bytes from file
lngsize = len(strbuff)
flgfound = 0
strtarget = chr(255) & chr(216) & chr(255)
flgfound = instr(strbuff, strtarget)
if flgfound = 0 then
exit function
end if
strimagetype = "jpg"
lngpos = flgfound + 2
exitloop = false
do while exitloop = false and lngpos < lngsize

do while asc(mid(strbuff, lngpos, 1)) = 255 and lngpos < lngsize
lngpos = lngpos + 1
loop
if asc(mid(strbuff, lngpos, 1)) < 192 or asc(mid(strbuff, lngpos, 1)) > 195 then
lngmarkersize = lngconvert2(mid(strbuff, lngpos + 1, 2))
lngpos = lngpos + lngmarkersize + 1
else
exitloop = true
end if
loop
'
if exitloop = false then
width = -1
height = -1
depth = -1
else
height = lngconvert2(mid(strbuff, lngpos + 4, 2))
width = lngconvert2(mid(strbuff, lngpos + 6, 2))
depth = 2 ^ (asc(mid(strbuff, lngpos + 8, 1)) * 8)
gfxspex = true
end if

end if
end function

':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
'::: test harness :::
':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

' to test, we'll just try to show all files with a .gif extension in the root of c:
set objfso = createobject("scripting.filesystemobject")
set objf = objfso.getfolder("c:\")
set objfc = objf.files
response.write "<table border=""0"" cellpadding=""5"">"
for each f1 in objfc
if instr(ucase(f1.name), ".gif") then
response.write "<tr><td>" & f1.name & "</td><td>" & f1.datecreated & "</td><td>" & f1.size & "</td><td>"
if gfxspex(f1.path, w, h, c, strtype) = true then
response.write w & " x " & h & " " & c & " colors"
else
response.write " "
end if
response.write "</td></tr>"
end if
next
response.write "</table>"
set objfc = nothing
set objf = nothing
set objfso = nothing

%>


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons