Exif tags on universal Windows Platform C#

佐手、 提交于 2020-01-06 01:35:07

问题


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


来源:https://stackoverflow.com/questions/33088196/exif-tags-on-universal-windows-platform-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!