Module ij
Package ij.io

Class Opener

java.lang.Object
ij.io.Opener

public class Opener
extends java.lang.Object
Opens tiff (and tiff stacks), dicom, fits, pgm, jpeg, bmp or gif images, and look-up tables, using a file open dialog or a path. Calls HandleExtraFileTypes plugin if the file type is unrecognised.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static int AVI  
    static int BMP  
    static int CUSTOM  
    static int DICOM  
    static int FITS  
    static int GIF  
    static int JAVA_OR_TEXT  
    static int JPEG  
    static int LUT  
    static int OJJ  
    static int PGM  
    static int PNG  
    static int RAW  
    static int ROI  
    static int TABLE  
    static int TEXT  
    static int TIFF  
    static int TIFF_AND_DICOM  
    static java.lang.String[] types  
    static int UNKNOWN  
    static int ZIP  
  • Constructor Summary

    Constructors 
    Constructor Description
    Opener()  
  • Method Summary

    Modifier and Type Method Description
    static void convertGrayJpegTo8Bits​(ImagePlus imp)
    Converts the specified RGB image to 8-bits if the 3 channels are identical.
    ImagePlus deserialize​(byte[] bytes)
    Deserialize a byte array that was serialized using the FileSaver.serialize().
    java.lang.String getDir​(java.lang.String path)  
    static java.lang.String getFileFormat​(java.lang.String path)  
    int getFileType​(java.lang.String path)
    Attempts to determine the image file type by looking for 'magic numbers' and the file name extension.
    static java.lang.String getLoadRate​(double time, ImagePlus imp)  
    java.lang.String getName​(java.lang.String path)  
    static boolean getOpenUsingPlugins()
    Returns the state of the openUsingPlugins flag.
    static FileInfo[] getTiffFileInfo​(java.lang.String path)
    Returns the FileInfo of the specified TIFF file.
    static boolean isFullPath​(java.lang.String path)  
    static java.lang.String makeFullPath​(java.lang.String path)  
    void open()
    Displays a file open dialog box and then opens the tiff, dicom, fits, pgm, jpeg, bmp, gif, lut, roi, or text file selected by the user.
    void open​(java.lang.String path)
    Opens and displays the specified tiff, dicom, fits, pgm, jpeg, bmp, gif, lut, roi, or text file.
    boolean openAndAddToRecent​(java.lang.String path)
    Opens the specified file and adds it to the File/Open Recent menu.
    ImagePlus openImage​(java.lang.String path)
    Opens, but does not display, the specified image file and returns an ImagePlus object object if successful, or returns null if the file is not in a supported format or is not found.
    ImagePlus openImage​(java.lang.String path, int n)
    Open the nth image of the specified tiff stack.
    ImagePlus openImage​(java.lang.String directory, java.lang.String name)
    Attempts to open the specified file as a tiff, bmp, dicom, fits, pgm, gif or jpeg image.
    static LUT openLut​(java.lang.String filePathOrUrl)
    Opens a lookup table (LUT) and returns it as a LUT object, or returns null if there is an error.
    void openMultiple()
    Displays a JFileChooser and then opens the tiff, dicom, fits, pgm, jpeg, bmp, gif, lut, roi, or text files selected by the user.
    static void openResultsTable​(java.lang.String path)
    Opens a tab or comma delimited text file in the Results window.
    Roi openRoi​(java.lang.String path)
    Attempts to open the specified ROI, returning null if unsuccessful.
    static void openTable​(java.lang.String path)
    Opens a tab or comma delimited text file.
    ImagePlus openTextImage​(java.lang.String dir, java.lang.String name)
    Opens the specified text file as a float image.
    ImagePlus openTiff​(java.io.InputStream in, java.lang.String name)
    Attempts to open the specified inputStream as a TIFF, returning an ImagePlus object if successful.
    ImagePlus openTiff​(java.lang.String path, int n)
    Opens the nth image of the specified TIFF stack.
    ImagePlus openTiff​(java.lang.String directory, java.lang.String name)
    Attempts to open the specified file as a tiff.
    ImagePlus openTiffStack​(FileInfo[] info)
    Attemps to open a tiff file as a stack.
    ImagePlus openURL​(java.lang.String url)
    Attempts to open the specified url as a tiff, zip compressed tiff, dicom, gif or jpeg.
    static ImagePlus openUsingBioFormats​(java.lang.String path)
    Opens an image file using the Bio-Formats plugin.
    ImagePlus openWithHandleExtraFileTypes​(java.lang.String path, int[] fileTypes)  
    ImagePlus openZip​(java.lang.String path)
    Opens a single TIFF or DICOM contained in a ZIP archive, or a ZIPed collection of ".roi" files created by the ROI manager.
    static void setOpenUsingPlugins​(boolean b)
    Open all images using HandleExtraFileTypes.
    void setSilentMode​(boolean mode)
    The "Opening: path" status message is not displayed in silent mode.
    static java.lang.String updateUrl​(java.lang.String url)
    Can't open imagej.nih.gov URLs due to encryption so redirect to imagej.net mirror.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • open

      public void open()
      Displays a file open dialog box and then opens the tiff, dicom, fits, pgm, jpeg, bmp, gif, lut, roi, or text file selected by the user. Displays an error message if the selected file is not in a supported format. This is the method that ImageJ's File/Open command uses to open files.
      See Also:
      IJ.open(), IJ.open(String), IJ.openImage(), IJ.openImage(String)
    • open

      public void open​(java.lang.String path)
      Opens and displays the specified tiff, dicom, fits, pgm, jpeg, bmp, gif, lut, roi, or text file. Displays an error message if the file is not in a supported format.
      See Also:
      IJ.open(String), IJ.openImage(String)
    • openMultiple

      public void openMultiple()
      Displays a JFileChooser and then opens the tiff, dicom, fits, pgm, jpeg, bmp, gif, lut, roi, or text files selected by the user. Displays error messages if one or more of the selected files is not in one of the supported formats. This is the method that ImageJ's File/Open command uses to open files if "Open/Save Using JFileChooser" is checked in EditOptions/Misc.
    • openImage

      public ImagePlus openImage​(java.lang.String path)
      Opens, but does not display, the specified image file and returns an ImagePlus object object if successful, or returns null if the file is not in a supported format or is not found. Displays a file open dialog if 'path' is null or an empty string.
      See Also:
      IJ.openImage(String), IJ.openImage()
    • openImage

      public ImagePlus openImage​(java.lang.String path, int n)
      Open the nth image of the specified tiff stack.
      See Also:
      IJ.openImage(String,int)
    • getLoadRate

      public static java.lang.String getLoadRate​(double time, ImagePlus imp)
    • makeFullPath

      public static java.lang.String makeFullPath​(java.lang.String path)
    • isFullPath

      public static boolean isFullPath​(java.lang.String path)
    • openAndAddToRecent

      public boolean openAndAddToRecent​(java.lang.String path)
      Opens the specified file and adds it to the File/Open Recent menu. Returns true if the file was opened successfully.
    • openImage

      public ImagePlus openImage​(java.lang.String directory, java.lang.String name)
      Attempts to open the specified file as a tiff, bmp, dicom, fits, pgm, gif or jpeg image. Returns an ImagePlus object if successful. Modified by Gregory Jefferis to call HandleExtraFileTypes plugin if the file type is unrecognised.
      See Also:
      IJ.openImage(String)
    • openTextImage

      public ImagePlus openTextImage​(java.lang.String dir, java.lang.String name)
      Opens the specified text file as a float image.
    • openURL

      public ImagePlus openURL​(java.lang.String url)
      Attempts to open the specified url as a tiff, zip compressed tiff, dicom, gif or jpeg. Tiff file names must end in ".tif", ZIP file names must end in ".zip" and dicom file names must end in ".dcm". Returns an ImagePlus object if successful.
      See Also:
      IJ.openImage(String)
    • updateUrl

      public static java.lang.String updateUrl​(java.lang.String url)
      Can't open imagej.nih.gov URLs due to encryption so redirect to imagej.net mirror.
    • openWithHandleExtraFileTypes

      public ImagePlus openWithHandleExtraFileTypes​(java.lang.String path, int[] fileTypes)
    • convertGrayJpegTo8Bits

      public static void convertGrayJpegTo8Bits​(ImagePlus imp)
      Converts the specified RGB image to 8-bits if the 3 channels are identical.
    • openTiffStack

      public ImagePlus openTiffStack​(FileInfo[] info)
      Attemps to open a tiff file as a stack. Returns an ImagePlus object if successful.
    • openTiff

      public ImagePlus openTiff​(java.lang.String directory, java.lang.String name)
      Attempts to open the specified file as a tiff. Returns an ImagePlus object if successful.
    • openTiff

      public ImagePlus openTiff​(java.lang.String path, int n)
      Opens the nth image of the specified TIFF stack.
    • getTiffFileInfo

      public static FileInfo[] getTiffFileInfo​(java.lang.String path)
      Returns the FileInfo of the specified TIFF file.
    • openTiff

      public ImagePlus openTiff​(java.io.InputStream in, java.lang.String name)
      Attempts to open the specified inputStream as a TIFF, returning an ImagePlus object if successful.
    • openZip

      public ImagePlus openZip​(java.lang.String path)
      Opens a single TIFF or DICOM contained in a ZIP archive, or a ZIPed collection of ".roi" files created by the ROI manager.
    • deserialize

      public ImagePlus deserialize​(byte[] bytes)
      Deserialize a byte array that was serialized using the FileSaver.serialize().
    • getName

      public java.lang.String getName​(java.lang.String path)
    • getDir

      public java.lang.String getDir​(java.lang.String path)
    • openRoi

      public Roi openRoi​(java.lang.String path)
      Attempts to open the specified ROI, returning null if unsuccessful.
    • openUsingBioFormats

      public static ImagePlus openUsingBioFormats​(java.lang.String path)
      Opens an image file using the Bio-Formats plugin.
    • openLut

      public static LUT openLut​(java.lang.String filePathOrUrl)
      Opens a lookup table (LUT) and returns it as a LUT object, or returns null if there is an error.
      See Also:
      ImagePlus.setLut(ij.process.LUT)
    • openResultsTable

      public static void openResultsTable​(java.lang.String path)
      Opens a tab or comma delimited text file in the Results window.
    • openTable

      public static void openTable​(java.lang.String path)
      Opens a tab or comma delimited text file.
    • getFileFormat

      public static java.lang.String getFileFormat​(java.lang.String path)
    • getFileType

      public int getFileType​(java.lang.String path)
      Attempts to determine the image file type by looking for 'magic numbers' and the file name extension.
    • setSilentMode

      public void setSilentMode​(boolean mode)
      The "Opening: path" status message is not displayed in silent mode.
    • setOpenUsingPlugins

      public static void setOpenUsingPlugins​(boolean b)
      Open all images using HandleExtraFileTypes. Set from a macro using setOption("openUsingPlugins", true).
    • getOpenUsingPlugins

      public static boolean getOpenUsingPlugins()
      Returns the state of the openUsingPlugins flag.