ASP读取Exif信息

index.asp

< ! -- #include file = " Exif.asp " -->
< ! -- #include file = " function.asp " -->
< %
F_Name
= " 01.jpg "
Exif
= GetImageExifInfo(F_Name)
    
if trim (Exif) <> "" then
         ExifSplit
= Split (Exif, " | " )
         TemplateHTML
= " <!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd""><html xmlns=""http://www.w3.org/1999/xhtml"" lang=""UTF-8""><head><link rel=""stylesheet"" rev=""stylesheet"" href=""glabal.css"" type=""text/css"" media=""all"" /></head><body><div id=""container""><div id=""header""><img src="" " & F_Name & " "" alt=""></div><div style=""clear: both;height:1px;overflow:hidden;margin-top:-1px;""></div><div id=""body""><Table border=""0"" cellspacing=""1"" cellpadding=""2"" class=""tableborder1"" style=""width:100%;""><tr height=""18px""> " & _
                        
" <td class=""{$abgcolor}"" align=""right"">相机品牌:</td><td class=""{$abgcolor}"" align=""left"">&nbsp;<b>{$CameraMake}</b></td> " & _
                        
" <td class=""{$abgcolor}"" align=""right"">相机型号:</td><td class=""{$abgcolor}"" align=""left"">&nbsp;<b>{$CameraModel}</b></td> " & _
                        
" </tr><tr height=""18""> " & _
                        
" <td class=""{$abgcolor}"" align=""right"">拍摄时间:</td><td class=""{$abgcolor}"" align=""left"">&nbsp;<b>{$DateTime}</b></td> " & _
                        
" <td class=""{$abgcolor}"" align=""right"">照片尺寸:</td><td class=""{$abgcolor}"" align=""left"">&nbsp;<b>{$ImageDimension}</b></td> " & _
                        
" </tr><tr height=""18""> " & _
                        
" <td class=""{$abgcolor}"" align=""right"">编辑工具:</td><td class=""{$abgcolor}"" align=""left"">&nbsp;<b>{$Software}</b></td> " & _
                        
" <td class=""{$abgcolor}"" align=""right"">ISO速度:</td><td class=""{$abgcolor}"" align=""left"">&nbsp;<b>{$ISOSpeed}</b></td> " & _
                        
" </tr><tr height=""18""> " & _
                        
" <td class=""{$abgcolor}"" align=""right"">光圈:</td><td class=""{$abgcolor}"" align=""left"">&nbsp;<b>{$FStop}</b></td> " & _
                        
" <td class=""{$abgcolor}"" align=""right"">曝光时间:</td><td class=""{$abgcolor}"" align=""left"">&nbsp;<b>{$ExposureTime}</b></td> " & _
                        
" </tr><tr height=""18""> " & _
                        
" <td class=""{$abgcolor}"" align=""right"">闪光灯:</td><td class=""{$abgcolor}"" align=""left"">&nbsp;<b>{$Flash}</b></td> " & _
                        
" <td class=""{$abgcolor}"" align=""right"">曝光补偿:</td><td class=""{$abgcolor}"" align=""left"">&nbsp;<b>{$ExposureBias}</b></td> " & _
                        
" </tr><tr height=""18""> " & _
                        
" <td class=""{$abgcolor}"" align=""right"">焦距:</td><td class=""{$abgcolor}"" align=""left"">&nbsp;<b>{$FocalLength}</b></td> " & _
                        
" <td class=""{$abgcolor}"" align=""right"">测距模式:</td><td class=""{$abgcolor}"" align=""left"">&nbsp;<b>{$MeteringMode}</b></td> " & _
                        
" </tr></table></div></div><body></html> "
         TemplateHTML
= Replace (TemplateHTML, " {$abgcolor} " ,abgcolor)
         TemplateHTML
= Replace (TemplateHTML, " {$CameraMake} " ,ExifSplit( ))
         TemplateHTML
= Replace (TemplateHTML, " {$CameraModel} " ,ExifSplit( 1 ))
         TemplateHTML
= Replace (TemplateHTML, " {$DateTime} " ,ExifSplit( 2 ))
         TemplateHTML
= Replace (TemplateHTML, " {$ImageDimension} " ,ExifSplit( 3 ))
         TemplateHTML
= Replace (TemplateHTML, " {$Software} " ,ExifSplit( 4 ))
         TemplateHTML
= Replace (TemplateHTML, " {$ISOSpeed} " ,ExifSplit( 5 ))
         TemplateHTML
= Replace (TemplateHTML, " {$FStop} " ,ExifSplit( 6 ))
         TemplateHTML
= Replace (TemplateHTML, " {$ExposureTime} " ,ExifSplit( 7 ))
         TemplateHTML
= Replace (TemplateHTML, " {$Flash} " ,ExifSplit( 8 ))
         TemplateHTML
= Replace (TemplateHTML, " {$ExposureBias} " ,ExifSplit( 9 ))
         TemplateHTML
= Replace (TemplateHTML, " {$FocalLength} " ,ExifSplit( 10 ))
         TemplateHTML
= Replace (TemplateHTML, " {$MeteringMode} " ,ExifSplit( 11 ))
         response.write TemplateHTML
    
end if
     response.write(
" <hr>读取全部信息 " )
     response.write GetAllExifInfo(F_Name)
     response.write(
" <hr>读取16进制信息 " )
     response.write GetHexInfo(F_Name)

%>

 

function.asp

<%
'********************************************************************************
'
函数名:GetImageExifInfo
'
功     能:获取基本的Exif信息
'
参     数:PicURL 文件路径,相对路径
'
返     回:用|分隔的字符串
'
********************************************************************************
Function GetImageExifInfo(PicURL)
    
Dim TempStr, TempSplit
    
Dim ExifInfo

    
set ExifInfo = new Cls_Exif
    
On Error Resume Next
       ExifInfo.ImageFile
= Server.MapPath(PicURL)
    
If Err<> Then
           Err.Clear
        
On Error Goto
        
Set ExifInfo = Nothing
           GetImageExifInfo
= ""
        
Exit Function
    
Else
         
On Error Goto
    
End if
    
if ExifInfo.hasExifInfo() and ExifInfo.GetExifByName("Camera Make")<>"" then
           TempStr
= ExifInfo.GetExifByName("Camera Make")
           GetImageExifInfo
= ExifItem(TempStr)
           TempStr
= ExifInfo.GetExifByName("Camera Model")
           GetImageExifInfo
= GetImageExifInfo & "|" & ExifItem(TempStr)
           TempStr
= ExifInfo.GetExifByName("Date Time Original")
        
If Left(TempStr, 4) = "0000" Then
               TempStr
= ExifInfo.GetExifByName("Date Time Digitized")
        
End If
        
If Left(TempStr, 4) = "0000" Then
               TempStr
= ExifInfo.GetExifByName("Date Time")
        
End If
        
If Left(TempStr, 4) = "0000" Then
               TempStr
= ""
        
End If
           GetImageExifInfo
= GetImageExifInfo & "|" & ExifItem(TempStr)
           TempStr
= ExifInfo.GetExifByName("Exif Image Width")
           TempSplit
= ExifInfo.GetExifByName("Exif Image Height")
        
if TempStr <> "" and TempSplit<>"" then
               TempStr
= TempStr & " * " & TempSplit
        
else
               TempStr
= ""
        
end if
           GetImageExifInfo
= GetImageExifInfo & "|" & ExifItem(TempStr)
           TempStr
= ExifInfo.GetExifByName("Software")
           GetImageExifInfo
= GetImageExifInfo & "|" & ExifItem(TempStr)
           TempStr
= ExifInfo.GetExifByName("ISO Speed Ratings")
           GetImageExifInfo
= GetImageExifInfo & "|" & ExifItem(TempStr)
           TempStr
= ExifInfo.GetExifByName("FStop")
           GetImageExifInfo
= GetImageExifInfo & "|" & ExifItem(TempStr)
           TempStr
= ExifInfo.GetExifByName("Exposure Time")
           GetImageExifInfo
= GetImageExifInfo & "|" & ExifItem(TempStr)
           TempStr
= ExifInfo.GetExifByName("Flash")
           GetImageExifInfo
= GetImageExifInfo & "|" & ExifItem(TempStr)
           TempStr
= ExifInfo.GetExifByName("Exposure Bias Value")
           GetImageExifInfo
= GetImageExifInfo & "|" & ExifItem(TempStr)
           TempStr
= ExifInfo.GetExifByName("Focal Length")
           GetImageExifInfo
= GetImageExifInfo & "|" & ExifItem(TempStr)
           TempStr
= ExifInfo.GetExifByName("Metering Mode")
           GetImageExifInfo
= GetImageExifInfo & "|" & ExifItem(TempStr)
    
else
           GetImageExifInfo
= ""
    
end if
    
Set ExifInfo = Nothing
End Function

Function GetAllExifInfo(PicURL)
    
set ExifInfo = new Cls_Exif
    
On Error Resume Next
       ExifInfo.ImageFile
= Server.MapPath(PicURL)
       GetAllExifInfo
=ExifInfo.ExifAllInfo()
    
Set ExifInfo = Nothing
End Function

Function GetHexInfo(PicURL)
    
set ExifInfo = new Cls_Exif
    
On Error Resume Next
       ExifInfo.ImageFile
= Server.MapPath(picURL)
       GetHexInfo
=ExifInfo.ExifAllInfo2()
    
Set ExifInfo = Nothing
End Function

Function ExifItem(ItemValue)
    
if ItemValue <> "" then
           ExifItem
= ExifItem & Server.HtmlEnCode(ItemValue)
    
else
           ExifItem
= ExifItem & "未知"
    
end if
End Function
%
>

你可能感兴趣的:(ASP读取Exif信息)