通用Windows平台C#上的Exif标记 [英] Exif tags on universal Windows Platform C#

查看:129
本文介绍了通用Windows平台C#上的Exif标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在UWP(通用Windows平台)/Windows Phone 10上的jpeg图片中添加标签. WindowsBase和PresentationCore不可用.

How do I add Tags to a jpeg picture on UWP (universal Windows Platform) / Windows Phone 10. WindowsBase and PresentationCore not available.

推荐答案

以下是有关如何在Windows运行时中将Artist exif标记写入jpeg图像的示例.

Here is an example about how to write the Artist exif tag to a jpeg image in Windows Runtime.

您可以在此网页中找到所有的EXIF标签ID:

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

这篇关于通用Windows平台C#上的Exif标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆