Convert PNG Images to JPG in Java

Convert PNG images to JPG in Java

In various scenarios, you may need to reduce 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 programmatically in Java.

Java API for PNG to JPG Conversion

To convert PNG images to JPEG format, we will use Aspose.Imaging for Java. It is a feature-rich image processing API for 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.

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>http://repository.aspose.com/repo/</url>
</repository>
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-imaging-java</artifactId>
    <version>21.12</version>
    <classifier>jdk16</classifier>
</dependency>

Convert a PNG Image to 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.

The following code sample shows how to convert a PNG image to JPG format.

Get a Free API License

You can get a free temporary license to use Aspose.Imaging for Java without evaluation limitations.

Conclusion

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.

See Also