我发现了一个 GitHub 问题,展示了如何通过将图像的 ExifProfile 设置为空来删除图像的 exif 数据:
SixLabors.ImageSharp.Image image = Image.Load(imagePath);
//remove exif
image.Metadata.ExifProfile = null;
//resize
image.Mutate(x => x.Resize(width, height));
//save
SixLabors.ImageSharp.Formats.Jpeg.JpegEncoder encoder = new SixLabors.ImageSharp.Formats.Jpeg.JpegEncoder();
encoder.Quality = 30;
image.Save(thumbnailPath, encoder);
...但它似乎对我不起作用——保存的 jpeg 大小相同,当我的操作系统检查时,它们会向我显示相机的所有 EXIF 设置。当我对从另一个实用程序创建的图像进行同样的检查时,操作系统没有向我显示所有 EXIF 设置...所以我倾向于说这种 ImageSharp 技术没有正确清理它们。
有什么想法吗?
最佳答案
原来有两种不同类型的元数据 - EXIF 和 XMP。有必要将两个对象都设置为 null 以将它们全部删除:
image.Metadata.ExifProfile = null;
image.Metadata.XmpProfile = null;
关于.net-core - 如何使用 ImageSharp 清除图像的 EXIF 数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71095620/