Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active December 15, 2021 03:10
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/043a4cdac69552bf48360e07520ee206 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/043a4cdac69552bf48360e07520ee206 to your computer and use it in GitHub Desktop.
Convert PNG to JPG or JPG to PNG in C#
// Load JPG image
using (Image image = Image.Load("aspose.jpg"))
{
// Create PNG options
PngOptions options = new PngOptions() { ColorType= FileFormats.Png.PngColorType.TruecolorWithAlpha };
// Save image as JPG
image.Save("JPG-to-PNG.png", options);
}
// Load PNG image
using (Image image = Image.Load("aspose.png"))
{
// Save image as JPG
image.Save("PNG-to-JPG.jpg", new JpegOptions());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment