<% const TristateUseDefault = -2 const TristateTrue = -1 const TristateFalse = 0 const ForReading = 1 const ForWriting = 2 const ForAppending = 8 const m_BYTE = 1 const m_STRING = 2 const m_SHORT = 3 const m_LONG = 4 const m_RATIONAL = 5 const m_SBYTE = 6 const m_UNDEFINED = 7 const m_SSHORT = 8 const m_SLONG = 9 const m_SRATIONAL = 10 const m_SINGLE = 11 const m_DOUBLE = 12 const ExifOffset = "8769" const MakerNote = "927C" Public ExifLookup set ExifLookup = Server.CreateObject("Scripting.Dictionary") 'IFD0 Tags ExifLookup.Add "Image Description", "010E" ExifLookup.Add "Camera Make", "010F" ExifLookup.Add "Camera Model", "0110" ExifLookup.Add "Orientation", "0112" ExifLookup.Add "X Resolution", "011A" ExifLookup.Add "Y Resolution", "011B" ExifLookup.Add "Resolution Unit", "0128" ExifLookup.Add "Software", "0131" ExifLookup.Add "Date Time", "0132" ExifLookup.Add "White Point", "013E" ExifLookup.Add "Primary Chromaticities", "013F" ExifLookup.Add "YCbCr Coefficients", "0211" ExifLookup.Add "YCbCr Positioning", "0213" ExifLookup.Add "Reference Black White", "0214" ExifLookup.Add "Copyright", "8298" ExifLookup.Add "Exif Offset", "8769" 'ExifSubIFD Tags ExifLookup.Add "Exposure Time", "829A" ExifLookup.Add "FStop", "829D" ExifLookup.Add "Exposure Program", "8822" ExifLookup.Add "ISO Speed Ratings", "8827" ExifLookup.Add "Exif Version", "9000" ExifLookup.Add "Date Time Original", "9003" ExifLookup.Add "Date Time Digitized", "9004" ExifLookup.Add "Components Configuration", "9101" ExifLookup.Add "Compressed Bits Per Pixel", "9102" ExifLookup.Add "Shutter Speed Value", "9201" ExifLookup.Add "Aperture Value", "9202" ExifLookup.Add "Brightness Value", "9203" ExifLookup.Add "Exposure Bias Value", "9204" ExifLookup.Add "Max Aperture Value", "9205" ExifLookup.Add "Subject Distance", "9206" ExifLookup.Add "Metering Mode", "9207" ExifLookup.Add "Light Source", "9208" ExifLookup.Add "Flash", "9209" ExifLookup.Add "Focal Length", "920A" ExifLookup.Add "Maker Note", "927C" ExifLookup.Add "User Comment", "9286" ExifLookup.Add "Subsec Time", "9290" ExifLookup.Add "Subsec Time Original", "9291" ExifLookup.Add "Subsec Time Digitized", "9292" ExifLookup.Add "Flash Pix Version", "A000" ExifLookup.Add "Color Space", "A001" ExifLookup.Add "Exif Image Width", "A002" ExifLookup.Add "Exif Image Height", "A003" ExifLookup.Add "Related Sound File", "A004" ExifLookup.Add "Exif Interoperability Offset", "A005" ExifLookup.Add "Focal Plane X Resolution", "A20E" ExifLookup.Add "Focal Plane Y Resolution", "A20F" ExifLookup.Add "Focal Plane Resolution Unit", "A210" ExifLookup.Add "Exposure Index", "A215" ExifLookup.Add "Sensing Method", "A217" ExifLookup.Add "File Source", "A300" ExifLookup.Add "Scene Type", "A301" ExifLookup.Add "CFA Pattern", "A302" 'Interoperability IFD Tags ExifLookup.Add "Interoperability Index", "01" ExifLookup.Add "Interoperability Version", "02" ExifLookup.Add "Related Image File Format", "1000" ExifLookup.Add "Related Image Width", "1001" ExifLookup.Add "Related Image Length", "1002" 'IFD1 Tags ExifLookup.Add "Image Width", "0100" ExifLookup.Add "Image Height", "0101" ExifLookup.Add "Bits Per Sample", "0102" ExifLookup.Add "Compression", "0103" ExifLookup.Add "Photometric Interpretation", "0106" ExifLookup.Add "Strip Offsets", "0111" ExifLookup.Add "Sample Per Pixel", "0115" ExifLookup.Add "Rows Per Strip", "0116" ExifLookup.Add "Strip Byte Counts", "0117" ExifLookup.Add "X Resolution 2", "011A" ExifLookup.Add "Y Resolution 2", "011B" ExifLookup.Add "Planar Configuration", "011C" ExifLookup.Add "Resolution Unit 2", "0128" ExifLookup.Add "JPEG Interchange Format", "0201" ExifLookup.Add "JPEG Interchange Format Length", "0202" ExifLookup.Add "YCbCr Coeffecients", "0211" ExifLookup.Add "YCbCr Sub Sampling", "0212" ExifLookup.Add "YCbCr Positioning 2", "0213" ExifLookup.Add "Reference Black White 2", "0214" 'Misc Tags ExifLookup.Add "New Subfile Type", "FE" ExifLookup.Add "Subfile Type", "FF" ExifLookup.Add "Transfer Function", "012D" ExifLookup.Add "Artist", "013B" ExifLookup.Add "Predictor", "013D" ExifLookup.Add "Tile Width", "0142" ExifLookup.Add "Tile Length", "0143" ExifLookup.Add "Tile Offsets", "0144" ExifLookup.Add "Tile Byte Counts", "0145" ExifLookup.Add "Sub IFDs", "014A" ExifLookup.Add "JPEG Tables", "015B" ExifLookup.Add "CFA Repeat Pattern Dim", "828D" ExifLookup.Add "CFA Pattern 2", "828E" ExifLookup.Add "Battery Level", "828F" ExifLookup.Add "IPTC_NAA", "83BB" ExifLookup.Add "Inter Color Profile", "8773" ExifLookup.Add "Spectral Sensitivity", "8824" ExifLookup.Add "GPS Info", "8825" ExifLookup.Add "OECF", "8828" ExifLookup.Add "Interlace", "8829" ExifLookup.Add "Time Zone Offset", "882A" ExifLookup.Add "Self Timer Mode", "882B" ExifLookup.Add "Flash Energy", "920B" ExifLookup.Add "Spatial Frequency Response", "920C" ExifLookup.Add "Noise", "920D" ExifLookup.Add "Image Number", "9211" ExifLookup.Add "Security Classification", "9212" ExifLookup.Add "Image History", "9213" ExifLookup.Add "Subject Location", "9214" ExifLookup.Add "Exposure Index 2", "9215" ExifLookup.Add "TIFFEP Standard ID", "9216" ExifLookup.Add "Flash Energy 2", "A20B" ExifLookup.Add "Spatial Frequency Response 2", "A20C" ExifLookup.Add "Subject Location 2", "A214" dim Offset_to_IFD0 dim Offset_to_APP0 dim Offset_to_APP1 dim Offset_to_TIFF dim Offset_to_SOS dim Length_of_APP0 dim Length_of_APP1 dim Offset_to_Next_IFD dim IFDDirectory IFDDirectory = array(0) dim Offset_to_ExifSubIFD dim ImageFile dim IsLoaded dim ExifTemp ExifTemp = array(0) const IFD_IDX_Tag_No = 0 const IFD_IDX_Tag_Name = 1 const IFD_IDX_Data_Format = 2 const IFD_IDX_Components = 3 const IFD_IDX_Value = 4 const IFD_IDX_Value_Desc = 5 const IFD_IDX_OffsetToValue = 6 Function LookupExifTag(which) dim item for each item in ExifLookup if ExifLookup(item) = which then LookupExifTag = item exit function end if next LookupExifTag = which End Function Function GetExifByName(ExifTag,ValueDescribed) If IsLoaded = False And ImageFile <> "" Then LoadImage (ImageFile) ElseIf IsLoaded = False And ImageFile = "" Then Exit Function End If Dim i For i = 0 To UBound(IFDDirectory) - 1 If IFDDirectory(i)(IFD_IDX_Tag_Name) = ExifTag Then if ValueDescribed then GetExifByName = IFDDirectory(i)(IFD_IDX_Value_Desc) else GetExifByName = IFDDirectory(i)(IFD_IDX_Value) end if Exit For End If Next End Function sub LoadImage(picFile) IFDDirectory = array(0) 'If ImageFile = "" Then ImageFile = picFile If ImageFile = "" Then Exit sub End If 'End If OpenJPGFile ImageFile If InspectJPGFile = False Then IsLoaded = False Exit Sub End If If IsIntel Then Offset_to_IFD0 = _ HexToDec(ExifTemp(Offset_to_APP1 + 17)) * 256 * 256 * 256 + _ HexToDec(ExifTemp(Offset_to_APP1 + 16)) * 256 * 256 + _ HexToDec(ExifTemp(Offset_to_APP1 + 15)) * 256 + _ HexToDec(ExifTemp(Offset_to_APP1 + 14)) Else Offset_to_IFD0 = _ HexToDec(ExifTemp(Offset_to_APP1 + 14)) * 256 * 256 * 256 + _ HexToDec(ExifTemp(Offset_to_APP1 + 15)) * 256 * 256 + _ HexToDec(ExifTemp(Offset_to_APP1 + 16)) * 256 + _ HexToDec(ExifTemp(Offset_to_APP1 + 17)) End If 'Debug.Print "Offset_to_IFD0: " & Offset_to_IFD0 IsLoaded = True GetDirectoryEntries Offset_to_TIFF + Offset_to_IFD0 MakeSenseOfMeaninglessValues End sub Function InspectJPGFile() Dim i If ExifTemp(0) <> "FF" And ExifTemp(1) <> "D8" Then InspectJPGFile = False Else For i = 2 To UBound(ExifTemp) - 1 If ExifTemp(i) = "FF" And ExifTemp(i + 1) = "E0" Then Offset_to_APP0 = i Exit For End If Next If Offset_to_APP0 = 0 Then InspectJPGFile = False End If 'for some reason it dies here some times. telling it to carry on seems to fix it. :P 'additionally this variable only matters when writing to JPEG so no worries... on error resume next Length_of_APP0 = _ HexToDec(ExifTemp(Offset_to_APP0 + 2)) * 256 + _ HexToDec(ExifTemp(Offset_to_APP0 + 3)) on error goto 0 For i = 2 To UBound(ExifTemp) - 1 If ExifTemp(i) = "FF" And ExifTemp(i + 1) = "E1" Then Offset_to_APP1 = i Exit For End If Next If Offset_to_APP1 = 0 Then InspectJPGFile = False End If Offset_to_TIFF = Offset_to_APP1 + 10 Length_of_APP1 = _ HexToDec(ExifTemp(Offset_to_APP1 + 2)) * 256 + _ HexToDec(ExifTemp(Offset_to_APP1 + 3)) If Chr(HexToDec(ExifTemp(Offset_to_APP1 + 4))) & Chr(HexToDec(ExifTemp(Offset_to_APP1 + 5))) & _ Chr(HexToDec(ExifTemp(Offset_to_APP1 + 6))) & Chr(HexToDec(ExifTemp(Offset_to_APP1 + 7))) <> "Exif" Then InspectJPGFile = False Exit Function End If InspectJPGFile = True End If End Function Function IsIntel() If ExifTemp(Offset_to_TIFF) = "49" Then IsIntel = True Else IsIntel = False End If End Function Function writeExifToJPG(ExifData, FileName) Dim FSO, FSO2, File, i 'Const adTypeBinary = 1 'Const adTypeText = 2 'Const adSaveCreateOverWrite = 2 If IsLoaded = False And ImageFile <> "" Then LoadImage (ImageFile) ElseIf IsLoaded = False And ImageFile = "" Then Exit Function End If 'Create Stream object 'Dim BinaryStream 'Set BinaryStream = CreateObject("ADODB.Stream") 'Specify stream type - we want To save binary data. 'BinaryStream.Type = adTypeBinary 'Open the stream And write binary data To the object 'BinaryStream.Open 'BinaryStream.Write ByteArray Set FSO = CreateObject("Scripting.FileSystemObject") 'Create text stream object Dim TextStream Set TextStream = FSO.CreateTextFile(FileName & ".TMP") For i = 0 To (Offset_to_APP0 + 2 + Length_of_APP0 - 1) TextStream.Write Hex2Ascii(ExifTemp(i)) Next TextStream.Write Hex2Ascii(ExifData) For i = (Offset_to_APP0 + 2 + Length_of_APP0) To UBound(ExifTemp) TextStream.Write Hex2Ascii(ExifTemp(i)) Next Set FSO2 = Server.CreateObject("Scripting.FileSystemObject") If FSO2.FileExists(FileName) Then Set File = FSO2.OpenTextFile(FileName, ForReading, False, TristateFalse) i = 0 While Not File.AtEndOfStream if i > UBound(ExifTemp) then 'BinaryStream.Write File.Read(1) TextStream.Write File.Read(1) end if i = i + 1 Wend File.Close Set File = Nothing Else Response.Write("File does not exist") End If Set FSO2 = Nothing Set FSO = Nothing 'Save binary data To disk 'BinaryStream.SaveToFile FileName & ".TMP", adSaveCreateOverWrite End Function Function OpenJPGFile(FileName) Dim Ascii, lastHex, currentHex, SOSFound Dim FSO, File, i If Not FileName = "" Then If InStr(1, FileName, ":\") = 0 Then FileName = Server.MapPath(FileName) End If Set FSO = Server.CreateObject("Scripting.FileSystemObject") If FSO.FileExists(FileName) Then Set File = FSO.OpenTextFile(FileName, ForReading, False, TristateFalse) i = 0 While Not File.AtEndOfStream and SOSFound = false Ascii = Asc(File.Read(1)) lastHex = currentHex currentHex = Right("0" & Hex(Ascii), 2) if lastHex & currentHex = "FFDA" or i > 100000 then SOSFound = true end if ExifTemp(i) = currentHex i = i + 1 ReDim Preserve ExifTemp(i) Wend File.Close Set File = Nothing Else Response.Write("File does not exist") End If Set FSO = Nothing End If end function Sub GetDirectoryEntries(Offset) Dim No_of_Entries Dim Upper_IFDDirectory Dim NewDimensions Dim Processed_ExifSubIFD Dim BytesPerComponent Dim Offset_to_MakerNote Dim i, j, k Do If IsIntel Then No_of_Entries = _ HexToDec(ExifTemp(Offset + 1)) * 256 + _ HexToDec(ExifTemp(Offset + 0)) Else No_of_Entries = _ HexToDec(ExifTemp(Offset + 0)) * 256 + _ HexToDec(ExifTemp(Offset + 1)) End If On Error Resume Next Upper_IFDDirectory = UBound(IFDDirectory) On Error GoTo 0 NewDimensions = Upper_IFDDirectory + No_of_Entries ReDim Preserve IFDDirectory(NewDimensions) For i = 1 To No_of_Entries k = Upper_IFDDirectory + i - 1 IFDDirectory(k) = array(null,null,null,null,null,null,null) 'With IFDDirectory(Upper_IFDDirectory + i) If IsIntel Then IFDDirectory(k)(IFD_IDX_Tag_No) = _ ExifTemp((Offset + 2) + ((i - 1) * 12) + 1) & _ ExifTemp((Offset + 2) + ((i - 1) * 12) + 0) IFDDirectory(k)(IFD_IDX_Data_Format) = _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 3)) * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 2)) IFDDirectory(k)(IFD_IDX_Components) = _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 7)) * 256 * 256 * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 6)) * 256 * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 5)) * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 4)) Select Case IFDDirectory(k)(IFD_IDX_Data_Format) Case m_BYTE, m_SBYTE BytesPerComponent = 1 If IFDDirectory(k)(IFD_IDX_Components) * BytesPerComponent <= 4 Then IFDDirectory(k)(IFD_IDX_Value) = _ ExifTemp((Offset + 2) + ((i - 1) * 12) + 11) & _ ExifTemp((Offset + 2) + ((i - 1) * 12) + 10) & _ ExifTemp((Offset + 2) + ((i - 1) * 12) + 9) & _ ExifTemp((Offset + 2) + ((i - 1) * 12) + 8) Else IFDDirectory(k)(IFD_IDX_OffsetToValue) = _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 11)) * 256 * 256 * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 10)) * 256 * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 9)) * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 8)) 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_STRING, m_UNDEFINED BytesPerComponent = 1 If IFDDirectory(k)(IFD_IDX_Components) * BytesPerComponent <= 4 Then IFDDirectory(k)(IFD_IDX_Value) = _ Chr(HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 11))) & _ Chr(HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 10))) & _ Chr(HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 9))) & _ Chr(HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 8))) Else IFDDirectory(k)(IFD_IDX_OffsetToValue) = _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 11)) * 256 * 256 * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 10)) * 256 * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 9)) * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 8)) For j = 0 To IFDDirectory(k)(IFD_IDX_Components) - 2 IFDDirectory(k)(IFD_IDX_Value) = IFDDirectory(k)(IFD_IDX_Value) & Chr(HexToDec(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) + 11)) * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 10)) + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 9)) * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 8)) Else IFDDirectory(k)(IFD_IDX_OffsetToValue) = _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 11)) * 256 * 256 * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 10)) * 256 * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 9)) * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 8)) 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_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) + 11)) * 256 * 256 * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 10)) * 256 * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 9)) * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 8)) Else IFDDirectory(k)(IFD_IDX_OffsetToValue) = _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 11)) * 256 * 256 * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 10)) * 256 * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 9)) * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 8)) 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) + 11)) * 256 * 256 * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 10)) * 256 * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 9)) * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 8)) IFDDirectory(k)(IFD_IDX_Value) = _ HexToDec(ExifTemp(Offset_to_TIFF + IFDDirectory(k)(IFD_IDX_OffsetToValue) + 3)) * 256 * 256 * 256 + _ HexToDec(ExifTemp(Offset_to_TIFF + IFDDirectory(k)(IFD_IDX_OffsetToValue) + 2)) * 256 * 256 + _ HexToDec(ExifTemp(Offset_to_TIFF + IFDDirectory(k)(IFD_IDX_OffsetToValue) + 1)) * 256 + _ HexToDec(ExifTemp(Offset_to_TIFF + IFDDirectory(k)(IFD_IDX_OffsetToValue) + 0)) & _ "/" & _ HexToDec(ExifTemp(Offset_to_TIFF + IFDDirectory(k)(IFD_IDX_OffsetToValue) + 7)) * 256 * 256 * 256 + _ HexToDec(ExifTemp(Offset_to_TIFF + IFDDirectory(k)(IFD_IDX_OffsetToValue) + 6)) * 256 * 256 + _ HexToDec(ExifTemp(Offset_to_TIFF + IFDDirectory(k)(IFD_IDX_OffsetToValue) + 5)) * 256 + _ HexToDec(ExifTemp(Offset_to_TIFF + IFDDirectory(k)(IFD_IDX_OffsetToValue) + 4)) End Select Else IFDDirectory(k)(IFD_IDX_Tag_No) = _ ExifTemp((Offset + 2) + ((i - 1) * 12) + 0) & _ ExifTemp((Offset + 2) + ((i - 1) * 12) + 1) IFDDirectory(k)(IFD_IDX_Data_Format) = _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 2)) * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 3)) IFDDirectory(k)(IFD_IDX_Components) = _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 4)) * 256 * 256 * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 5)) * 256 * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 6)) * 256 + _ HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 7)) Select Case IFDDirectory(k)(IFD_IDX_Data_Format) Case m_BYTE, m_SBYTE BytesPerComponent = 1 If IFDDirectory(k)(IFD_IDX_Components) * BytesPerComponent <= 4 Then IFDDirectory(k)(IFD_IDX_Value) = _ ExifTemp((Offset + 2) + ((i - 1) * 12) + 8) & _ ExifTemp((Offset + 2) + ((i - 1) * 12) + 9) & _ ExifTemp((Offset + 2) + ((i - 1) * 12) + 10) & _ 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_STRING, m_UNDEFINED BytesPerComponent = 1 If IFDDirectory(k)(IFD_IDX_Components) * BytesPerComponent <= 4 Then IFDDirectory(k)(IFD_IDX_Value) = _ Chr(HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 8))) & _ Chr(HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 9))) & _ Chr(HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 10))) & _ Chr(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) & Chr(HexToDec(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)