Convert PNG images to JPG in C#

Converting images between formats is a common task in various scenarios, with one of the most frequently performed conversions being from PNG to JPG. This conversion is particularly beneficial for reducing image file sizes, making it easier to manage and share images. In this article, we will explore how to convert a PNG image to JPG in C# using the powerful Aspose.Imaging for .NET API, a leading solution for .NET image processing.

Table of Contents

API Installation for PNG to JPG Conversion

To perform the conversion from PNG to JPG, we will utilize the Aspose.Imaging for .NET API. This robust image processing API supports a wide range of image formats and provides an easy-to-use interface for converting images without compromising quality. You can install the API by either downloading the DLL from the Aspose website or directly through NuGet using the following command:

PM> Install-Package Aspose.Imaging

**TIP**: If you're also interested in converting images in the opposite direction, [Aspose.Slides .NET](https://products.aspose.com/slides/net/) can handle both PNG to JPG and JPG to PNG conversions, along with other formats such as [PNG to SVG](https://products.aspose.com/slides/net/conversion/png-to-svg/) and the reverse [SVG to PNG](https://products.aspose.com/slides/net/conversion/svg-to-png/).

## Steps to Convert PNG to JPG in C# {#steps-to-convert-png-to-jpg-in-c}

The process of converting a PNG image to JPG format in C# is straightforward. Follow these simple steps:

1. Load the PNG image from a file.
2. Save the image as a JPG to your desired location.

That's all there is to it! Now, let's dive into the code that accomplishes this task.

## Code Example: Converting a PNG to JPG in C# {#code-example-converting-a-png-to-jpg-in-c}

Using the Aspose.Imaging for .NET API, converting a PNG image to JPG is a breeze. You simply need to load the image and save it in the desired format. Here's how you can do it:

- Load the PNG file using the [Image](https://reference.aspose.com/imaging/net/aspose.imaging/image) class.
- Convert the PNG to JPG using the [Image.Save(string, JpegOptions)](https://reference.aspose.com/imaging/net/aspose.imaging.image/save/methods/4) method.

Here’s a code sample that demonstrates how to save a PNG image as JPG in C#:




## Get a Free License for the Aspose Plugin {#get-a-free-license-for-the-aspose-plugin}

You can [obtain a free temporary license](https://purchase.aspose.com/temporary-license) to convert PNG images to JPG format without any evaluation limitations, allowing you to explore the full capabilities of the Aspose.Imaging Plugin.

## Conclusion {#conclusion}

In this article, we've explored how to convert PNG images to JPG format in C#. By installing the Aspose.Imaging .NET Plugin and utilizing the provided code samples, you can easily automate this image conversion process within your .NET applications. For further insights and details about the .NET image processing API, feel free to check the [documentation](https://docs.aspose.com/imaging/net/) or post your questions on our [forum](https://forum.aspose.net/).

## See Also

- [Convert Images to Grayscale in C#](https://blog.aspose.com/imaging/convert-images-to-grayscale-in-csharp/)
- [Add Watermark to Images using C#](https://blog.aspose.com/imaging/add-watermark-to-images-in-csharp/)
- [Compress PNG, JPEG, and TIFF Images using C#](https://blog.aspose.com/imaging/compress-png-jpeg-and-tiff-images-using-csharp/)