How to Add 'Comments' to a JPEG File Using C#

后端 未结 6 1317
眼角桃花
眼角桃花 2020-11-27 17:59

Within the property window of a JPEG image, there is a tab called \'Summary\'. Within this tab, there is a field called \'Comments\' I would like to write some c# code which

6条回答
  •  醉酒成梦
    2020-11-27 18:37

    The easy part:

    Add this property item:

    var data = System.Text.Encoding.UTF8.GetBytes( "Some comments" );
    PropertyItem pi;
    *** create an empty PropertyItem here
    pi.Type = 2;
    pi.Id = 37510;
    pi.Len = data.Length;
    pi.Value = data;
    

    To the Image's PropertItems collection.

    The somewhat more cumbersome part: How do you create a new PropertyItem, since it has no public constructor?

    The common "trick" is to have an empty image lying around from which you can steal a PropertyItem. sigh

提交回复
热议问题