I’d like to talk about the BOM in the room.
In the course of working with image metadata via both Directory Opus and ExifTool, it’s become apparent that some EXIF fields written by DOpus contain a BOM (UTF byte order mark, or zero-width non-breaking space, U+FEFF / 0xEF,0xBB,0xBF) as the first character. As far as I have seen so far, this BOM does not get included in the respective field value string when displaying/editing metadata via DOpus’ Metadata Pane or Set Metadata dialog, but can be found in JSON data exported from image files by ExifTool:
Under normal circumstances, this BOM probably doesn’t bother anybody else, and it mostly didn’t bother me, either, until my recent efforts to automate a number of routine (for me) metadata operations that I had previously performed manually. For example, I’m often enough prepending and/or appending new strings to existing metadata fields such as Description, Subject, Title and Comment. I’m using ExifTool to do these, via custom DOpus commands like this:
@set descprfx={dlgstring|Enter string to prepend to Description}$
ExifTool "-EXIF:ImageDescription<{$descprfx}EXIF:ImageDescription" .
As written above, this command results in BOM ending up between the new and existing strings, which often causes problems for me later on. I’ve now managed to amend my command line to remove the BOM, if there is one, during the prepend operation:
ExifTool "-EXIF:ImageDescription<{$descprfx}{EXIF:ImageDescription;m/^(?:\xEF\xBB\xBF)?(.*)/; $_=$1}" .
Post-BOM removal, there seems to be no adverse effects on the display/editability of the Description field in the Metadata Pane or Set Metadata dialog. Is the BOM actually necessary? Can a future update to DOpus’ metadata capabilities maybe do away with it? I’m not absolutely sure, but I think there are other metadata fields written by DOpus which do not contain a BOM. I assume the code for dealing with metadata is not strictly DOpus’, but the support library I see looks to me like it’s a customized version of Exiv, credited to GPSoftware, and not updated since 2014.
On the other hand, if the BOM does serve some purpose for DOpus that’s eluding me, am I potentially setting myself up for other complications down the road by removing it? I’m sure I could easily revise my code to restore it to the beginning of the prepended string, but would rather just leave it out if all else is equal.
Contents:
“DOpus_Meta_BOM\”
“2020-09-12 08;56;35 - MAZE - DOpus Meta BOM.png” (57,940) [800 x 340 x 24]
“DOpus_Meta_BOM.png” (4,191) [1 x 1 x 1]
“DOpus_Meta_BOM.png.json” (1,582)
“DOpus_Meta_BOM.png.txt” (370)
“DOpus_Meta_BOM_Original.png” (4,049) [1 x 1 x 1]
“DOpus_Meta_BOM_Original.png.json” (1,441)