Page 1 of 1

Java: TiffParser().getComment() returns null

PostPosted: Wed Feb 15, 2017 8:28 pm
by lando.wark
I'm having a problem with some code that I have previously got working. Essentially it's an ImageJ plugin that copies the metadata from a zvi image to an ome.tif copy of that image. I've used it quite a bit in the past with no problems, but now... not so much.

The problem is in the following code:

Code: Select all
String tReader;
try {
   IJ.log("Accessing metadata.");
   tReader = new TiffParser(imgIn).getComment();
} catch (IOException e) {
   tReader = "";
   IJ.log("Failure to parse tiffcomment");
   e.printStackTrace();
   return;
}
      
//String manipulation.
IJ.log("Tiffcomment: " + tReader);


The final log command returns "Tiffcomment: null". It prints "Accessing metadata." so there's no exception. When I load the image with bioformats the associated metadata is there.
I'm wondering if there's been an update that has maybe broken some functionality of the code.
Does anyone have any ideas?

Re: Java: TiffParser().getComment() returns null

PostPosted: Thu Feb 16, 2017 11:36 am
by dgault
Hi,

There hasn't been any recent changes to the TiffParser or ZeissZVIReader which would explain this behaviour. A couple of initial questions that might help to investigate this:
- Are you seeing the issue on selective files or is occurring all the time?
- What version of Bio-Formats do you currently have installed?(Can be found in Help -> About Plugins -> Bio-Formats Plugins)?
- Are you initialising the TiffParser with an input stream or are you passing a filename?

One quick test you could use to check if it is reading the input file as a valid Tiff stream would be the following call:
Code: Select all
TiffParser parser = new TiffParser(imgIn).getComment();
boolean isValidTiff = parser.isValidHeader();
IJ.log("TiffParser - Valid Tiff found : " + isValidTiff);


David Gault

Re: Java: TiffParser().getComment() returns null

PostPosted: Fri Feb 17, 2017 2:33 pm
by lando.wark
Hmmm. I tried your reporting technique and it seems that it's pretty much all zvi images. I don't remember this being a problem before. I've constructed a workaround that just exports zvi as an ome.tif before processing and it seems to be working okay.

Thanks for your time.

Re: Java: TiffParser().getComment() returns null

PostPosted: Mon Feb 20, 2017 11:13 am
by dgault
Thats good to hear that you have found a work around for now. I have added this as an issue to our Bio-Formats inbox for further testing and investigation into the cause of the original problem.