How can I save an image to disk in a standard image format?

John Zukowski

The javax.imageio package provides this for you in Java 1.4. Previousl versions had no standard support, though you could add third party libraries to standard Java for this.

    BufferedImage output = new BufferedImage (width, height,
// fill image
    // Save
    File outputFile = new File("image.png");
    ImageIO.write(output, "PNG", outputFile);