How to add GPS to WEBP or AVIF files
Posted: Wed Sep 13, 2023 8:55 pm
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
4) I run a script written in Python that copies the EXIF information from the original JPG files to the new AVIF
I can add any details if you need them.
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
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
- you need to have the xmpMetadata plugin enabled and the extension (AVIF) enabled in its settings
I can add any details if you need them.