Got further on extracting the metadata and writing out new image.