/ Forside / Teknologi / Udvikling / ASP / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
ASP
#NavnPoint
smorch 9259
Harlekin 1866
molokyle 1040
Steffanst.. 758
gandalf 657
smilly 564
gibson 560
cumano 530
MouseKeep.. 480
10  Random 410
Læsning af EXIF-info
Fra : Esben Kolind Laustru~


Dato : 27-02-05 17:54

Min webleverandør (B-one.net) har ikke installeret noget program
(ASPJPEJ eller lignende), som jeg umiddelbart kan anvende i
forbindelse med læsning af EXIF-informationer fra billeder.

Er der nogle, der kan hjælpe mig noget ASP-værk, som kan læse
EXIF-informationer?

På forhånd tak,

Esben


 
 
terje (28-02-2005)
Kommentar
Fra : terje


Dato : 28-02-05 00:27

Esben Kolind Laustrup (slet TE1DR) wrote:
> Min webleverandør (B-one.net) har ikke installeret noget program
> (ASPJPEJ eller lignende), som jeg umiddelbart kan anvende i
> forbindelse med læsning af EXIF-informationer fra billeder.
>
> Er der nogle, der kan hjælpe mig noget ASP-værk, som kan læse
> EXIF-informationer?

Jeg kjenner ikke til noe som er laget i ASP, men vet at det finnes
diverse kode for VB/Java/C++ som gjør dette. Ikke bare i form av
kommersielle komponenter, men også som fri kode. I prinsippet kan slik
kode godt skrives om til ASP, men dette krever nok ganske mye arbeid

Dersom du vil lage din egen løsning: Det du må gjøre er å lese bildet
som bytes. Så må du kjenne JPEG spesifikasjonene for å vite nøyaktig
hvor i bytestreamen du finner den informasjonen du ønsker. Jeg antar at
en årsak til at det ikke finnes ASP kode tilgjengelig som gjør dette er
at det fort vil ta veldig lang tid å bruke ASP til å parse bildefiler på
denne måten. Det er kanskje rett og slett ikke hensiktsmessig,
ihvertfall hvis det er snakk om filer av en viss størrelse. Altså vil en
komponent være raskere og bedre egnet.

Her er et eksempel på ASP kode som åpner bildefiler og finner
bredde/høyde informasjonen som er gjemt inne i filene. Kanskje det kan
gi deg noen ideer?

http://www.4guysfromrolla.com/webtech/code/imgsz.asp.html

terje

Casper Bang (28-02-2005)
Kommentar
Fra : Casper Bang


Dato : 28-02-05 16:52

> Jeg antar at en årsak til at det ikke finnes ASP kode tilgjengelig som
> gjør dette er at det fort vil ta veldig lang tid å bruke ASP til å parse
> bildefiler på denne måten. Det er kanskje rett og slett ikke
> hensiktsmessig, ihvertfall hvis det er snakk om filer av en viss
> størrelse. Altså vil en komponent være raskere og bedre egnet.

Hvad vil en komponent kunne gøre, som ASP ikke selv gør?
Komponenten vil jo selv skulle åbne filen, og søge igennem dem efter de EXIF
informationer der søges... hvorfor skulle en komponent kunne gøre dette
hurtigere end en ASP-side?



Jens B (28-02-2005)
Kommentar
Fra : Jens B


Dato : 28-02-05 10:37


"Esben Kolind Laustrup (slet TE1DR)" <mail@TE1DRezben.dk> skrev i en
meddelelse news:11095234450.0607476563903546@dtext.news.tele.dk...
> Min webleverandør (B-one.net) har ikke installeret noget program
> (ASPJPEJ eller lignende), som jeg umiddelbart kan anvende i
> forbindelse med læsning af EXIF-informationer fra billeder.
>
> Er der nogle, der kan hjælpe mig noget ASP-værk, som kan læse
> EXIF-informationer?
>

Jeg er en gang faldet over følgenden script, og har gemt det. Har dog aldrig
nået at rode med det, så jeg skal ikke kune sige hvor godt det er.

Default.asp
************************************************************************************************************
<!--#include file="functions_exif.asp"-->

<%

' -- sample usage --
dim pathinfo
pathinfo = Request.ServerVariables("PATH_INFO")
pathinfo = left(pathinfo,instrrev(pathinfo,"/"))

LoadImage Server.MapPath(pathinfo) & "\IMG_0807_tiny.jpg"

%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Pure ASP Exif (JPG/JPEG metadata) Parsing</title>
</head>

<body>

Date Time: <%= GetExifByName("Related Image Width") %><br>
Exif Image Width: <%= GetExifByName("Exif Image Width") %><br>
Exif Image Height: <%= GetExifByName("Exif Image Height") %><br>

<br>
<table border=1>
<tr>
<th nowrap>#</td>
<th nowrap>Tag HEX</td>
<th nowrap>Tag Name</td>
<th nowrap>Format</td>
<th nowrap>Size</td>
<th nowrap>Offset</td>
<th nowrap>Value</td>
<th nowrap>Value Described</td>
</tr>
<%
'show all tags in current images metadata
'you can use the fields in "Tag Name" in the GetExifByName(TagName) function
dim x
for x = 0 to ubound(IFDDirectory) - 1
response.write "<tr>"
response.write "<td>" & x & "</td>"
response.write "<td>" & IFDDirectory(x)(IFD_IDX_Tag_No) & "</td>"
response.write "<td>" & IFDDirectory(x)(IFD_IDX_Tag_Name) & "</td>"
response.write "<td>" & IFDDirectory(x)(IFD_IDX_Data_Format) & "</td>"
response.write "<td>" & IFDDirectory(x)(IFD_IDX_Components) & "</td>"
response.write "<td>" & IFDDirectory(x)(IFD_IDX_OffsetToValue) & "</td>"
response.write "<td>" & IFDDirectory(x)(IFD_IDX_Value) & "</td>"
response.write "<td>" & IFDDirectory(x)(IFD_IDX_Value_Desc) & "</td></tr>"
next
%>
<table>
</body>
</html>






functions_exif.asp
************************************************************************************************************
<%

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_APP1
dim Offset_to_TIFF
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)
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
GetExifByName = IFDDirectory(i)(IFD_IDX_Value)
Exit For
End If
Next
End Function

sub LoadImage(picFile)
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) = "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 OpenJPGFile(FileName)

const TristateUseDefault = -2
const TristateTrue = -1
const TristateFalse = 0

const ForReading = 1
const ForWriting = 2
const ForAppending = 8

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)
'HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 1)) * 256 + _
'HexToDec(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) = _
HexToDec(ExifTemp((Offset + 2) + ((i - 1) * 12) + 0)) * 256 + _
HexToDec(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(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 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

%>



terje (28-02-2005)
Kommentar
Fra : terje


Dato : 28-02-05 15:11

Jens B wrote:
> Jeg er en gang faldet over følgenden script, og har gemt det. Har
dog aldrig
> nået at rode med det, så jeg skal ikke kune sige hvor godt det er.

Et Google søk ga denne linken som ser ut til å tilby et mer oppdatert
skript:
http://www.spaz.com/mr/work/aspexiffuncs/

terje

Søg
Reklame
Statistik
Spørgsmål : 177558
Tips : 31968
Nyheder : 719565
Indlæg : 6408926
Brugere : 218888

Månedens bedste
Årets bedste
Sidste års bedste