Search in sources :

Example 16 with TiffParser

use of loci.formats.tiff.TiffParser in project bioformats by openmicroscopy.

the class ImaconReader method isThisType.

// -- IFormatReader API methods --
/* @see loci.formats.IFormatReader#isThisType(RandomAccessInputStream) */
@Override
public boolean isThisType(RandomAccessInputStream stream) throws IOException {
    TiffParser parser = new TiffParser(stream);
    parser.setDoCaching(false);
    IFD ifd = parser.getFirstIFD();
    if (ifd == null)
        return false;
    return ifd.containsKey(XML_TAG);
}
Also used : IFD(loci.formats.tiff.IFD) TiffParser(loci.formats.tiff.TiffParser)

Example 17 with TiffParser

use of loci.formats.tiff.TiffParser in project bioformats by openmicroscopy.

the class PCIReader method getOptimalTileWidth.

/* @see loci.formats.IFormatReader#getOptimalTileWidth() */
@Override
public int getOptimalTileWidth() {
    FormatTools.assertId(currentId, true, 1);
    String file = imageFiles.get(0);
    try {
        if (poi == null) {
            initPOIService();
        }
        RandomAccessInputStream s = poi.getDocumentStream(file);
        TiffParser tp = new TiffParser(s);
        if (tp.isValidHeader()) {
            IFD ifd = tp.getFirstIFD();
            s.close();
            return (int) ifd.getTileWidth();
        }
        s.close();
    } catch (FormatException e) {
        LOGGER.debug("Could not retrieve tile width", e);
    } catch (IOException e) {
        LOGGER.debug("Could not retrieve tile width", e);
    }
    return super.getOptimalTileWidth();
}
Also used : IFD(loci.formats.tiff.IFD) TiffParser(loci.formats.tiff.TiffParser) RandomAccessInputStream(loci.common.RandomAccessInputStream) IOException(java.io.IOException) FormatException(loci.formats.FormatException)

Example 18 with TiffParser

use of loci.formats.tiff.TiffParser in project bioformats by openmicroscopy.

the class PCIReader method openBytes.

/**
 * @see loci.formats.IFormatReader#openBytes(int, byte[], int, int, int, int)
 */
@Override
public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException {
    FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h);
    if (poi == null) {
        initPOIService();
    }
    String file = imageFiles.get(no);
    RandomAccessInputStream s = poi.getDocumentStream(file);
    TiffParser tp = new TiffParser(s);
    if (tp.isValidHeader()) {
        IFD ifd = tp.getFirstIFD();
        tp.getSamples(ifd, buf, x, y, w, h);
    } else {
        s.seek(0);
        readPlane(s, x, y, w, h, buf);
    }
    s.close();
    return buf;
}
Also used : IFD(loci.formats.tiff.IFD) TiffParser(loci.formats.tiff.TiffParser) RandomAccessInputStream(loci.common.RandomAccessInputStream)

Example 19 with TiffParser

use of loci.formats.tiff.TiffParser in project bioformats by openmicroscopy.

the class PhotoshopTiffReader method isThisType.

// -- IFormatReader API methods --
/* @see loci.formats.IFormatReader#isThisType(RandomAccessInputStream) */
@Override
public boolean isThisType(RandomAccessInputStream stream) throws IOException {
    TiffParser tp = new TiffParser(stream);
    tp.setDoCaching(false);
    IFD ifd = tp.getFirstIFD();
    if (ifd == null)
        return false;
    return ifd.containsKey(IMAGE_SOURCE_DATA);
}
Also used : IFD(loci.formats.tiff.IFD) TiffParser(loci.formats.tiff.TiffParser)

Example 20 with TiffParser

use of loci.formats.tiff.TiffParser in project bioformats by openmicroscopy.

the class PrairieReader method isThisType.

@Override
public boolean isThisType(RandomAccessInputStream stream) throws IOException {
    final int blockLen = (int) Math.min(1048608, stream.length());
    if (!FormatTools.validStream(stream, blockLen, false))
        return false;
    String s = stream.readString(blockLen);
    if (s.indexOf("xml") != -1 && s.indexOf("PV") != -1)
        return true;
    TiffParser tp = new TiffParser(stream);
    IFD ifd = tp.getFirstIFD();
    if (ifd == null)
        return false;
    String software = null;
    try {
        software = ifd.getIFDStringValue(IFD.SOFTWARE);
    } catch (FormatException exc) {
        // no software tag, or tag is wrong type
        return false;
    }
    if (software == null)
        return false;
    // not Prairie software
    if (software.indexOf("Prairie") < 0)
        return false;
    return ifd.containsKey(new Integer(PRAIRIE_TAG_1)) && ifd.containsKey(new Integer(PRAIRIE_TAG_2)) && ifd.containsKey(new Integer(PRAIRIE_TAG_3));
}
Also used : IFD(loci.formats.tiff.IFD) TiffParser(loci.formats.tiff.TiffParser) FormatException(loci.formats.FormatException)

Aggregations

TiffParser (loci.formats.tiff.TiffParser)96 IFD (loci.formats.tiff.IFD)74 RandomAccessInputStream (loci.common.RandomAccessInputStream)56 FormatException (loci.formats.FormatException)26 CoreMetadata (loci.formats.CoreMetadata)19 IOException (java.io.IOException)18 IFDList (loci.formats.tiff.IFDList)16 Location (loci.common.Location)15 MetadataStore (loci.formats.meta.MetadataStore)15 ArrayList (java.util.ArrayList)12 Timestamp (ome.xml.model.primitives.Timestamp)9 Length (ome.units.quantity.Length)8 PhotoInterp (loci.formats.tiff.PhotoInterp)6 File (java.io.File)5 HashMap (java.util.HashMap)5 ServiceException (loci.common.services.ServiceException)4 Time (ome.units.quantity.Time)4 NonNegativeInteger (ome.xml.model.primitives.NonNegativeInteger)4 List (java.util.List)3 ByteArrayHandle (loci.common.ByteArrayHandle)3