Ricavare i valori EXIF di una foto JPG
Gli Exif (acronimo di EXchangeable Image file Format) sono il dettaglio tecnico sull’immagine appena registrata dalla fotocamera sotto forma di file. Dettagli che vengono salvati sullo stesso file digitale.
Questa classe DisplayEXIFInfo permette di leggere tutti gli EXIF di una foto .jpg, in seguito il codice sorgente scritto in VBScript
Sub DisplayEXIFInfo
Dim pImage, strJPEGPath
Dim dblLat, dblLon, dblAlt, dtTime
'++ get the JPEG image
strJPEGPath= CommonDialog.ShowOpen("jpg","JPG - JPEG Image|*.jpg","",&H1000)
If strJPEGPath = "" Then Exit Sub
'++ create the Image object and load the JPEG image
Set pImage = Application.CreateAppObject("Image")
pImage.Open strJPEGPath
'++ set title and comments
pImage.Title = "My Photo"
pImage.Comments = "Taken by me on a beautiful, sunny day"
'++ read some EXIF fields
dblLat = pImage.Properties(2)
dblLon = pImage.Properties(4)
dblAlt = pImage.Properties(6)
dtTime = pImage.Properties(36867)
'++ display info
Application.MessageBox "Title: " & pImage.Title & apNewLine & _
"Comments: " & pImage.Comments & apNewLine & _
"Lat: " & dblLat & apNewLine & _
"Lon: " & dblLon & apNewLine & _
"Alt: " & dblAlt & apNewLine & _
"Time taken: " & dtTime, apInformation, "EXIF"
'++ clean up
pImage.Close
End Sub
Sub DisplayEXIFInfo
Dim pImage, strJPEGPath
Dim dblLat, dblLon, dblAlt, dtTime
'++ get the JPEG image
strJPEGPath= CommonDialog.ShowOpen("jpg","JPG - JPEG Image|*.jpg","",&H1000)
If strJPEGPath = "" Then Exit Sub
'++ create the Image object and load the JPEG image
Set pImage = Application.CreateAppObject("Image")
pImage.Open strJPEGPath
'++ set title and comments
pImage.Title = "My Photo"
pImage.Comments = "Taken by me on a beautiful, sunny day"
'++ read some EXIF fields
dblLat = pImage.Properties(2)
dblLon = pImage.Properties(4)
dblAlt = pImage.Properties(6)
dtTime = pImage.Properties(306)
'++ display info
Application.MessageBox "Title: " & pImage.Title & apNewLine & _
"Comments: " & pImage.Comments & apNewLine & _
"Lat: " & dblLat & apNewLine & _
"Lon: " & dblLon & apNewLine & _
"Alt: " & dblAlt & apNewLine & _
"Time taken: " & dtTime, apInformation, "EXIF"
'++ clean up
pImage.Close
End Sub