Saves the specified image in TIFF format. Displays a file save dialog if 'path' is null or an empty string. Returns 'false' if there is an error or if the user selects "Cancel" in the file save dialog.
(ImagePlus imp, String path)
| 2265 | if 'path' is null or an empty string. Returns 'false' if there is an |
| 2266 | error or if the user selects "Cancel" in the file save dialog. */ |
| 2267 | public static boolean saveAsTiff(ImagePlus imp, String path) { |
| 2268 | if (imp==null) |
| 2269 | imp = getImage(); |
| 2270 | if (path==null || path.equals("")) |
| 2271 | return (new FileSaver(imp)).saveAsTiff(); |
| 2272 | if (!path.endsWith(".tiff")) |
| 2273 | path = updateExtension(path, ".tif"); |
| 2274 | FileSaver fs = new FileSaver(imp); |
| 2275 | boolean ok; |
| 2276 | if (imp.getStackSize()>1) |
| 2277 | ok = fs.saveAsTiffStack(path); |
| 2278 | else |
| 2279 | ok = fs.saveAsTiff(path); |
| 2280 | if (ok) |
| 2281 | fs.updateImagePlus(path, FileInfo.TIFF); |
| 2282 | return ok; |
| 2283 | } |
| 2284 | |
| 2285 | static String updateExtension(String path, String extension) { |
| 2286 | if (path==null) return null; |
no test coverage detected