Preserving 360 metadata when using Python scripts

I’m using Python and Pillow to remove the tripod from many 360 shots, but saving the new images does not transfer the 360 metadata. Does anyone know how to preserve or recreate the data so image viewers and social media platforms recognize the pictures as spherical? Thanks for the information.

You can inspect the metadata with this tool.

This article provides a basic overview of the metadata

Did you try this?