private void exportImage(Image image, File file) throws IOException {

		BufferedImage buffered = ImageUtils.getBufferedImage(image);

		String extension = getExtensionFromFile(file).toLowerCase();

		switch (extension) {
			case "png":
			case "gif":
			case "jpg":
				break;
			default:
				extension = "png";
		}

		ImageIO.write(buffered, extension, file);
		Msg.info(this, "Saved image to '" + file.getCanonicalPath() + "' in " +
			extension.toUpperCase() + " format");
	}
An action to save the image from a NavigableImagePanel to a file.
<p>
The user is asked to provide a file to save the image to.
<p>
This class uses the ImageIO library to write the image to a file;
the image format is determined by filename extension -- PNG, GIF and JPG extensions are 
recognized and honored, other extensions are ignored, and the file is written in PNG 
format. Image transparency is honored when possible.

@see javax.imageio.ImageIO
Ghidra/Framework/Docking/src/main/java/docking/widgets/imagepanel/actions/SaveImageAction.java