I’m currently using the ij.jar in a Java application and using ImageJ to save some processed images to the disk. However, if I try to save an image to a file that already exists, the save fails silently. The original file remains untouched and ImageJ does not throw an error.
Here is a sample piece of code:
IJ.saveAs(image, filename);
Is there a way to have saveAs automatically overwrite if a file with the same name already exists?
I think you’ll be best off using the
FileSaverclass (ij.io.FileSaver) instead of the genericsaveAsmethod. For example, if yourImagePlusisimage, then you can save it as a TIFF stack with:If you need another format, have a look at the documentation, and you’ll see that there are similar methods for other formats.