XImage.Raster
Features
Tech Specs
How-to C#
Pricing

C# Imaging Library
C# Raster - Convert Image to PNG in C#.NET


Online C# Guide for Converting Image to PNG in .NET Application



How to convert, export TIFF, BMP, JPG raster image to PNG file using C#?

  1. Download XImage.Raster C# imaging library
  2. Install C# library to convert, export TIFF, BMP, JPG raster image to PNG file in .NET applications
  3. Step by Step Tutorial










Convert RasterImage to PNG

Sample Code (convert single frame image to PNG):

ConvertHandler.Convert("input.jpeg", @"output.png");


The C# example code below will convert the first page of multi-page TIFF document to PNG image file.

RasterImage img = new RasterImage("input.tiff");
img.Save(@"output.png");


The C# example code below will convert the specified page of multi-page TIFF document to PNG image file.

  • Use methdo MultiPageImageProcess.ExtractPages() to get the specified tiff page or pages into a new RasterImage object
  • Save the tiff page to a PNG image file
RasterImage image = new RasterImage("C://input//multi-page-tiff-sample.tiff");
int[] pageIdnex = new int[] { 1 };
RasterImage output = MultiPageImageProcess.ExtractPages(image, pageIdnex);
SaveOption options = new SaveOption();
options.ImageFormat = RasterEdge.XImage.Raster.ImageFormat.PNG;
image.Save("C://output//sample-color-barcode.png", options);




How to convert image to PNG with options applied in C#?



When you convert image to PNG image file using XImage.Raster C# Imaging library, you can customize and apply the following PNG image options
  • Filter filtering the data before compression
  • Interlaced if save the png file in interlaced format. Turn on it if there is a slow internet connection.
  • Level compression level
  • Strategy compression strategy
  • TransparencyColor pick a color form the image, and make it transparent
  • TransparencyMatch colors within this distance are considered equal.


The C# source code below explains how to convert a JPEG image to PNG image with PNG properties applied using XImage.Raster C# image library.

  • In the SaveOption object, specify the output image format in property ImageFormat as RasterEdge.XImage.Raster.ImageFormat.PNG
  • Customize the PNG image property settings through SaveOption.Png

SaveOption options = new SaveOption();
options.ImageFormat = RasterEdge.XImage.Raster.ImageFormat.PNG;
options.Png.Filter = PNGFilter.PAETH;
options.Png.Interlaced = true;
options.Png.Level = PNGCompressLevel.LEVEL9;
RasterImage image = new RasterImage("C://input//sample-color-barcode.jpg");
image.Save("C://output//sample-color-barcode.png", options);