private void saveImageAsNewImage(ResourceFieldLocation imageLocation) {
		Data data = imageLocation.getResourceData();
		if (data == null || !(data.getValue() instanceof DataImage)) {
			return;
		}
		DataImage dataImage = (DataImage) data.getValue();
		GhidraFileChooser chooser = new GhidraFileChooser(tool.getActiveWindow());
		chooser.setFileSelectionMode(GhidraFileChooserMode.FILES_ONLY);
		chooser.setTitle("Save Image File As");
		chooser.setApproveButtonText("Save Image As");
		chooser.addFileFilter(GRAPHIC_FORMATS_FILTER);
		File f = chooser.getSelectedFile();
		chooser.dispose();
		if (f != null) {
			if (f.exists() && OptionDialog.showYesNoDialog(tool.getActiveWindow(),
				"Overwrite Existing File?",
				"Overwrite " + f.getName() + "?") != OptionDialog.YES_OPTION) {
				return;
			}
			String extension = FilenameUtils.getExtension(f.getName());
			if (extension.isBlank()) {
				Msg.showError(this, null, "Missing File Type",
					"Filename must specify a supported graphics format extension.");
				return;
			}

			try {
				ImageIcon icon = dataImage.getImageIcon();
				BufferedImage buffy = ImageUtils.getBufferedImage(icon.getImage());
				boolean success = ImageIO.write(buffy, extension, f);
				if (!success) {
					Msg.showError(this, null, "Image File Error",
						"Failed to save " + f.getName() +
							".\n\nEither unsupported image format or " +
							"incompatible image features with selected image format.");
					return;
				}
				tool.setStatusInfo(
					"Image resource at " + data.getAddress() + " saved as: " + f.getName());
			}
			catch (IOException e) {
				Msg.showError(this, null, "Image File Error", "Failed to save " + f.getName(), e);
			}
		}
	}
A plugin that adds actions to manage data resources in the listing
Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/resources/ResourceActionsPlugin.java