C# Tiff Convert: How to Convert Raster Images (Jpeg/Png/Bmp/Gif) to Tiff Image
Give You Sample Codes for Changing and Converting Jpeg, Png, Bmp, and Gif Images to Tiff File
On the whole, our XDoc.Converter for .NET toolkit empowers C# developers to render and convert Bmp, Gif, Png, and Jpeg raster images to Tiff image file. More details here,
Generally speaking, the actual size of image during conversion between supported raster images and Tiff image will keep the same.
You are also allowed to set a target resolution for rendered Tiff image. But, note that, this might give rise to image distortion.
C# DLLs for Converting Images to TIFF
Add necessary references to your C# project:
RasterEdge.Imaging.Basic.dll
RasterEdge.Imaging.Basic.Codec.dll
RasterEdge.Imaging.DICOM.dll
RasterEdge.Imaging.Font.dll
RasterEdge.Imaging.Drawing.dll
RasterEdge.Imaging.JBIG2.dll
RasterEdge.Imaging.JPEG2000.dll
RasterEdge.Imaging.Processing.dll
RasterEdge.XDoc.Converter.dll
RasterEdge.XDoc.Excel.dll
RasterEdge.XDoc.Office.Inner.Common.dll
RasterEdge.XDoc.Office.Inner.Office03.dll
RasterEdge.XDoc.PDF.dll
RasterEdge.XDoc.PowerPoint.dll
RasterEdge.XDoc.TIFF.dll
RasterEdge.XDoc.Word.dll
RasterEdge.XImage.AdvancedCleanup.Core.dll
RasterEdge.XImage.OCR.dll
RasterEdge.XImage.OCR.Tesseract.dll
RasterEdge.XImage.Raster.Core.dll
RasterEdge.XImage.Raster.dll
Use the namespaces
using RasterEdge.Imaging.Basic;
using RasterEdge.XDoc.Converter;
Use C# to Convert Jpeg to Tiff
Here's an example of converting raster image Jpeg to Tiff image file. For other supported raster images, please see as below.
// Define input and output files path.
String inputFilePath = @"C:\input.jpg";
String outputFilePath = @"C:\output.tif";
String outputFilePathCompression = @"C:\outputCompression.tif";
// Convert Jpeg to Tiff with default resolution(96) and compression(JPEG).
DocumentConverter.ToDocument(inputFilePath, outputFilePath, FileType.DOC_TIFF);
//Convert Jpeg to tiff with resolution(192) and compression(CCITT)
//Define the document save setting options
DocumentSaveOption option = new DocumentSaveOption(FileType.DOC_TIFF);
//set the output tiff file compression
option.CompressionMode = ImageCompress.CCITT;
//set the output tiff file resolution
option.Resolution = 192;
DocumentConverter.ToDocument(inputFilePath, outputFilePathCompression, option);
|
Use C# to Convert Png to Tiff
This is for converting Png to Tiff in C# application.
// Define input and output files path.
String inputFilePath = @"C:\input.png";
String outputFilePath = @"C:\output.tif";
String outputFilePathCompression = @"C:\outputCompression.tif";
// Convert Jpeg to Tiff with default resolution(96) and compression(JPEG).
DocumentConverter.ToDocument(inputFilePath, outputFilePath, FileType.DOC_TIFF);
//Convert Jpeg to tiff with resolution(192) and compression(LZW)
//Define the document save setting options
DocumentSaveOption option = new DocumentSaveOption(FileType.DOC_TIFF);
//set the output tiff file compression
option.CompressionMode = ImageCompress.LZW;
//set the output tiff file resolution
option.Resolution = 192;
DocumentConverter.ToDocument(inputFilePath, outputFilePathCompression, option);
|
Use C# to Convert Bmp to Tiff
To convert Bmp image to Tiff image, you may refer to this C# demo.
// Define input and output files path.
String inputFilePath = @"C:\input.bmp";
String outputFilePath = @"C:\output.tif";
String outputFilePathCompression = @"C:\outputCompression.tif";
// Convert Jpeg to Tiff with default resolution(96) and compression(JPEG).
DocumentConverter.ToDocument(inputFilePath, outputFilePath, FileType.DOC_TIFF);
//Convert Jpeg to tiff with resolution(300) and compression(Group4Fax)
//Define the document save setting options
DocumentSaveOption option = new DocumentSaveOption(FileType.DOC_TIFF);
//set the output tiff file compression
option.CompressionMode = ImageCompress.Group4Fax;
//set the output tiff file resolution
option.Resolution = 300;
DocumentConverter.ToDocument(inputFilePath, outputFilePathCompression, option);
|
Use C# to Convert Gif to Tiff
You can also transform Gif image to Tiff image by using the following C# sample code.
// Define input and output files path.
String inputFilePath = @"C:\input.gif";
String outputFilePath = @"C:\output.tif";
String outputFilePathCompression = @"C:\outputCompression.tif";
// Convert Jpeg to Tiff with default resolution(96) and compression(JPEG).
DocumentConverter.ToDocument(inputFilePath, outputFilePath, FileType.DOC_TIFF);
//Convert Jpeg to tiff with resolution(192) and compression(Group3Fax)
//Define the document save setting options
DocumentSaveOption option = new DocumentSaveOption(FileType.DOC_TIFF);
//set the output tiff file compression
option.CompressionMode = ImageCompress.Group3Fax;
//set the output tiff file resolution
option.Resolution = 192;
DocumentConverter.ToDocument(inputFilePath, outputFilePathCompression, option);
|