MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / saveFolder

Method saveFolder

ij/src/main/java/ij/plugin/FITS_Writer.java:286–312  ·  view source on GitHub ↗
(ImagePlus imp, String path, String extension)

Source from the content-addressed store, hash-verified

284 }
285
286 public static void saveFolder(ImagePlus imp, String path, String extension) {
287 // GET PATH
288 if (path == null || path.trim().isEmpty()) {
289 var nm = imp.getTitle();
290
291 String title = FitsExtensionUtil.fileNameWithoutExt(nm);
292 SaveDialog sd = new SaveDialog("Write FITS image",title,extension);
293 path = sd.getDirectory()+sd.getFileName();
294 }
295
296 var p = Path.of(path);
297 var dir = Files.isDirectory(p) ? p : p.getParent();
298 var name = Files.isDirectory(p) ? "fits" : FitsExtensionUtil.fileNameWithoutExt(p.getFileName().toString());
299 var options = FitsExtensionUtil.compressionModes(path);
300
301 var size = imp.getStackSize();
302 int numberOfDigits = Integer.toString(size+1).length();
303
304 var format = new DecimalFormat("0".repeat(numberOfDigits));
305
306 IJ.showProgress(0, size);
307 for (int i = 1; i <= size; i++) {
308 var pi = dir.resolve(FitsExtensionUtil.makeFitsSave("%s_%s".formatted(name, format.format(i)), options.toArray(FitsExtensionUtil.CompressionMode[]::new)));
309 saveImage(imp, pi.toString(), i);
310 IJ.showProgress(i, size);
311 }
312 }
313
314 public static void saveMPTable(ResultsTable resultsTable, boolean includePrefs, boolean includeApertures, String path, String extension) {
315 IJ.showStatus("Saving image...");

Callers 1

buildMenubarMethod · 0.95

Calls 15

fileNameWithoutExtMethod · 0.95
getDirectoryMethod · 0.95
getFileNameMethod · 0.95
compressionModesMethod · 0.95
showProgressMethod · 0.95
makeFitsSaveMethod · 0.95
saveImageMethod · 0.95
getParentMethod · 0.80
resolveMethod · 0.80
getTitleMethod · 0.65
lengthMethod · 0.65
isEmptyMethod · 0.45

Tested by

no test coverage detected