This article describes the method of converting png format images into jpg format images in Java. Share it for your reference, as follows:
import java.awt.Color;import java.awt.image.BufferedImage;import java.io.File;import java.io.IOException;import javax.imageio.ImageIO;public class ConvertImageFile { public static void main(String[] args) { BufferedImage bufferedImage; try { // read image file bufferedImage = ImageIO.read(new File("c://java.png")); // create a blank, RGB, same width and height, and a white // background BufferedImage newBufferedImage = new BufferedImage(bufferedImage.getWidth(), bufferedImage.getHeight(), BufferedImage.TYPE_INT_RGB); // TYPE_INT_RGB: Create an RBG image with a 24-bit depth, and successfully convert the 32-bit map into 24-bit newBufferedImage.createGraphics().drawImage(bufferedImage, 0, 0, Color.WHITE, null); // write to jpeg file ImageIO.write(newBufferedImage, "jpg", new File("c://java.jpg")); System.out.println("Done"); } catch (IOException e) { e.printStackTrace(); } }}PS: Here are a few online tools related to image processing for your reference:
Online picture format conversion (jpg/bmp/gif/png) tool:
http://tools.VeVB.COM/aideddesign/picext
Online picture cropping/generating tools:
http://tools.VeVB.COM/aideddesign/imgcut
ICO icon online generation tool:
http://tools.VeVB.COM/aideddesign/ico_img
Online low polygon graphics generation tool:
http://tools.VeVB.COM/aideddesign/img_lowpoly
For more Java-related content, readers who are interested in this site can view the topics: "Summary of Java Image Operation Skills", "Summary of Java Date and Time Operation Skills", "Summary of Java Operation DOM Node Skills", "Summary of Java File and Directory Operation Skills" and "Tutorials of Java Data Structure and Algorithm".
I hope this article will be helpful to everyone's Java programming.