修改照片中的extra info

2018-06-13  本文已影响0人  InnoTech

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();

}

上一篇 下一篇

猜你喜欢

热点阅读