美文网首页
修改照片中的extra info

修改照片中的extra info

作者: InnoTech | 来源:发表于2018-06-13 10:47 被阅读0次

https://dejanstojanovic.net/aspnet/2014/november/adding-extra-info-to-an-image-file/

https://stackoverflow.com/questions/32066893/changing-datetaken-of-a-photo?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa


private static void SetDateToken(FileInfo fileInfo, DateTime date, string path)

{

    Image theImage = new Bitmap(fileInfo.FullName);

    PropertyItem[] propItems = theImage.PropertyItems;

    Encoding _Encoding = Encoding.UTF8;

    var property = propItems[0];

    property.Id = 0x9003;

    property.Value = Encoding.UTF8.GetBytes(date.ToString("yyyy:MM:dd HH:mm:ss") + '\0');

    property.Len = property.Value.Length - 1;

    property.Type = 2;

    theImage.SetPropertyItem(property);

    property.Id = 0x9004;

    property.Value = Encoding.UTF8.GetBytes(date.ToString("yyyy:MM:dd HH:mm:ss") + '\0');

    property.Len = property.Value.Length - 1;

    property.Type = 2;

    theImage.SetPropertyItem(property);

    theImage.Save(path + "\\" + fileInfo.Name, theImage.RawFormat);

    theImage.Dispose();

}

相关文章

网友评论

      本文标题:修改照片中的extra info

      本文链接:https://www.haomeiwen.com/subject/bbxjeftx.html