使用 .Net 替换现有多页 Tiff 中的图像
使用 .Net 如何用新图像替换多页 tiff 文件的第一页。最好不创建新文件。
Using .Net how do I replace the first page of a multiple page tiff file with a new image. Preferable without create a new file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为如果不创建另一个文件你就无法做到这一点。
您可以先读取所有图像,替换要替换的图像,关闭原始源,然后用新的多页 TIFF 替换文件,但我相信这会占用大量内存。我会一次读取一个图像,并将其写入一个新文件,最后一步,更改文件名。
比如:
希望有帮助。对于 .NET 成像方面的问题,Bob Powell页面有很多好东西。
I think you could not do it without creating another file.
You could read all the images first, replace the image you want to replace, close the original source, and then replace the file with the new multi-page TIFF, but I believe it will use a lot of memory. I would read an image at a time, and write it to a new file and, as the last step, change the file names.
Something like:
Hope it helps. For questions in .NET imaging, the Bob Powell page has a lot of good stuff.
这很容易做到。 CodeProject 教程页面上有源代码,可以帮助您执行以下操作你想要的。
本质上,您需要调用 Image .GetFrameCount() 将为您提供多页 TIFF 中的图像数量(只是为了确认您确实拥有多页 TIFF)。
您可能需要尝试如何保存生成的 TIFF - 您可能需要手动重新组装 TIFF,或者您可以在将 TIFF 写回磁盘之前直接编辑/替换图像。
This is fairly easy to do. There's source code on this CodeProject tutorial page that will help you do what you want.
Essentially, you'll need to make a call to Image.GetFrameCount() which will give you the number of images in your multi-page TIFF (just to confirm that you actually have a multi-page TIFF).
You might need to experiment with how you save your resulting TIFF - you may need to reassemble the TIFF manually, or you might be able to edit/replace the image directly before writing the TIFF back to disk.