Java Utililty Methods BufferedImage Save

List of utility methods to do BufferedImage Save

Description

The list of methods to do BufferedImage Save are organized into topic(s).

Method

booleansaveImage(BufferedImage image)
save Image
if (image == null)
    return false;
JFileChooser fC = new JFileChooser();
File file;
if (JFileChooser.APPROVE_OPTION == fC.showSaveDialog(null)) {
    file = fC.getSelectedFile();
    return saveImage(image, file);
return false;
voidsaveImage(BufferedImage img, String extension)
Asks the user for a file and then saves the image to that file.
JFileChooser fc = new JFileChooser(".");
int action = fc.showSaveDialog(null);
if (action == JFileChooser.APPROVE_OPTION && fc.getSelectedFile() != null) {
    File f = fc.getSelectedFile();
    if (f.getPath().toLowerCase().endsWith("." + extension.toLowerCase()) == false) {
        f = new File(f.getPath() + "." + extension);
    if (f.exists()) {
...
voidsaveImage(BufferedImage img, String targetfile)
save Image
String image_format = "png";
FileOutputStream out = new FileOutputStream(targetfile);
javax.imageio.ImageIO.write(img, image_format, out);
out.close();
voidSaveImageToFile(BufferedImage bimg, String filename, String outformat)
Save Image To File
File f = new File(filename);
if (outformat.equalsIgnoreCase("JPEG") || outformat.equalsIgnoreCase("JPG"))
    SaveJPEG(bimg, f);
else
    SaveImageToFile(bimg, f, outformat);