private void saveImageOriginalBytes(ResourceFieldLocation imageLocation) {
		Data data = imageLocation.getResourceData();
		if (data == null) {
			return;
		}
		try {
			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;
				}
				byte[] bytes = data.getBytes();
				FileUtilities.writeBytes(f, bytes);
				tool.setStatusInfo(
					"Image resource at " + data.getAddress() + " saved as: " + f.getName());
			}
		}
		catch (MemoryAccessException | IOException e) {
			Msg.showError(this, null, "Error Saving Image File", "Failed to save image", 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