Platforms to show: All Mac Windows Linux Cross-Platform

/Images/Exif Tags


Required plugins for this example: MBS Images Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Images/Exif Tags

This example is the version from Sat, 10th Apr 2020.

Project "Exif Tags.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub NewDocument() // let user pick a file Dim f As FolderItem = GetOpenFolderItem(FileTypes1.Jpeg) If f <> Nil Then OpenDocument f End If End EventHandler
EventHandler Sub OpenDocument(item As FolderItem) // open jpeg file and look for EXIF Dim j As New JPEGImporterMBS j.ReadExifData = True j.File = item j.mode = j.ModeAuto If j.ReadHeader Then // read header only // do we have exif data Dim ExifData As String = j.ExifData If ExifData.Len = 0 Then MsgBox "No EXIF data in the file "+item.DisplayName+"." else Dim exif As New ExifTagsMBS(ExifData) Dim w As New ExifWindow w.ShowExif exif, item.DisplayName end if Else MsgBox "Failed to read file: "+j.ErrorMessage End If End EventHandler
End Class
Class ExifWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Function GetFormatName(tag as integer) As string Select Case tag Case ExifTagMBS.kFormatInvalid return "Invalid" Case ExifTagMBS.kFormatByte return "Byte" Case ExifTagMBS.kFormatString return "String" Case ExifTagMBS.kFormatUShort return "UShort" Case ExifTagMBS.kFormatULong return "ULong" Case ExifTagMBS.kFormatURational return "URational" Case ExifTagMBS.kFormatSByte return "SByte" Case ExifTagMBS.kFormatUndefined return "Undefined" Case ExifTagMBS.kFormatSShort return "SShort" Case ExifTagMBS.kFormatSLong return "SLong" Case ExifTagMBS.kFormatSRational return "SRational" Case ExifTagMBS.kFormatSingle return "Single" Case ExifTagMBS.kFormatDouble return "Double" Else Break return "?" End Select End Function
Sub ShowExif(e as ExifTagsMBS, t as string) Title = t exif = e // show tags in memory Dim tags() As ExifTagMBS = e.Tags For Each tag As ExifTagMBS In tags Dim type As String = GetFormatName(tag.Format) If tag.Components <> 1 Then type = type + "["+Str(tag.Components)+"]" End If List.AddRow Str(tag.Tag)+" "+tag.TagName, tag.StringValue, type Next If False Then // change it Dim DateTimeTag As ExifTagMBS = exif.DateTime Dim OldDateTime As String = DateTimeTag.Value exif.DateTime.Value = "2020:03:31 16:17:18" Dim data As MemoryBlock = exif.Data // let it parse again exif = New ExifTagsMBS(data) tags = exif.Tags For Each tag As ExifTagMBS In tags Dim type As String = GetFormatName(tag.Format) If tag.Components <> 1 Then type = type + "["+Str(tag.Components)+"]" End If List.AddRow Str(tag.Tag)+" "+tag.TagName, tag.StringValue, type Next // or write it back to a file End If End Sub
Property exif As ExifTagsMBS
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
FileTypes1
Filetype image/jpeg
End FileTypes1
End Project

The items on this page are in the following plugins: MBS Images Plugin.


The biggest plugin in space...