Skip to content

Instantly share code, notes, and snippets.

How to Convert PNG to JPG using Java. For more information, please follow link: https://kb.conholdate.com/total/java/how-to-convert-png-to-jpg-using-java
import com.groupdocs.conversion.Converter;
import com.groupdocs.conversion.licensing.License;
import com.groupdocs.conversion.options.convert.ImageConvertOptions;
public class ConvertPngToJpgUsingJava {
public static void main(String[] args) { // Main function to convert PNG to JPG in Java
// Remove the watermark in output JPG document by adding license
License lic = new License();
lic.setLicense("GroupDocs.Conversion.lic");
// Load the source PNG file for conversion to JPG
Converter converter = new Converter("sample.png");
// Set the convert options for JPG format
ImageConvertOptions options = new ImageConvertOptions();
// Convert and save the PNG in JPG format
converter.convert("converted.jpg", options);
System.out.println("Done");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment