User:Slaunger/Mitigating Mediawiki Metadata Viewer Bug

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Mitigating Mediawiki Metadata Viewer Bug when Exporting from Lightroom ver. 6.x

[edit]

The problem

[edit]

When Lightroom ver. 6.x (out-of-the box with no plugins installed) is used to export as jpg, and the exported files are and uploaded to Wikimedia Commons, the mediawiki metadata viewer shows selected fields with corrupted or swapped data. The problem is due to a bug in php's exif support used in the Mediawiki software. It is triggered in files where the values for the exif tags come before the list of tags contained in the file. This seems to be the case in Lightroom 6.0, which was released on April 21, 2015 and also in the subsequent minor release of ver. 6.1 from June 15, 2015.

I first noticed the problem in the initial version of File:Sarcophagus of Louise of Great Britain, Roskilde Cathedral, Denmark, 2015-03-31-4813.jpg, which was uploaded on April 23 after upgrading to Lightroom 6.0 via a subscription service for Lightroom. The bug has apparently been known for five years, but has not been an actual problem until the emergence of Lightroom 6.0 in April 2015.

At the time of this writing it is not known (to me at least) when this bug will be fixed in Mediawiki and whether fixing the bug will automatically correct all existing problems with viewing the metadata correctly for files exported from Lightroom ver. 6.x.

Until then, there are two ways that I know of to mitigate that the list of tags comes before the values in the block of exif data, as expected by the current Mediawiki implementation.

Mitigation using exiftool

[edit]

Creating a batch script on windows

[edit]

The following describes a method I have used on my Windows 7 PC

1. Download ExifTool by Phil Harvey as a zipped executable for Windows.

2. Unzip it to a suitable location. In the following, it is assumed the zip file is unzipped into a C:\Tools\ folder, and that we are using exiftool ver. 9.98.

3. After unzipping, you have an executable file C:\Tools\exiftool-9.98\exiftool(-k).exe

4. In the file explorer, select the executable file, press F2 and rename it to exiftool.exe

5. Open a text editor, e.g. NotePad, and copy the following into a new file

C:\Tools\exiftool-9.98\exiftool.exe -TagsFromFile %1 -exif:all temp.mie
C:\Tools\exiftool-9.98\exiftool.exe %1 -exif:all=
C:\Tools\exiftool-9.98\exiftool.exe -TagsFromFile temp.mie -exif:all %1

6. Save the file as, e.g., mwfixexif.bat on your desktop. It is important that you choose 'All files *.*' instead of 'Text files *.txt' in the file type drop down box.

Using the exiftool batch script to fix previous uploads

[edit]

1. From a file explorer drag and drop individual jpg files which has this problem onto the batch file icon on your desktop.

2. After running the script, the original "some file name".jpg is replaced by a new file of the same name, with EXIF data, which can be formatted correctly in the mediawiki metadata viewer. The original file is kept as "some file name".jpg_original in the same folder. A temporary file temp.mie is also created.

3. Upload "some file name".jpg as a new version of the existing file.

4. Check that the Exif data are displayed as intended in the mediawiki metadata view on the file page

I have used this procedure with success on about 50 uploads, which had been originally exported from either Lightroom 6.0 or 6.1. The batch script could easily be extended to also clean up temporary files made in the process. However, I have found it useful to keep them, as the initial version of the script above contained an error. Since the original jpegs were still there as .jpg_original it was easy to rename those and run the corrected script again.

Mitigation using Jeffrey Friedl's Metadata Wrangler Lightroom Plugin

[edit]

I personally find it annoying the have to use the exiftool script as part of the postprocessing work prior to upload. Colin noted that he had no such problems using the same version of Lightroom, but he also used a metadata plugin for Lightroom called the Jeffrey’s “Metadata Wrangler” Lightroom Plugin. This can be installed for free during a trial period whereafter you need to register and pay an arbitrary price from 1 cent and up to get a permanent license (I gave $5). If the metadata wrangler is enabled during export, the exif data are encoded in a manner, which can be decoded by the mediawiki metadata viewer. Since I have installed this plugin, I have not had to use the exiftool script on new Lightroom exports. I have some problems though with a co-existance of the metadata wrangler plugin and Jeffrey’s “Creative Commons” Lightroom Plugin. Currently, I have disabled the latter and just filled in the fields myself in the metadata preset used during import.

Colin: I have filed a bug-report with Jeffrey Friedl about the Creative Commons plugin. As a work-around, running Lightroom as an administrator helps fix that issue.

References

[edit]