Hello!
I use ImageJ API in my java development work. I would like to use ij.io.FileSaver.saveAsJpeg(String path)
method to save an ImagePlus
instance as a Jpeg file. My method call looks like this:
new FileSaver(myImagePlusInstance).saveAsJpeg(myPathToFile);
However, I have a problem with the saveAsJpeg(String path)
method. For some reason (that I do not know) its implementation when saving ImagePlus.GRAY16
and ImagePlus.GRAY32
image instances explicitly excludes them from updating their corresponding FileInfo
object instances:
/** Save the image in JPEG format using the specified path.
@see #setJpegQuality
@see #getJpegQuality
*/
public boolean saveAsJpeg(String path) {
String err = JpegWriter.save(imp, path, jpegQuality);
if (err==null && !(imp.getType()==ImagePlus.GRAY16 || imp.getType()==ImagePlus.GRAY32))
updateImp(fi, FileInfo.GIF_OR_JPG);
return true;
}
I need to save as Jpeg ImagePlus.GRAY16
images. Further in my java application I have to use getOriginalFileInfo().directory
field for my ImagePlus
instances.
What is the correct way to update the FileInfo
object instance (in particular, its directory
field) when saving an ImagePlus.GRAY16
image as Jpeg file using ImageJ API?