use of loci.formats.tiff.TiffParser in project bioformats by openmicroscopy.
the class TrestleReader method isThisType.
/* @see loci.formats.IFormatReader#isThisType(RandomAccessInputStream) */
@Override
public boolean isThisType(RandomAccessInputStream stream) throws IOException {
TiffParser parser = new TiffParser(stream);
IFD ifd = parser.getFirstIFD();
if (ifd == null)
return false;
String copyright = ifd.getIFDTextValue(IFD.COPYRIGHT);
if (copyright == null)
return false;
return copyright.indexOf("Trestle Corp.") >= 0;
}
use of loci.formats.tiff.TiffParser in project bioformats by openmicroscopy.
the class VectraReader method isThisType.
// -- IFormatReader API methods --
/* (non-Javadoc)
* @see loci.formats.FormatReader#isThisType(java.lang.String, boolean)
*/
@Override
public boolean isThisType(String name, boolean open) {
if (!open) {
return checkSuffix(name, "qptiff");
}
try (RandomAccessInputStream stream = new RandomAccessInputStream(name)) {
TiffParser tiffParser = new TiffParser(stream);
tiffParser.setDoCaching(false);
if (!tiffParser.isValidHeader()) {
return false;
}
IFD ifd = tiffParser.getFirstIFD();
if (ifd == null) {
return false;
}
tiffParser.fillInIFD(ifd);
String software = ifd.getIFDTextValue(IFD.SOFTWARE);
return software != null && software.startsWith(SOFTWARE_CHECK);
} catch (IOException e) {
LOGGER.debug("I/O exception during isThisType() evaluation.", e);
return false;
}
}
use of loci.formats.tiff.TiffParser in project bioformats by openmicroscopy.
the class SVSReader method isThisType.
/* (non-Javadoc)
* @see loci.formats.FormatReader#isThisType(java.lang.String, boolean)
*/
@Override
public boolean isThisType(String name, boolean open) {
boolean isThisType = super.isThisType(name, open);
if (!isThisType && open) {
RandomAccessInputStream stream = null;
try {
stream = new RandomAccessInputStream(name);
TiffParser tiffParser = new TiffParser(stream);
tiffParser.setDoCaching(false);
if (!tiffParser.isValidHeader()) {
return false;
}
IFD ifd = tiffParser.getFirstIFD();
if (ifd == null) {
return false;
}
Object description = ifd.get(IFD.IMAGE_DESCRIPTION);
if (description != null) {
String imageDescription = null;
if (description instanceof TiffIFDEntry) {
Object value = tiffParser.getIFDValue((TiffIFDEntry) description);
if (value != null) {
imageDescription = value.toString();
}
} else if (description instanceof String) {
imageDescription = (String) description;
}
if (imageDescription != null && imageDescription.startsWith(APERIO_IMAGE_DESCRIPTION_PREFIX)) {
return true;
}
}
return false;
} catch (IOException e) {
LOGGER.debug("I/O exception during isThisType() evaluation.", e);
return false;
} finally {
try {
if (stream != null) {
stream.close();
}
} catch (IOException e) {
LOGGER.debug("I/O exception during stream closure.", e);
}
}
}
return isThisType;
}
use of loci.formats.tiff.TiffParser in project bioformats by openmicroscopy.
the class SlidebookTiffReader method isThisType.
// -- IFormatReader API methods --
/* @see loci.formats.IFormatReader#isThisType(RandomAccessInputStream) */
@Override
public boolean isThisType(RandomAccessInputStream stream) throws IOException {
TiffParser tp = new TiffParser(stream);
IFD ifd = tp.getFirstIFD();
if (ifd == null)
return false;
String software = ifd.getIFDTextValue(IFD.SOFTWARE);
if (software == null)
return false;
return software.equals(SLIDEBOOK_MAGIC_STRING) && ifd.getComment().length() == 0 && (ifd.containsKey(X_POS_TAG) || ifd.containsKey(Y_POS_TAG) || ifd.containsKey(Z_POS_TAG) || ifd.containsKey(CHANNEL_TAG) || ifd.containsKey(PHYSICAL_SIZE_TAG) || ifd.containsKey(MAGNIFICATION_TAG));
}
use of loci.formats.tiff.TiffParser in project bioformats by openmicroscopy.
the class SlidebookTiffReader method getFirstChannel.
private String getFirstChannel(String path) throws FormatException, IOException {
RandomAccessInputStream s = new RandomAccessInputStream(path);
TiffParser parser = new TiffParser(s);
IFD ifd = parser.getFirstIFD();
Object channel = ifd.getIFDValue(CHANNEL_TAG);
s.close();
parser.getStream().close();
return channel == null ? null : channel.toString();
}
Aggregations