In various scenarios, you may need to reduce the size of the PNG images. In such cases, PNG to JPG conversion is commonly practiced. To automate this conversion from within the Java applications, this article shows how to convert a PNG image to JPG in Java.
- Java PNG to JPG Converter - Free Download
- Steps to Convert PNG to JPG in Java
- Convert a PNG Image to JPG
Convert PNG to JPG in Java - API Installation
To convert PNG images to JPEG format, we will use Aspose.Imaging for Java. It is a feature-rich image processing API for the manipulation of a wide range of image formats. The API also provides a powerful image converter to convert images from one format to another. You can either download the API’s JAR or install it using Maven.
<name>Aspose Java API</name>
How to Convert PNG to JPG in Java
The following are the steps to convert a PNG image to JPG format.
- Load the PNG image from file.
- Save PNG as JPG image to the desired location.
Let’s now have a look at how to convert a PNG image to JPG format in Java.
Save a PNG Image as JPG in Java
Aspose.Imaging for Java involves only a couple of steps to perform PNG to JPG conversion. Just load the PNG image and save it in JPG format. Let’s see how to convert a PNG image to JPG in Java.
- Load the PNG file using Image class.
- Convert PNG to JPG using Image.save(string, JpegOptions) method.
The following code sample shows how to save a PNG image as JPG in Java.
Java PNG to JPG Converter - Get a Free License
You can get a free temporary license to convert PNG images to JPG format without evaluation limitations.
In this article, you have learned how to convert PNG images to JPG in Java. You can simply install the API and integrate provided code sample to automate PNG to JPG conversion from within your Java applications. In addition, you can explore more about the Java image processing API using documentation. Also, you can post your queries on our forum.