We're Hiring!

Java: TiffParser().getComment() returns null

Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats
Please note:
Historical discussions about the Bio-Formats library. Please look for and ask new questions at https://forum.image.sc/tags/bio-formats

If you are having trouble with image files, there is information about reporting bugs in the Bio-Formats documentation. Please send us the data and let us know what version of Bio-Formats you are using. For issues with your code, please provide a link to a public repository, ideally GitHub.

Java: TiffParser().getComment() returns null

Postby lando.wark » Wed Feb 15, 2017 8:28 pm

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?
lando.wark
 
Posts: 11
Joined: Fri May 20, 2016 3:23 am

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

Postby dgault » Thu Feb 16, 2017 11:36 am

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
User avatar
dgault
Team Member
 
Posts: 208
Joined: Fri Aug 14, 2015 2:56 pm

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

Postby lando.wark » Fri Feb 17, 2017 2:33 pm

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.
lando.wark
 
Posts: 11
Joined: Fri May 20, 2016 3:23 am

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

Postby dgault » Mon Feb 20, 2017 11:13 am

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.
User avatar
dgault
Team Member
 
Posts: 208
Joined: Fri Aug 14, 2015 2:56 pm


Return to User Discussion [Legacy]

Who is online

Users browsing this forum: No registered users and 0 guests