Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created June 10, 2020 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/b8ed72ac8b5ad3f06e103a003c6c8e78 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/b8ed72ac8b5ad3f06e103a003c6c8e78 to your computer and use it in GitHub Desktop.
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