Platforms to show: All Mac Windows Linux Cross-Platform
Required plugins for this example: MBS Main Plugin, MBS XMP Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /XMP/Create EXIF
This example is the version from Fri, 27th Mar 2014.
Project "Create EXIF.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
EventHandler Sub Open()
dim pic as Picture = LogoMBS(500)
dim file as FolderItem = SpecialFolder.Desktop.Child("test.jpg")
pic.Save(file, pic.SaveAsJPEG, 80)
// use XMPFilesMBS to open file
dim flags as integer = XMPFilesMBS.kOpenForUpdate
dim xf as new XMPFilesMBS(file, XMPFilesMBS.kUnknownFile, flags)
// now read the metadata
dim xmp as new XMPMetaMBS
dim PacketInfo as XMPPacketInfoMBS
dim xmppacket as string
if xf.GetXMP(xmp, xmppacket, PacketInfo) then
// and dump to test file
dim outputfile as FolderItem = SpecialFolder.Desktop.Child("before.txt")
dim output as new MyXMPTextOutputMBS(outputfile)
call xmp.DumpObject(output)
// here we add EXIF version:
xmp.SetProperty xmp.kNS_EXIF, "ExifVersion", "0221"
// here we add EXIF texts
xmp.SetProperty xmp.kNS_TIFF, "Make", "Test Make"
xmp.SetProperty xmp.kNS_TIFF, "Model", "Test Model"
xmp.SetLocalizedText ( xmp.kNS_DC, "description", "", "x-default", "Test Image Description" )
// here we add EXIF GPS coordinates:
xmp.SetProperty xmp.kNS_EXIF, "GPSAltitudeRef", "0"
xmp.SetProperty xmp.kNS_EXIF, "GPSAltitude", "26696/43"
xmp.SetProperty xmp.kNS_EXIF, "GPSImgDirectionRef", "T"
xmp.SetProperty xmp.kNS_EXIF, "GPSImgDirection", "74843/234"
xmp.SetProperty xmp.kNS_EXIF, "GPSLatitude", "36,6.47N"
xmp.SetProperty xmp.kNS_EXIF, "GPSLongitude", "115,9.13W"
xmp.SetProperty xmp.kNS_EXIF, "GPSTimeStamp", "2014-03-25T16:09:46Z"
// and dump to test file
outputfile = SpecialFolder.Desktop.Child("after.txt")
output = new MyXMPTextOutputMBS(outputfile)
call xmp.DumpObject(output)
// update file
if xf.CanPutXMP(xmp) then
xf.PutXMP(xmp)
xf.CloseFile(XMPFilesMBS.kUpdateSafely)
else
MsgBox "Can't update."
end if
end if
End EventHandler
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Class MyXMPTextOutputMBS Inherits XMPTextOutputMBS
EventHandler Function Output(text as string) As integer
TextStream.Write text
Return 0 // OK
End EventHandler
Sub Constructor(file as FolderItem)
self.file = file
self.TextStream = TextOutputStream.Create(file)
End Sub
Property TextStream As TextOutputStream
Property file As FolderItem
End Class
End Project
See also:
The items on this page are in the following plugins: MBS XMP Plugin.