loci.formats.out

## Class OMETiffWriter

- java.lang.Object
- - loci.formats.FormatHandler
  - - loci.formats.FormatWriter
    - - loci.formats.out.TiffWriter
      - - loci.formats.out.OMETiffWriter

- All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, ICompressedTileWriter, IFormatHandler, IFormatWriter, IMetadataConfigurable, IPyramidHandler
  Direct Known Subclasses:
    PyramidOMETiffWriter

      public class OMETiffWriter
      extends TiffWriter

  OMETiffWriter is the file format writer for OME-TIFF files.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `COMPANION_KEY`
    `static java.lang.String` | `CREATOR_KEY`
    `private java.util.Map<java.lang.String,java.lang.Integer>` | `ifdCounts`
    `private java.lang.String[][]` | `imageLocations`
    `private OMEXMLMetadata` | `omeMeta`
    `private OMEXMLService` | `service`
    `private java.util.Map<java.lang.String,java.lang.String>` | `uuids`
    `private static java.lang.String` | `WARNING_COMMENT`

    - ### Fields inherited from class loci.formats.out.TiffWriter

      `canDetectBigTiff, checkParams, COMPRESSION_J2K, COMPRESSION_J2K_LOSSY, COMPRESSION_JPEG, COMPRESSION_LZW, COMPRESSION_UNCOMPRESSED, COMPRESSION_ZLIB, in, isBigTiff, tiffSaver, tileSizeX, tileSizeY`

    - ### Fields inherited from class loci.formats.FormatWriter

      `cm, compression, compressionTypes, fps, initialized, interleaved, metadataRetrieve, options, out, resolution, resolutionData, sequential, series, validBits`

    - ### Fields inherited from class loci.formats.FormatHandler

      `COMPRESSION_SUFFIXES, currentId, format, LOGGER, metadataOptions, suffixes`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `OMETiffWriter()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `private java.lang.String` | `getBinaryOnlyOMEXML(java.lang.String file, java.lang.String companion, java.lang.String companionUUID)`
    `java.lang.String` | `getCompanion()` Get the value of the `COMPANION_KEY` option.
    `private java.lang.String` | `getOMEXML(java.lang.String file)`
    `private java.lang.String` | `getUUID(java.lang.String filename)` Gets the UUID corresponding to the given filename.
    `private java.lang.String` | `insertWarningComment(java.lang.String xml)`
    `private int` | `planeCount()`
    `private void` | `populateImage(OMEXMLMetadata omeMeta, int series)`
    `private void` | `populateTiffData(OMEXMLMetadata omeMeta, int[] zct, int ifd, int series, int plane)`
    `boolean` | `preserveCreator()` Get the value of the `CREATOR_KEY` option.
    `void` | `saveBytes(int no, byte[] buf, IFD ifd, int x, int y, int w, int h)` Saves the given image to the specified series in the current file.
    `void` | `saveBytes(int no, byte[] buf, int x, int y, int w, int h)` Saves the given image tile to the current series in the current file.
    `private void` | `saveComment(java.lang.String file, java.lang.String xml)`
    `void` | `saveCompressedBytes(int no, byte[] buf, int x, int y, int w, int h)` Save a compressed tile to the current output file.
    `private void` | `setCreator(ome.xml.meta.OMEXMLMetadataRoot root)` Set the Creator attribute on the given OME-XML root object.
    `void` | `setId(java.lang.String id)` Initializes a writer from the input file name.
    `private void` | `setupServiceAndMetadata()`

    - ### Methods inherited from class loci.formats.out.TiffWriter

      `canDoStacks, createInputStream, createTiffSaver, getCodec, getPixelTypes, getPlaneCount, getTileSizeX, getTileSizeY, makeIFD, prepareToWriteImage, saveBytes, setBigTiff, setCanDetectBigTiff, setTileSizeX, setTileSizeY, setupTiffSaver`

    - ### Methods inherited from class loci.formats.FormatWriter

      `changeOutputFile, checkParams, createOutputStream, getCodecOptions, getColorModel, getCompression, getCompressionTypes, getFramesPerSecond, getMetadataRetrieve, getPixelTypes, getPlaneCount, getResolution, getResolutionCount, getResolutions, getSamplesPerPixel, getSamplesPerPixel, getSeries, getSizeX, getSizeY, hasResolutions, isFullPlane, isInterleaved, isSupportedType, saveBytes, saveBytes, savePlane, savePlane, savePlane, seekToPlaneOffset, setCodecOptions, setColorModel, setCompression, setFramesPerSecond, setInterleaved, setMetadataRetrieve, setResolution, setResolutions, setSeries, setValidBitsPerPixel, setWriteSequentially`

    - ### Methods inherited from class loci.formats.FormatHandler

      `checkSuffix, checkSuffix, getFormat, getMetadataOptions, getNativeDataType, getSuffixes, getSupportedMetadataLevels, isThisType, setMetadataOptions`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface loci.formats.IFormatHandler

      `getFormat, getNativeDataType, getSuffixes, isThisType`

    - ### Methods inherited from interface loci.formats.IMetadataConfigurable

      `getMetadataOptions, getSupportedMetadataLevels, setMetadataOptions`

- - ### Field Detail

    - #### WARNING_COMMENT

          private static final java.lang.String WARNING_COMMENT

      See Also:
        Constant Field Values

    - #### COMPANION_KEY

          public static final java.lang.String COMPANION_KEY

      See Also:
        Constant Field Values

    - #### CREATOR_KEY

          public static final java.lang.String CREATOR_KEY

      See Also:
        Constant Field Values

    - #### imageLocations

          private java.lang.String[][] imageLocations

    - #### omeMeta

          private OMEXMLMetadata omeMeta

    - #### service

          private OMEXMLService service

    - #### ifdCounts

          private java.util.Map<java.lang.String,java.lang.Integer> ifdCounts

    - #### uuids

          private java.util.Map<java.lang.String,java.lang.String> uuids

  - ### Constructor Detail

    - #### OMETiffWriter

          public OMETiffWriter()

  - ### Method Detail

    - #### close

          public void close()
                     throws java.io.IOException

      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Overrides:
        `close` in class `TiffWriter`
      Throws:
        `java.io.IOException`

    - #### saveCompressedBytes

          public void saveCompressedBytes(int no,
                                          byte[] buf,
                                          int x,
                                          int y,
                                          int w,
                                          int h)
                                   throws FormatException,
                                          java.io.IOException

      Description copied from interface: `ICompressedTileWriter`
      Save a compressed tile to the current output file. The compression type of the tile should match the compression type set in the writer.
      Specified by:
        `saveCompressedBytes` in interface `ICompressedTileWriter`
      Overrides:
        `saveCompressedBytes` in class `TiffWriter`
      Parameters:
        `no` - plane index
        `buf` - compressed tile bytes
        `x` - pixel X coordinate of the upper-left corner of the tile
        `y` - pixel Y coordinate of the upper-left corner of the tile
        `w` - width in pixels of the compressed tile
        `h` - height in pixels of the compressed tile
      Throws:
        `FormatException`
        `java.io.IOException`

    - #### saveBytes

          public void saveBytes(int no,
                                byte[] buf,
                                int x,
                                int y,
                                int w,
                                int h)
                         throws FormatException,
                                java.io.IOException

      Description copied from interface: `IFormatWriter`
      Saves the given image tile to the current series in the current file.
      Specified by:
        `saveBytes` in interface `IFormatWriter`
      Overrides:
        `saveBytes` in class `TiffWriter`
      Parameters:
        `no` - the plane index within the series.
        `buf` - the byte array that represents the image tile.
        `x` - the X coordinate of the upper-left corner of the image tile.
        `y` - the Y coordinate of the upper-left corner of the image tile.
        `w` - the width (in pixels) of the image tile.
        `h` - the height (in pixels) of the image tile.
      Throws:
        `FormatException` - if one of the parameters is invalid.
        `java.io.IOException` - if there was a problem writing to the file.
      See Also:
        `IFormatWriter.saveBytes(int, byte[], int, int, int, int)`

    - #### saveBytes

          public void saveBytes(int no,
                                byte[] buf,
                                IFD ifd,
                                int x,
                                int y,
                                int w,
                                int h)
                         throws FormatException,
                                java.io.IOException

      Description copied from class: `TiffWriter`
      Saves the given image to the specified series in the current file. The IFD hashtable allows specification of TIFF parameters such as bit depth, compression and units. Use one IFD instance per plane.
      Overrides:
        `saveBytes` in class `TiffWriter`
      Throws:
        `FormatException`
        `java.io.IOException`
      See Also:
        `IFormatWriter.saveBytes(int, byte[], int, int, int, int)`

    - #### setId

          public void setId(java.lang.String id)
                     throws FormatException,
                            java.io.IOException

      Description copied from class: `FormatWriter`
      Initializes a writer from the input file name. Initializes a `RandomAccessOutputStream` for the output file and initializes the metadata for all the series using `FormatWriter.setSeries(int)`.
      Specified by:
        `setId` in interface `IFormatHandler`
      Overrides:
        `setId` in class `TiffWriter`
      Parameters:
        `id` - a `String` specifying the path to the file
      Throws:
        `FormatException`
        `java.io.IOException`

    - #### getCompanion

          public java.lang.String getCompanion()

      Get the value of the `COMPANION_KEY` option.
      Returns:
        path to the companion file, or null if a companion file is not used

    - #### preserveCreator

          public boolean preserveCreator()

      Get the value of the `CREATOR_KEY` option. This toggles whether or not the OME Creator attribute will be overwritten with the current Bio-Formats version. For input data that does not have a Creator attribute defined, this makes no difference. By default, returns false, i.e. the Creator will be overwritten if it exists.
      Returns:
        true if the Creator attribute should be preserved (if it exists)

    - #### getUUID

          private java.lang.String getUUID(java.lang.String filename)

      Gets the UUID corresponding to the given filename.

    - #### setupServiceAndMetadata

          private void setupServiceAndMetadata()
                                        throws loci.common.services.DependencyException,
                                               loci.common.services.ServiceException

      Throws:
        `loci.common.services.DependencyException`
        `loci.common.services.ServiceException`

    - #### insertWarningComment

          private java.lang.String insertWarningComment(java.lang.String xml)

    - #### getOMEXML

          private java.lang.String getOMEXML(java.lang.String file)
                                      throws FormatException,
                                             java.io.IOException

      Throws:
        `FormatException`
        `java.io.IOException`

    - #### getBinaryOnlyOMEXML

          private java.lang.String getBinaryOnlyOMEXML(java.lang.String file,
                                                       java.lang.String companion,
                                                       java.lang.String companionUUID)
                                                throws FormatException,
                                                       java.io.IOException,
                                                       loci.common.services.DependencyException,
                                                       loci.common.services.ServiceException

      Throws:
        `FormatException`
        `java.io.IOException`
        `loci.common.services.DependencyException`
        `loci.common.services.ServiceException`

    - #### setCreator

          private void setCreator(ome.xml.meta.OMEXMLMetadataRoot root)

      Set the Creator attribute on the given OME-XML root object. If the Creator was not previously set, it will be set to the current Bio-Formats version. If the Creator has been set already, the `CREATOR_KEY` option (via `preserveCreator`) is used to determine whether to overwrite the existing value with the Bio-Formats version.
      Parameters:
        `root` - OME-XML root object

    - #### saveComment

          private void saveComment(java.lang.String file,
                                   java.lang.String xml)
                            throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### populateTiffData

          private void populateTiffData(OMEXMLMetadata omeMeta,
                                        int[] zct,
                                        int ifd,
                                        int series,
                                        int plane)

    - #### populateImage

          private void populateImage(OMEXMLMetadata omeMeta,
                                     int series)

    - #### planeCount

          private int planeCount()

Copyright © 2026 Open Microscopy Environment