Skip to content

Instantly share code, notes, and snippets.

@aspose-com-kb
Last active March 31, 2023 18:10
How to Convert Tiff to PNG in C#. For more information: https://kb.aspose.com/imaging/net/how-to-convert-tiff-to-png-in-csharp/
using System;
using Aspose.Imaging;
using Aspose.Imaging.FileFormats.Tiff;
using Aspose.Imaging.ImageOptions;
namespace TestImaging
{
public class TiffToPNG
{
public static void ConvertTiffToPNG()
{
String path = @"/Users/Documents/TestData/";
// Applying product license to convert Tiff to PNG in C#
License TiffToPdfLicense = new License();
TiffToPdfLicense.SetLicense(path + "Conholdate.Total.Product.Family.lic");
using (Image srcTiffImage = Image.Load(path+ "AFREY-Original.tif"))
{
TiffImage tiffImage = (TiffImage)srcTiffImage;
// Initialize an index variable to keep track of the frames in the tiff image,
// Iterate through the tiff frame collection and Save the PNG image on the disk
int index = 0;
foreach (var tiffFrame in tiffImage.Frames)
{
tiffFrame.Save(path + ++index + "_image_out.png", new PngOptions());
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment