Interface ImageExporter


public interface ImageExporter
ImageExporters are used to generate linear sequences of images-as-rendered by a DisplayWindow. They include the current image scaling, any overlays, etc.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    Allowed export formats.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Run the export process.
    loop(String axis, int start, int stop)
    Add a new "inner loop" to the export parameters.
    void
    Reset the current export loop parameters to empty.
    void
    Set the display to use for image exporting.
    default void
    setFfmpegPath(String ffmpegPath)
    Set the path to the ffmpeg executable.
    void
    setImageJName(String imageJName)
    Sets the name to be used for the ImageJ Stack Window (if this was used as the output format).
    void
    Set the output format to use.
    void
    setOutputQuality(int quality)
    Set the image quality.
    void
    setSaveInfo(String path, String prefix)
    Set the path to save images to, and the filename prefix to use when saving images.
    void
    setUseLabel(boolean label)
    Whether to use labels indicating position, channel, time point and z position (where) appropriate or to sequentially number output files.
    void
    Block until a prior call to export() returns.
  • Method Details

    • setDisplay

      void setDisplay(DisplayWindow display)
      Set the display to use for image exporting. The same ImageExporter may be re-used for multiple displays, if desired.
      Parameters:
      display - Display to use for exporting images.
    • setOutputFormat

      void setOutputFormat(ImageExporter.OutputFormat format)
      Set the output format to use.
      Parameters:
      format - The format to output in.
    • setUseLabel

      void setUseLabel(boolean label)
      Whether to use labels indicating position, channel, time point and z position (where) appropriate or to sequentially number output files.
      Parameters:
      label - When true, filename will include position, channel, time point and z position labels (where appropriate).
    • setOutputQuality

      void setOutputQuality(int quality)
      Set the image quality. This is currently only relevant if the output format is OUTPUT_JPG or OUTPUT_MOVIE.
      Parameters:
      quality - An integer quality ranging from 1 through 100. The default value is 90.
    • setFfmpegPath

      default void setFfmpegPath(String ffmpegPath)
      Set the path to the ffmpeg executable. Required when the output format is OUTPUT_MOVIE. Ignored for other formats.

      This method has a default no-op implementation so that existing implementations of this interface remain source- and binary-compatible.

      Parameters:
      ffmpegPath - Absolute path to the ffmpeg binary.
    • setSaveInfo

      void setSaveInfo(String path, String prefix) throws IOException
      Set the path to save images to, and the filename prefix to use when saving images. These values are ignored if the output format is set to OUTPUT_IMAGEJ.
      Parameters:
      path - Directory in which images will be placed
      prefix - String to place at beginning of each output image's name.
      Throws:
      IllegalArgumentException - if the directory does not exist.
      IOException
    • setImageJName

      void setImageJName(String imageJName)
      Sets the name to be used for the ImageJ Stack Window (if this was used as the output format). Only used when output format is set to OUTPUT_IMAGEJ
      Parameters:
      imageJName - Name to be used in ImageJ
    • loop

      ImageExporter loop(String axis, int start, int stop)
      Add a new "inner loop" to the export parameters. This determines what order the images will be output in. For example: exporter.loop(Coords.Z, 0, 10).loop(Coords.CHANNEL, 0, 2) This will cause the channel axis to be the "inner loop", changing most frequently, and the Z axis to be the "outer loop", changing least frequently.
      Parameters:
      axis - Axis name, like Coords.CHANNEL, Coords.Z, etc.
      start - Axis index to start exporting from, inclusive.
      stop - Axis index to stop exporting from, exclusive (i.e. one more than the index of the last image you want to export).
      Returns:
      This instance, allowing calls to be chained together.
    • resetLoops

      void resetLoops()
      Reset the current export loop parameters to empty.
    • export

      void export() throws IOException, IllegalArgumentException
      Run the export process. This will generate the image sequence as configured previously by calling setOutputFormat, setSaveInfo, and loop. Only one export is allowed to run at a time; if a second export is started, it will block until the first has finished. Otherwise, this method will return immediately. If you want to wait for exporting to finish, call the waitForExport() method.

      NOTE: the exporter will silently ignore the following "configuration errors": - Setting a save path when using the OUTPUT_IMAGEJ format - Loops over axes that are not used by any images in the display's datastore - Loops that have invalid start/end boundary conditions (starting or ending index is greater than largest index in the datastore). In the latter two cases, image coordinates that do not refer to a valid image will be ignored (for example, trying to access a Z coordinate of 1 in a dataset that is two-dimensional). It is therefore possible that this method will not actually do anything, if none of the loops encompass valid image coordinates.

      Throws:
      IOException - if the export process would attempt to write to a file that already exists
      IllegalArgumentException - if no output format has been set, or OUTPUT_PNG or OUTPUT_JPG formats are used but no save information has been set, or if no loops have been configured, or if no display has been set.
    • waitForExport

      void waitForExport() throws InterruptedException
      Block until a prior call to export() returns. Returns immediately if no export is currently running.
      Throws:
      InterruptedException - if the thread was interrupted while waiting.