Hello,
You could try the following code to copy the metadata to a new photo.
if (retrievedProps.ContainsKey("System.ApplicationName"))
{
Bitmap theImage = new Bitmap(path);
var programName = (string)retrievedProps["System.ApplicationName"];
Encoding _Encoding = Encoding.UTF8;
PropertyItem[] propItems = theImage.PropertyItems;
var DataTakenProperty = propItems.Where(a => a.Id.ToString("x") == "9004").FirstOrDefault();
var programNamenProperty = propItems.Where(a => a.Id.ToString("x") == "9003").FirstOrDefault();
DataTakenProperty.Value = _Encoding.GetBytes(dateTaken.ToString());
programNamenProperty.Value = _Encoding.GetBytes(programName);
theImage.SetPropertyItem(programNamenProperty);
theImage.SetPropertyItem(DataTakenProperty);
theImage.Save(path);
theImage.Dispose();
}
In addition, you could also use the Image class to get/set
the EXIF information for your file.
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.