用JPEG文件EXIF信息ASP版本(5)

发表于:2007-06-30来源:作者:点击数: 标签:
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 11)) For j = 0 To IFDDirectory(k)(IFD_IDX_Components) - 1 IFDDirectory(k)(IFD_IDX_Value) = IFDDirectory(k)(IFD_IDX_Value) Chr(ExifTemp(Offset_to_TIFF + IFDDirectory(k)(IFD_IDX_OffsetToValue
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 11))
For j = 0 To IFDDirectory(k)(IFD_IDX_Components) - 1
IFDDirectory(k)(IFD_IDX_Value) = IFDDirectory(k)(IFD_IDX_Value) & Chr(ExifTemp(Offset_to_TIFF + IFDDirectory(k)(IFD_IDX_OffsetToValue) + j))
Next
End If

Case m_SHORT, m_SSHORT
BytesPerComponent = 2
If IFDDirectory(k)(IFD_IDX_Components) * BytesPerComponent <= 4 Then
IFDDirectory(k)(IFD_IDX_Value) = _
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 8)) * 256 + _
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 9)) + _
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 10)) * 256 + _
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 11))
Else
IFDDirectory(k)(IFD_IDX_OffsetToValue) = _
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 8)) * 256 * 256 * 256 + _
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 9)) * 256 * 256 + _
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 10)) * 256 + _
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 11))
For j = IFDDirectory(k)(IFD_IDX_Components) - 1 To 0 Step -1
IFDDirectory(k)(IFD_IDX_Value) = IFDDirectory(k)(IFD_IDX_Value) & ExifTemp(Offset_to_TIFF + IFDDirectory(k)(IFD_IDX_OffsetToValue) + j)
Next
End If

Case m_LONG, m_SLONG
BytesPerComponent = 4
If IFDDirectory(k)(IFD_IDX_Components) * BytesPerComponent <= 4 Then
IFDDirectory(k)(IFD_IDX_Value) = _
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 8)) * 256 * 256 * 256 + _
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 9)) * 256 * 256 + _
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 10)) * 256 + _
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 11))
Else
IFDDirectory(k)(IFD_IDX_OffsetToValue) = _
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 8)) * 256 * 256 * 256 + _
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 9)) * 256 * 256 + _
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 10)) * 256 + _
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 11))
For j = 0 To IFDDirectory(k)(IFD_IDX_Components) - 1
IFDDirectory(k)(IFD_IDX_Value) = IFDDirectory(k)(IFD_IDX_Value) & ExifTemp(Offset_to_TIFF + IFDDirectory(k)(IFD_IDX_OffsetToValue) + j)
Next
End If

Case m_RATIONAL, m_SRATIONAL
BytesPerComponent = 8
IFDDirectory(k)(IFD_IDX_OffsetToValue) = _
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 8)) * 256 * 256 * 256 + _
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 9)) * 256 * 256 + _
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 10)) * 256 + _
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 11))
IFDDirectory(k)(IFD_IDX_Value) = _
HexToDec(ExifTemp(Offset_to_TIFF + IFDDirectory(k)(IFD_IDX_OffsetToValue) + 0)) * 256 * 256 * 256 + _
HexToDec(ExifTemp(Offset_to_TIFF + IFDDirectory(k)(IFD_IDX_OffsetToValue) + 1)) * 256 * 256 + _
HexToDec(ExifTemp(Offset_to_TIFF + IFDDirectory(k)(IFD_IDX_OffsetToValue) + 2)) * 256 + _
HexToDec(ExifTemp(Offset_to_TIFF + IFDDirectory(k)(IFD_IDX_OffsetToValue) + 3)) & _
"/" & _
HexToDec(ExifTemp(Offset_to_TIFF + IFDDirectory(k)(IFD_IDX_OffsetToValue) + 4)) * 256 * 256 * 256 + _
HexToDec(ExifTemp(Offset_to_TIFF + IFDDirectory(k)(IFD_IDX_OffsetToValue) + 5)) * 256 * 256 + _
HexToDec(ExifTemp(Offset_to_TIFF + IFDDirectory(k)(IFD_IDX_OffsetToValue) + 6)) * 256 + _
HexToDec(ExifTemp(Offset_to_TIFF + IFDDirectory(k)(IFD_IDX_OffsetToValue) + 7))

End Select

End If

If IFDDirectory(k)(IFD_IDX_Tag_No) = MakerNote Then
Offset_to_MakerNote = IFDDirectory(k)(IFD_IDX_OffsetToValue)
End If
If IFDDirectory(k)(IFD_IDX_Tag_No) = ExifOffset Then
Offset_to_ExifSubIFD = CLng(IFDDirectory(k)(IFD_IDX_Value))
‘’Debug.Print "Offset_to_ExifSubIFD: " & Offset_to_ExifSubIFD
End If
IFDDirectory(k)(IFD_IDX_Tag_Name) = LookupExifTag(IFDDirectory(k)(IFD_IDX_Tag_No))

Next

If IsIntel Then
If Not Processed_ExifSubIFD Then
Offset_to_Next_IFD = _
HexToDec(ExifTemp(Offset + 2 + (No_of_Entries * 12) + 3)) * 256 * 256 * 256 + _
HexToDec(ExifTemp(Offset + 2 + (No_of_Entries * 12) + 2)) * 256 * 256 + _
HexToDec(ExifTemp(Offset + 2 + (No_of_Entries * 12) + 1)) * 256 + _
HexToDec(ExifTemp(Offset + 2 + (No_of_Entries * 12) + 0))
‘’Debug.Print "Offset_to_Next_IFD: " & Offset_to_Next_IFD
Else
Offset_to_Next_IFD = 0
End If
Else
If Not Processed_ExifSubIFD Then
Offset_to_Next_IFD = _
HexToDec(ExifTemp(Offset + 2 + (No_of_Entries * 12) + 0)) * 256 * 256 * 256 + _
HexToDec(ExifTemp(Offset + 2 + (No_of_Entries * 12) + 1)) * 256 * 256 + _
HexToDec(ExifTemp(Offset + 2 + (No_of_Entries * 12) + 2)) * 256 + _
HexToDec(ExifTemp(Offset + 2 + (No_of_Entries * 12) + 3))
‘’Debug.Print "Offset_to_Next_IFD: " & Offset_to_Next_IFD
Else
Offset_to_Next_IFD = 0
End If
End If

If Offset_to_Next_IFD = 0 And Processed_ExifSubIFD = False Then
Offset_to_Next_IFD = Offset_to_ExifSubIFD
Processed_ExifSubIFD = True
End If

Offset = Offset_to_TIFF + Offset_to_Next_IFD

Loop While Offset_to_Next_IFD <> 0

If Offset_to_MakerNote <> 0 Then
‘’ProcessMakerNote Offset_to_MakerNote + Offset_to_TIFF
End If

End Sub

Function HexToDec(strHex)
dim lngResult
dim intIndex
dim strDigit
dim intDigit
dim intValue

lngResult = 0

for intIndex = len(strHex) to 1 step -1
strDigit = mid(strHex, intIndex, 1)
intDigit = instr("0123456789ABCDEF", ucase(strDigit))-1
if intDigit >= 0 then
intValue = intDigit * (16 ^ (len(strHex)-intIndex))
lngResult = lngResult + intValue
else
lngResult = 0
intIndex = 0 ‘’ stop the loop
end if
next

HexToDec = lngResult

End Function

Function Hex2Ascii(strHex)
dim i
for i = 1 To Len(strHex) Step 2
Hex2Ascii = Hex2Ascii & Chr(Eval("&H" & Mid(strHex, i, 2)))
Next
End Function

Function MakeSenseOfMeaninglessValues()
dim x
for x = 0 to ubound(IFDDirectory) - 1
Select Case IFDDirectory(x)(IFD_IDX_Tag_Name)
Case "Orientation"
dim OrientationTagValues
OrientationTagValues = array("Undefined","Normal","Flip Horizontal", "Rotate 180", "Flip Vertical", "Transpose", "Rotate 90", "Transverse", "Rotate 270")
if IFDDirectory(x)(IFD_IDX_Value)>=0 and IFDDirectory(x)(IFD_IDX_Value)<ubound(OrientationTagValues) then
IFDDirectory(x)(IFD_IDX_Value_Desc) = OrientationTagValues(IFDDirectory(x)(IFD_IDX_Value))
end if
End Select
next
End Function

Function HexToBinary(btHex)

‘’ Function Converts a single hex value into it‘’s binary equivalent
‘’
‘’ Written By: Mark Jager
‘’ Written Date: 8/10/2000
‘’
‘’ Free to distribute as long as code is not modified, and header is kept intact
‘’
Select Case btHex
Case "0"
HexToBinary = "0000"
Case "1"
HexToBinary = "0001"
Case "2"
HexToBinary = "0010"
Case "3"
HexToBinary = "0011"
Case "4"
HexToBinary = "0100"
Case "5"
HexToBinary = "0101"
Case "6"
HexToBinary = "0110"
Case "7"
HexToBinary = "0111"
Case "8"
HexToBinary = "1000"
Case "9"
HexToBinary = "1001"
Case "A"
HexToBinary = "1010"
Case "B"
HexToBinary = "1011"
Case "C"
HexToBinary = "1100"
Case "D"
HexToBinary = "1101"
Case "E"
HexToBinary = "1110"
Case "F"
HexToBinary = "1111"
Case Else
HexToBinary = "2222"
End Select
End Function

Function HexBlockToBinary(strHex)
‘’ Function Converts a 8 digit/32 bit hex value to its 32 bit binary equivalent
‘’
‘’ Written By: Mark Jager
‘’ Written Date: 8/10/2000
‘’
‘’ Free to distribute as long as code is not modified, and header is kept intact
‘’
Dim intPos
Dim strTemp

For intPos = 1 To Len(strHex)
strTemp = strTemp & HexToBinary(Mid(strHex, cint(intPos), 1))
Next

HexBlockToBinary = strTemp

End Function
%>

调用格式
<!--#include file="functions_exif.asp"-->
<%= GetExifByName("Date Time") %>
<%= GetExifByName("Exif Image Width") %>
<%= GetExifByName("Exif Image Height") %>



组件版到http://dazhou.net/下载

原文转自:http://www.ltesting.net