I\'m trying to set the metadata of an image on exit from a resize, the property appears to be set but after the save nothing is there.
I\'m pretty sure I\'m doing so
Well, after some tests, this works... But only if property 40091 doesn't exist in the original Image. If it exists, it's not replaced (must admit I don't know why).
var image = Image.FromFile(@"C:\Tools\test.jpg");
var propertyItem = createPropertyItem();
var text = "awe" + char.MinValue;//add \0 at the end of your string
propertyItem = createPropertyItem();
propertyItem.Id = 40091;
propertyItem.Value = Encoding.Unicode.GetBytes(text);//change to Unicode
propertyItem.Len = propertyItem.Value.Length;
propertyItem.Type = 1;//it's not type 2 !
image.SetPropertyItem(propertyItem);
image.Save(@"C:\Tools\test2.jpg");