Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert GIF to TIFF, PDF and Raster Images in C#
// Load GIF image
using (var image = Image.Load(@"Sample_2.gif"))
{
// Convert frame 1 of GIF to BMP
image.Save("converted-to-bmp.bmp", new BmpOptions() { MultiPageOptions = new MultiPageOptions(6), FullFrame = true });
}
// Load GIF image
using (var image = Image.Load(@"Sample_2.gif"))
{
// Convert frame 1 of GIF to JPG
image.Save("converted-to-jpg.jpg", new JpegOptions() { MultiPageOptions = new MultiPageOptions(6), FullFrame = true });
}
// Load GIF file
using (Image image = Image.Load(@"sample_2.gif"))
{
// Convert all the frames
image.Save("GIF-to-PDF.pdf", new PdfOptions() { FullFrame = true });
// Convert selected frames
image.Save("Selected-Frames-to-PDF.pdf", new PdfOptions() { MultiPageOptions = new MultiPageOptions(new IntRange(2, 5)), FullFrame = true });
}
// Load GIF image
using (var image = Image.Load(@"Sample_2.gif"))
{
// Convert frame 1 of GIF to PNG
image.Save("converted-to-png.png", new PngOptions() { MultiPageOptions = new MultiPageOptions(1), FullFrame = true });
}
// Load GIF file
using (var image = Image.Load(@"sample_2.gif"))
{
// Convert selected frames only
image.Save("Selected-Frames.tiff", new TiffOptions(TiffExpectedFormat.TiffDeflateRgb) { MultiPageOptions = new MultiPageOptions(new IntRange(1, 3)), FullFrame = true });
// Convert all the frames
image.Save("GIF-to-TIFF.tiff", new TiffOptions(TiffExpectedFormat.TiffDeflateRgb) { FullFrame = true });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.