Converting TIFF files to PNG in .Net

那年仲夏 提交于 2019-11-27 01:25:20

问题


I have to build an application in .Net (3.5) to pick up a TIFF file saved from another piece of software and convert it into a PNG so that it can be rendered easily in Internet Explorer. Does anyone know of any libraries (preferably freeware/open source) that will do this conversion for me?

If there aren't any simple ways of getting it to a PNG are there any libraries that I can use to transform it to another IE friendly image format?

I know I can pass a TIFF to the browser and use a plugin to render it but the PCs this is aimed at are locked down and can't install plugins.


回答1:


System.Drawing.
    Bitmap.FromFile("your image.tif")
              .Save("your image.png", System.Drawing.Imaging.ImageFormat.Png);

Please, also check this: Convert Tiff Images to Gif/Jpeg




回答2:


In C# / .NET, it is probably as easy as:

using System.Drawing;
using System.Drawing.Imaging;

using (var tiff = new Bitmap("my_tiff_file.tif")) {
    tiff.Save("output.jpg", ImageFormat.Jpeg);
}

If for some reason System.Drawing.Imaging won't read your TIFF files, check out an open-source project called ImageMagick, which will read and write just about any image format imaginable. Worst case scenario you'll need to call ImageMagick's convert.exe via Process.Start() in .NET - not elegant, but it does work.



来源:https://stackoverflow.com/questions/1566188/converting-tiff-files-to-png-in-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!