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

查看:31
本文介绍了通用 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天全站免登陆