如何修改/添加元数据到 System.Drawing.Image 文件

发布于 2024-10-01 04:52:40 字数 564 浏览 2 评论 0原文

商业目的:我正在创建一个 CMS,并允许用户“删除”他们之前上传到服务器的图像。

问题:如果我允许他们真正删除图像,他们会留下用现在损坏的图像创建的旧帖子。示例:用户上传 vtWinsACC2005.jpg,写了一篇关于它的文章链接到该图像,然后最终清理了他的画廊并删除了该图像,但保留了该文章,最终得到了一篇图像损坏的文章。

目标:当用户“删除”他们之前上传的图像时,我想向 IO 中的实际文件添加一个“注释”字段或任何类型的元数据,例如, “hidden=true”,在我的 GetFiles() 逻辑中,我将检查以确保该元数据不存在。这样,用户就看不到他们已删除的图像,甚至可以在将来“恢复”他们不想删除的图像。当它们恢复时,我可以简单地擦除该文件中的元数据,仅此而已。

替代:在数据库中使用 userId + fileName 保留一个简单的查找表,并将其命名为“HiddenUserImage”,但是,上面的方法更有趣,如果我不必添加另一个表,那太好了!

有什么想法吗?这将在 C# 中进行。谢谢!

Business purpose: I'm creating a CMS, and allowing the user to "delete" images that they've previously uploaded to the server.

Issue: if I allow them to really delete the images, they are left with old posts they've created with now-broken images. Example: user uploads vtWinsACC2005.jpg, writes an article about it linking to the image, then finally cleans up his gallery and deletes that image, but leaves the article alone, ending up with an article with a broken image.

Goal: when a user "deletes" an image they've previously uploaded, I want to add a "note" field, or any type of meta data to the actual file in IO, with something like, "hidden=true," and in my GetFiles() logic, I'll check to make sure that that metadata does not exist. This way, the user doesn't see the images they've deleted, and they could even "restore" images in the future that they did not mean to delete. When they restore, I can simply wipe the metadata from that file, and that's it.

Alternative: keep a simple lookup table in the database with userId + fileName, and call it "HiddenUserImage," but, the above way is more fun, and if I don't have to add another table, then great!

Any ideas?? This will be in C#. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

野侃 2024-10-08 04:52:40

我认为您可以为每个图像创建一个 NTFS 备用数据流,这是一个映射到图像文件的隐藏 ADS 文件,并在其中存储 hide=true 属性。

I think you can create for each image a NTFS Alternate Data Stream, a hidden ADS file that is mapped to your image file and store there the hidden=true property.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文