How to export image metadata?
Take a look at Titanium Backup, it will backup all the data saved in the Contacts app and Gallery app and you can either transfer it to a new phone, or extract the sql-lite db's contained in the backup and (hopefully) get your data into a spreadsheet or something. (as mentioned here)

An alternative method (without root) is to use the adb backup command. Since you're restoring your phone you might want to just adb backup -all -apk -system -shared and that will get everything. For just the data you want you can instead use -all -noapk -system -shared and it will be faster, but no apks. You can easily unzip the backup and locate your /data/Gallery.apk or Contacts.apk and unzip those to find a sql-lite database (or many). You can either extract the database or transfer the whole /data/Gallery.apk to your restored device.

Hope this helps