Hier:
http://www.purebasic.fr/english/viewtop ... 943#p92943
findeste einen Code zum Auslesen des Datums. Hab extra für Dich mal an die aktuelle
PB Version angepaßt:
Code: Alles auswählen
UseJPEGImageDecoder()
#Exif_DT_Modified = $132 ; 306
#Exif_Sub = $8769 ; 34665
#Exif_DT_Taken = $9003 ; 36867
#Exif_DT_Digitized = $9004 ; 36868
#Header = 12
#ModifiedDate = 0
#TakenDate = 1
#DigitizedDate = 2
Global date_time
Global Dim exifDate$(2)
Procedure.s GetExifDateTime(jpg$, writeIt, newDateTime$)
OpenFile(0, jpg$)
; --> Byte 0 of EXIF begins after JPEG header
FileSeek(0, #Header)
; --> Bytes 0-1 is byte order 18761 ($4949) is Intel and 19789 ($4D4D) is Motorola
byteOrder = ReadWord(0)
If byteOrder = $4949
; --> Bytes 2-3 is TIFF format, it's always 42 ($2A). If not, give up.
tifFormat = ReadWord(0)
If tifFormat = $2A
; --> Bytes 4-7 is starting offset for IFD (Image File Directory)
ifd1 = ReadLong(0)
; --> Move to start of IFD
FileSeek(0, ifd1 + #Header)
; --> First 2 bytes of IFD is number of field entries
nFields = ReadWord(0)
; --> Loop through all fields to find Date/Time stamp
date_time = #False
For i = 1 To nFields
; --> Bytes 0-1 contain the Tag for the field.
currentTag = ReadWord(0) &$FFFF
Select currentTag
Case #Exif_DT_Modified
; --> Bytes 2-3 contain the field Type.
; --> We know this will be 2 (ASCII) For Date/Time
fieldType = ReadWord(0)
; --> Bytes 4-7 contain the Length of the field.
fieldLength = ReadLong(0)
currentloc = Loc(0)
; --> Bytes 8-11 contain a pointer to ASCII Date/Time
fieldValue = ReadLong(0)
; --> Move to that pointer
FileSeek(0, fieldValue + #Header)
; --> This is the start point of Dat/Time ASCII string
If writeIt And newDateTime$
WriteString(0, newDateTime$)
date_time$ = newDateTime$
MessageRequester("Info", "Date and Time have been changed.")
Else
exifDate$(#ModifiedDate) = ReadString(0)
allDate$ = "Modified:" + #TAB$ + exifDate$(#ModifiedDate)
FileSeek(0, currentloc+4)
EndIf
Case #Exif_Sub
FileSeek(0, Loc(0) + 6)
ExifLoc = ReadLong(0)
FileSeek(0, ExifLoc + #Header + 2)
Repeat
tag = ReadWord(0) &$FFFF
If tag = #Exif_DT_Taken
currLoc = Loc(0)
FileSeek(0, Loc(0) + 6)
datLoc = ReadLong(0)
FileSeek(0, datLoc + #Header)
exifDate$(#TakenDate) = ReadString(0)
allDate$ + #CRLF$ + "Taken:" + #TAB$ + exifDate$(#TakenDate)
FileSeek(0, currLoc + 10)
EndIf
If tag = #Exif_DT_Digitized
currLoc = Loc(0)
FileSeek(0, Loc(0) + 6)
datLoc = ReadLong(0)
FileSeek(0, datLoc + #Header)
exifDate$(#DigitizedDate) = ReadString(0)
allDate$ + #CRLF$ + "Digitized:" + #TAB$ + exifDate$(#DigitizedDate)
FileSeek(0, currLoc + 10)
EndIf
If tag <> #Exif_DT_Taken And tag <> #Exif_DT_Digitized
FileSeek(0, Loc(0) + 10)
EndIf
Until tag = 0
Default
; --> Move to next field. Each field is 12 bytes.
; --> currentTag (2 bytes) is current Loc() so we add 10
FileSeek(0, Loc(0)+10)
EndSelect
Next i
Else
MessageRequester("Error", "Invalid file format!")
EndIf
Else
MessageRequester("Sorry", "Invalid file format!")
EndIf
CloseFile(0)
ProcedureReturn allDate$
EndProcedure
If OpenWindow(0, 10, 10, 300, 200, "Exif Date/Time", #PB_Window_SystemMenu)
ButtonGadget(0, 10, 10, 280, 20, "Open JPG for Exif info")
Repeat
event = WaitWindowEvent()
If event = #PB_Event_Gadget
Select EventGadget()
Case 0
fileOpen$ = (OpenFileRequester("Select JPEG", "C:\Documents and Settings\Owner\My Documents\My Pictures\", "JPG files (JPG)|*.jpg;*.jpeg", 0))
If fileOpen$
dt$ = GetExifDateTime(fileOpen$, 0, "")
MessageRequester("Exif Info", dt$)
EndIf
EndSelect
EndIf
Until event = #PB_Event_CloseWindow
EndIf
End
PS: Anpassen an neue Version dauert im allg. nur wenige Minuten und sollte von Dir zu
bewältigen sein!
Bei CallFunction... wo ein Integer statt String erwartet wird, reicht es ein @ vor den String zu stellen, usw.
Den Rest machste jetzt wohl alleine.
Gruß
Thomas