Using Bio-Formats as a Java library =================================== Bio-Formats as a Maven, Gradle or Ivy dependency ------------------------------------------------ All released :file:`.jar` artifacts are published to and can be obtained from the `OME Artifactory `_. The "Client Settings" section of the Artifactory main page provides example code snippets for inclusion into your Gradle, Maven or Ivy project, which will enable the use of this repository. Examples of getting started with Bio-Formats using Maven or Gradle are given in the https://github.com/ome/bio-formats-examples repository. `OMERO `_ uses Ivy to manage its Java dependencies including Bio-Formats. .. note:: In order to retrieve the NetCDF dependency of Bio-Formats, it is necessary to configure the Unidata releases repository in addition to Maven Central and the OME artifactory in your :examples:`pom.xml`, :examples:`build.gradle` or :file:`ivy.xml` file. Bio-Formats as a Java library ----------------------------- Alternatively Bio-Formats can be used by including its component jar files. You can :downloads:`download formats-gpl.jar ` to use it as a library. Just add :file:`formats-gpl.jar` to your :envvar:`CLASSPATH` or build path. You will also need :file:`ome-common.jar` for common I/O functions, :file:`ome-xml.jar` for metadata standardization, and `SLF4J `_ for :doc:`logging`. Dependencies ^^^^^^^^^^^^ The complete list of current dependencies is as follows: .. list-table:: :header-rows: 1 * - Package - Maven name - License * - `Logback Classic v1.1.1 `_ - ch.qos.logback:logback-classic:1.1.1 - `Eclipse Public License v1.0`_ * - `Logback Core v1.1.1 `_ - ch.qos.logback:logback-core:1.1.1 - `Eclipse Public License v1.0`_ * - `JHDF5 v14.12.6 `_ - cisd:jhdf5:14.12.6 - `Apache License v2.0`_ * - `XMP Library for Java v5.1.2 `_ - com.adobe.xmp:xmpcore:5.1.2 - `BSD License`_ * - `JCommander v1.27 `_ - com.beust:jcommander:1.27 - `Apache License v2.0`_ * - `metadata-extractor v2.11.0 `_ - com.drewnoakes:metadata-extractor:2.11.0 - `Apache License v2.0`_ * - `Kryo v2.24.0 `_ - com.esotericsoftware.kryo:kryo:2.24.0 - `BSD License`_ * - `MinLog v1.2 `_ - com.esotericsoftware.minlog:minlog:1.2 - `BSD License`_ * - `Guava v27.1 `_ - com.google.guava:guava:27.1-jre - `Apache License v2.0`_ * - `JGoodies Common v1.7.0 `_ - com.jgoodies:jgoodies-common:1.7.0 - `BSD License`_ * - `JGoodies Forms v1.7.2 `_ - com.jgoodies:jgoodies-forms:1.7.2 - `BSD License`_ * - `Commons Collections v3.2.1 `_ - commons-collections:commons-collections:3.2.1 - `Apache License v2.0`_ * - `Commons Lang v2.4 `_ - commons-lang:commons-lang:2.4 - `Apache License v2.0`_ * - `Commons Logging v1.1.1 `_ - commons-logging:commons-logging:1.1.1 - `Apache License v2.0`_ * - `NetCDF-Java Library v4.6.13 `_ - edu.ucar:netcdf:4.6.13 - `MIT-Style License`_ * - `Joda time v2.2 `_ - joda-time:joda-time:2.2 - `Apache License v2.0`_ * - `JUnit v4.10 `_ - junit:junit:4.10 - `Common Public License v1.0`_ * - `Apache Log4j v1.2.17 `_ - log4j:log4j:1.2.17 - `Apache License v2.0`_ * - `ImageJ v1.48s `_ - net.imagej:ij:1.48s - Public domain * - `Assume NG v1.2.4 `_ - nl.javadude.assumeng:assumeng:1.2.4 - `Apache License v2.0`_ * - `Apache Velocity v1.6.4 `_ - org.apache.velocity:velocity:1.6.4 - `Apache License v2.0`_ * - `BeanShell v2.0b4 `_ - org.beanshell:bsh:2.0b4 - `Sun Public License / LGPL`_ * - `Hamcrest Core v1.1 `_ - org.hamcrest:hamcrest-core:1.1 - `BSD 3-Clause`_ * - `Objenesis v2.1 `_ - org.objenesis:objenesis:2.1 - `Apache License v2.0`_ * - `Perf4J v0.9.16 `_ - org.perf4j:perf4j:0.9.16 - `Apache License v2.0`_ * - `Native Library Loader v2.1.4 `_ - org.scijava:native-lib-loader:2.1.4 - `BSD License`_ * - `SLF4J API v1.7.4 `_ - org.slf4j:slf4j-api:1.7.6 - `MIT License`_ * - `SLF4J LOG4J-12 Binding v1.7.6 `_ - org.slf4j:slf4j-log4j12:1.7.6 - `MIT License`_ * - `TestNG v6.8 `_ - org.testng:testng:6.8 - `Apache License v2.0`_ * - `SnakeYAML v1.6 `_ - org.yaml:snakeyaml:1.6 - `Apache License v2.0`_ * - `Jakarta ORO v2.0.8 `_ - oro:oro:2.0.8 - `Apache License v2.0`_ * - `Woolz v1.4.0 `_ - woolz:JWlz:1.4.0 - `GPL v2`_ * - `Xalan Java Serializer v2.7.2 `_ - xalan:serializer:2.7.2 - `Apache License v2.0`_ * - `Xalan Java v2.7.2 `_ - xalan:xalan:2.7.2 - `Apache License v2.0`_ * - `Xerces2 Java Parser v2.8.1 `_ - xerces:xercesImpl:2.8.1 - `Apache License v2.0`_ * - `XML Commons External Components XML APIs v1.3.04 `_ - xml-apis:xml-apis:1.3.04 - `Apache License v2.0`_ As described in :ref:`versioning-policy`, the minor version number of a Bio-Formats release will always be increased if the version of a non-OME/external dependency is bumped. .. _Apache License v2.0: https://spdx.org/licenses/Apache-2.0.html .. _MIT License: https://spdx.org/licenses/MIT.html .. _BSD 3-Clause: https://spdx.org/licenses/BSD-3-Clause.html .. _Sun Public License / LGPL: http://www.beanshell.org/license.html .. _Common Public License v1.0: https://spdx.org/licenses/CPL-1.0.html .. _MIT-Style License: https://github.com/Unidata/thredds/blob/v4.3.22/cdm/license.txt .. _BSD License: https://spdx.org/licenses/BSD-2-Clause.html .. _Eclipse Public License v1.0: https://spdx.org/licenses/EPL-1.0.html .. _GPL v2: https://spdx.org/licenses/GPL-2.0.html Examples of usage ----------------- File reading and performance: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :source:`MultiFileExample ` - Simple example of how to open multiple files simultaneously. :source:`ParallelRead ` - Reads all files in given directory in parallel, using a separate thread for each. :doc:`ReadWriteInMemory ` - Tests the Bio-Formats I/O logic to and from byte arrays in memory. :java_examples:`OrthogonalReader ` - Reads image data in XZ and YZ order. File writing: ^^^^^^^^^^^^^ :source:`MinimumWriter ` - A command line utility demonstrating the minimum amount of metadata needed to write a file. :java_examples:`FileExport ` - Write a file in any supported output format. :source:`TiledExport ` - Shows how to convert a file one tile at a time, instead of one plane at a time (needed for very large images). :java_examples:`FileExportSPW ` - Write a file with plate (OME SPW) metadata. File compression: ^^^^^^^^^^^^^^^^^ :source:`makeLZW ` - Converts the given image file to an LZW-compressed TIFF. Metadata extract/print: ^^^^^^^^^^^^^^^^^^^^^^^ :source:`GetPhysicalMetadata ` - Uses Bio-Formats to extract some basic standardized (format-independent) metadata. :java_examples:`ReadPhysicalSize ` - Reads physical size information uses the units API to display in micrometers. :source:`ImageInfo ` - A more involved command line utility for thoroughly reading an input file, printing some information about it, and displaying the pixels onscreen using the Bio-Formats viewer. :source:`PrintTimestamps ` - A command line example demonstrating how to extract timestamps from a file. :source:`PrintLensNA ` - Uses Bio-Formats to extract lens numerical aperture in a format-independent manner from a dataset. :source:`PrintROIs ` - A simple example of how to retrieve ROI data parsed from a file. :java_examples:`SubResolutionExample ` - Demonstration of the sub-resolution API. Metadata add/edit: ^^^^^^^^^^^^^^^^^^ :source:`EditImageName ` - Edits the given file's image name (but does not save back to disk). :source:`EditTiffComment ` - Allows raw user TIFF comment editing for the given TIFF files. :source:`writeMapAnnotations ` - Example method to write MapAnnotations to the ome-xml. :source:`CommentSurgery ` - Edits a TIFF ImageDescription comment, particularly the OME-XML comment found in OME-TIFF files. Image converters: ^^^^^^^^^^^^^^^^^ :source:`ImageConverter ` - A simple command line tool for converting between formats. :java_examples:`FileConvert ` - Converts a file in any supported format to any supported output format. :source:`ConvertToOmeTiff ` - Converts the given files to OME-TIFF format. :source:`WritePreCompressedPlanes ` - Writes the pixels from a set of JPEG files to a single TIFF. The pixel data is used as-is, so no decompression or re-compression is performed. :java_examples:`GeneratePyramidResolutions ` - Convert a file containing a single large image to a pyramid OME-TIFF. :java_examples:`TiledReaderWriter ` - Convert a file to OME-TIFF one tile at a time. :java_examples:`OverlappedTiledWriter ` - Convert a file to OME-TIFF one tile at a time, when the image size is not a multiple of the tile size. :java_examples:`SimpleTiledWriter ` - Convert a file to OME-TIFF using automatic tiling. ImageJ plugins: ^^^^^^^^^^^^^^^ :source:`Simple_Read ` - A simple ImageJ plugin demonstrating how to use Bio-Formats to read files into ImageJ (see :doc:`/users/imagej/index`). :source:`Read_Image ` - An ImageJ plugin that uses Bio-Formats to build up an image stack, reading image planes one by one (see :doc:`/users/imagej/index`). :source:`Mass_Importer ` - A simple plugin for ImageJ that demonstrates how to open all image files in a directory using Bio-Formats, grouping files with similar names to avoiding opening the same dataset more than once (see :doc:`/users/imagej/index`). Image processing utilities: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ :source:`SewTiffs ` - Stitches the first plane from a collection of TIFFs into a single file. :source:`SumPlanes ` - Sums together the image planes from the given file,and saves the result to a 16-bit TIFF. A Note on Java Web Start (bioformats\_package.jar vs. formats-gpl.jar) ---------------------------------------------------------------------- To use Bio-Formats with your Java Web Start application, we recommend using **formats-gpl.jar** rather than **bioformats\_package.jar**—the latter is merely a bundle of **formats-gpl.jar** plus all its optional dependencies. The **bioformats\_package.jar** bundle is intended as a convenience (e.g. to simplify installation as an ImageJ plugin), but is by no means the only solution for developers. We recommend using **formats-gpl.jar** as a separate entity depending on your needs as a developer. The bundle is quite large because we have added support for several formats that need large helper libraries (e.g. Imaris' HDF-based format). However, these additional libraries are optional; Bio-Formats has been coded using reflection so that it can both compile and run without them. When deploying a JNLP-based application, using **bioformats\_package.jar** directly is not the best approach, since every time Bio-Formats is updated, the server would need to feed another 15+ MB JAR file to the client. Rather, Web Start is a case where you should keep the JARs separate, since JNLP was designed to make management of JAR dependencies trivial for the end user. By keeping **formats-gpl.jar** and the optional dependencies separate, only a <1 MB JAR needs to be updated when **formats-gpl.jar** changes. As a developer, you have the option of packaging **formats-gpl.jar** with as many or as few optional libraries as you wish, to cut down on file size as needed. You are free to make whatever kind of "stripped down" version you require. You could even build a custom **formats-gpl.jar** that excludes certain classes, if you like.