javaimage-processingimage-editor

java save jpg as png


I have an image on disk which is a jpg file . I want to convert and save it as png and delete original jpg. Whats best way to do this in java?

String justNameJpg = "something.jpg";
String justNamePng = ImageEditor.GetImageNameNoExtension(justName) + "." + "png";
java.awt.image.BufferedImage bufferedImage = ImageIO.read(new File(folder, justNameJpg));
ImageIO.write(bufferedImage, "png", new File(folder, justNamePng));

Solution

  • If you want to use ImageIO this should work:

    ImageIO.write(image, "png", new File("new output file name"));