Page 1 of 1

How to add GPS to WEBP or AVIF files

Posted: Wed Sep 13, 2023 8:55 pm
by Mates-K1
Following this issue https://github.com/netPhotoGraphics/net ... ssues/1469, I would like to share my solution for the "problem" where the GPS coordinates are not displayed in the nPG for WEBP and AVIF files.

There are very few oflline and online converters that include other metadata - typically GPS coordinates - in the mentioned photos. So I solve the situation:

1) I have an original JPG to which I add GPS coordinates (or it has it already).
2) I convert the JPG to AVIF
  • I use XnConverter for Windows
  • I need to choose a chroma subsampling of at least 4:4:2
3) I put both file types in one directory
4) I run a script written in Python that copies the EXIF information from the original JPG files to the new AVIF

Code: Select all

import os
import subprocess

folder = "images"

for file in os.listdir(folder):
    if file.endswith(".jpg"):
        source_img = os.path.join(folder, file)
        target_img = os.path.join(folder, file.replace(".jpg", ".avif"))

        try:
            subprocess.run(["exiftool", "-tagsfromfile", source_img, "-all:all", "-ext", "avif", "-overwrite_original", target_img])
        except Exception as e:
            print(f"Error: {e}")

  • I need to have ExifTool by Phil Harvey downloaded in PC
5) Via FTP (but I guess it doesn't matter) I upload the photos to the nPG
  • you need to have the xmpMetadata plugin enabled and the extension (AVIF) enabled in its settings
6) done, there is a satellite symbol in the thumbnails = the photo has GPS coordinates and its location is shown on the map.

I can add any details if you need them.