views:

473

answers:

3

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.

+7  A: 
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

Rubens Farias
Thanks for this it worked first time, you've saved me ages of messing about.
colethecoder
A: 

Check out the PngBitmapEncoder and the TiffBitmapDecoder

Daniel Enetoft
+3  A: 

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.

Dylan Beattie