Philip Mallis

How to export Flickr photos with metadata attached

I have been a user of Flickr for about eight years. While I have no plans to move away, there are many reasons why someone would want to export their photos and videos.

Having spent many hours reading through forum posts, documentation and Github repositories, I want to share my method of how I achieved this. It wasn’t easy.

If you want to skip the backstory and go straight to the method, click here.

Parameters

What I needed was a download of all of my Flickr content with the metadata attached.

The issue is that Flickr only allows you to export photos with the data attached from before it was uploaded. So if you were like me, and did at least some editing within Flickr itself, none of this would be attached to the files.

The only thing to do is to either request a data export of all Flickr content, where all of this would be contained in separate .json files, or use a third-party provider.

This also assumes that you are only downloading your own Flickr content and not someone else’s.

What I tried

Eventually I finally figured out that since 2020, Flickr have added additional numbers to file names. As a result, the [8] in the command that captures the image ID number in Step 6 below should now be an [11]. And that’s what finally made it work!

Method that works

This works on Linux but should also work on Windows with the necessary tweaks.

Before you start, install:

Then follow these steps:

  1. Navigate to Flickr account settings page to download your entire Flickr archive
  2. Use Downthemall (right-click) and filter by .zip files to download all of the files into the folder of your choice
  3. Extract all of the archives into a single folder (right-click and go ‘extract’ in 7Zip or whatever)
  4. Run this command in your command prompt/console: exiftool -s file.json (change [file.json] to the path to any photo file in that folder)
  5. Read the output and select which tags you want to extract. Then match these tags to whichever items you want to attach the image to on this list of supported EXIF metadata: https://exiv2.org/tags.html
  6. Run this command in your command prompt/console: exiftool -AddTagsFromFile %dphoto_%-11.2f.json "-keywords<AlbumsTitle" "-ImageDescription<Title" "-gpslatitude<GeoLatitude" "-gpslongitude<GeoLongitude" "-name<Name" "-keywords<TagsTag" "-ProfileCopyright<License" <fullfilepath> (note that all of the items in double quotation marks are examples only, you should change these to the tags that you want as outlined in Step 5 – the first name being what is listed in the exiv2.org link earlier, the second being what the output shows in Step 4. Also change <fullfilepath> to the path shown when you drag and drop a file into the terminal, for some reason relative paths weren’t working for me.)
  7. Execute the command.
  8. Once this is completed, check one of the new image files by running exiftool -s again on one of them to see that it has everything you need.
  9. If you are like me, you ended up with a second copy of these files. To get rid of these, run <COMMAND>
  10. Open your photos in the photo editor/organiser of your choice (I use and recommend Digikam).

Congratulations, that should be all!

Once that’s done, you may want to sort them. Exiftool has a lot of different ways to do this. One of the most common is organising by date and time. If you are interested in doing this, I found this page to be the most helpful: https://exiftool.org/filename.html

Many thanks to the many people who created resources previously to explain this. For further reading and information, please go to these places:

Comments

One response to “How to export Flickr photos with metadata attached”

  1. William Whyte Avatar
    William Whyte

    Thanks very much for this, Philip, this was a big help for me trying to carry out the same process.

    A couple of notes that might help others:

    The json files didn’t give longitude and latitude in degrees, but in millionths of a degree. The numbers needed to be divided by a million to give the right value. Fortunately, this was just a matter of adding a decimal point character to the relevant lines — no actual math was required. I did this using the following perl command-line command:

    perl -pi.bak -e ‘s/(“(longitude|latitude)”: “.)(\d{6})/\1.\3/’ photo_.json

    (i.e. on any line that contains “longitude” or “latitude”, find the last run of 6 decimal digits on that line and put a “.” in front of them).

    Just so that the syntax of this command is clear with respect to the filenames:

    AddTagsFromFile %dphoto_%-11.2f.json …

    What this means is: “for each file that’s found by fullfilepath, find the corresponding tags in the same directory (that’s what the %d means) in a file whose name is photo_[id_number_of_photo_file].json, where you get id_number_of_photo_file by taking the last 11 characters of the photo file name (that’s what the %-11f means) and cutting off the last two characters, which are always “_o” (that’s what the %-.2f means)”

    This command is tailored for photo files with a 9-digit photo identifier number. However, when I did the download, the number was sometimes 9 digits and sometimes 10. This means that if you used “%-11.2f” you’d cut off the first digit of a 10-digit identifier, and if you used “%-12.2f” to get the whole 10-digit identifier, then if the ID was 9 digits you’d pull in the leading “_” which doesn’t appear in the JSON file name. So in either case, there isn’t a single command that I could see that would work on both the 9-digit and the 10-digit files.

    I got around this by using a shell script to rename all the photo files so the name consisted just of the 9- or 10-digit ID. (I did ls *.jpg, put the output into a file, and then used a regular expression in VI to convert each “xxx_id_o.jpg” line to “mv xxx_id_o.jpg id.jpg”, then ran the file as a shell script).

    With the filenames in this format, the command

    AddTagsFromFile photo_%f.json … *.jpg

    worked for all files.

    For some JSON files, the command above didn’t completely work, because it doesn’t import the GPS “reference direction”, which is needed as well as the GPS value. I asked on Reddit about this (https://www.reddit.com/r/googlephotos/comments/1hugukz/geographic_location_data_not_showing_up/) and was told to use

    “-gpslatitude<GeoLatitude” “-gpslongitude<GeoLongitude”

    i.e. with a “*<” rather than just a “<“. This sets the reference direction correctly.

    Finally, some very old photos didn’t even have a creation date in the jpeg, although they did have a date in the JSON. I was able to pull that date from the JSON and put it in the JPEG using

    “-DateTime<date_taken”

    So my final command line process was:

    rename the files as noted above and fix the longitude/latitude units with the perl script
    Then run: exiftool -AddTagsFromFile photo_%f.json “-keywords<AlbumsTitle” “-ImageDescription<Title” “-gpslatitude<GeoLatitude” “-gpslongitude<GeoLongitude” “-name<Name” “-keywords<TagsTag” “-ProfileCopyright<License” “-DateTime<date_taken” *.jpg

    Hope this helps anyone who finds this page but had the problems I did.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.