Hi Marcel and Alexey,
Thank you for your answers and sorry for the delay in responding.
I tried the suggested solution of changing metadata to camera.photo.meta, but unfortunately it still doesn't trigger the path changes to be saved.
Here's a minimal reproducible example:
import Metashape
import os
import time
# Create a project and add photos
project_file = '/path/to/test_project.psx'
images_path = "/path/to/images"
doc = Metashape.Document()
Metashape.app.settings.project_absolute_paths = True
chunk = doc.addChunk()
# Add some photos (adjust path pattern as needed)
photo_files = [os.path.join(images_path, f) for f in os.listdir(images_path) if f.endswith(('.jpg', '.JPG', '.tif', '.TIF'))]
chunk.addPhotos(photo_files[:5]) # Just add a few for testing
# Save the project initially
doc.save(project_file)
print(f"Initial path: {chunk.cameras[0].photo.path}")
# Initial path: /mnt/nfs/labo/.../.JPG
# Now modify the photo paths
for camera in chunk.cameras:
old_path = camera.photo.path
# Change from Linux mount to UNC path (or any other modification)
new_path = old_path.replace("/mnt/nfs/labo/", "//labo/")
camera.photo.path = new_path
# Try changing metadata as suggested
camera.photo.meta["PathModifyDate"] = time.ctime()
print(f"Modified path (before save): {chunk.cameras[0].photo.path}")
# Modified path (before save): //labo/.../.JPG
# Save with doc.save() - this doesn't persist the path changes
doc.save()
# Reload the project to verify
doc.open(project_file)
print(f"Path after reload: {doc.chunk.cameras[0].photo.path}")
# Expected: The modified path (//labo/...)
# Actual: The original path (/mnt/nfs/labo/...)
# Compare with doc.save(new_path) which work:
# Modify the photo paths again
for camera in doc.chunk.cameras:
old_path = camera.photo.path
# Change from Linux mount to UNC path (or any other modification)
new_path = old_path.replace("/mnt/nfs/labo/", "//labo/")
camera.photo.path = new_path
new_project_file = '/path/to/test_project_v2.psx'
doc.save(new_project_file) # This correctly saves the modified paths
doc.open(new_project_file)
print(f"Path in new project file: {doc.chunk.cameras[0].photo.path}")
# This shows the updated paths (//labo/...)
Best,
Antoine