利用FSO取得BMP,JPG,PNG,GIF文件信息

<%
'':::::通用分页代码研究sp; 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

%>

版权声明:
作者:Kiyo
链接:https://www.wkiyo.cn/html/2008-01/i49.html
来源:Kiyo's space
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>