How do I add Tags to a jpeg picture on UWP (universal Windows Platform) / Windows Phone 10. WindowsBase and PresentationCore not available.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Here is an example about how to write the Artist exif tag to a jpeg image in Windows Runtime.
You can find all of the EXIF tag ids in this web page:
http://www.exiv2.org/tags.html
var src = await KnownFolders
.PicturesLibrary
.GetFileAsync("210644575939381015.jpg");
using (var stream = await src.OpenAsync(FileAccessMode.ReadWrite))
{
var decoder = await BitmapDecoder.CreateAsync(stream);
var encoder = await BitmapEncoder.CreateForTranscodingAsync(stream, decoder);
// var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, stream);
var list = new List<KeyValuePair<string, BitmapTypedValue>>();
var artist = new BitmapTypedValue("Hello World", Windows.Foundation.PropertyType.String);
list.Add(new KeyValuePair<string, BitmapTypedValue>("/app1/ifd/exif/{ushort=315}", artist));
await encoder.BitmapProperties.SetPropertiesAsync(list);
await encoder.FlushAsync();
await stream.FlushAsync();
}