- java.lang.Object
-
- ij.io.FileSaver
-
public class FileSaver extends Object
Saves images in tiff, gif, jpeg, raw, zip and text format.
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_JPEG_QUALITY
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetDescriptionString()Returns a string containing information about the specified image.static intgetJpegQuality()Returns the current JPEG quality setting (0-100).static byte[][]getOverlay(ImagePlus imp)static booleanokForFits(ImagePlus imp)static booleanokForGif(ImagePlus imp)static booleanokForJpeg(ImagePlus imp)Always returns true.booleansave()Resaves the image.booleansaveAsBmp()Save the image in BMP format using a save file dialog.booleansaveAsBmp(String path)Save the image in BMP format using the specified path.booleansaveAsFits()Save the image in FITS format using a save file dialog.booleansaveAsFits(String path)Save the image in FITS format using the specified path.booleansaveAsGif()Save the image in GIF format using a save file dialog.booleansaveAsGif(String path)Save the image in Gif format using the specified path.booleansaveAsJpeg()Save the image in JPEG format using a save file dialog.booleansaveAsJpeg(String path)Save the image in JPEG format using the specified path.booleansaveAsLut()Save the current LUT using a save file dialog.booleansaveAsLut(String path)Save the current LUT using the specified path.booleansaveAsPgm()Saves grayscale images in PGM (portable graymap) format and RGB images in PPM (portable pixmap) format, using a save file dialog.booleansaveAsPgm(String path)Saves grayscale images in PGM (portable graymap) format and RGB images in PPM (portable pixmap) format, using the specified path.booleansaveAsPng()Save the image in PNG format using a save file dialog.booleansaveAsPng(String path)Save the image in PNG format using the specified path.booleansaveAsRaw()Save the image or stack as raw data using a save file dialog.booleansaveAsRaw(String path)Save the image as raw data using the specified path.booleansaveAsRawStack(String path)Save the stack as raw data using the specified path.booleansaveAsText()Save the image as comma or tab-delimited text using a save file dialog.booleansaveAsText(String path)Save the image as tab-delimited text using the specified path.booleansaveAsTiff()Saves the image or stack in TIFF format using a save file dialog.booleansaveAsTiff(String path)Saves the image in TIFF format using the specified path.booleansaveAsTiffStack(String path)Saves the stack as a multi-image TIFF using the specified path.booleansaveAsZip()Uses a save file dialog to save the image or stack as a TIFF in a ZIP archive.booleansaveAsZip(String path)Save the image or stack in TIFF/ZIP format using the specified path.voidsaveDisplayRangesAndLuts(ImagePlus imp, FileInfo fi)byte[]serialize()Converts this image to a TIFF encoded array of bytes, which can be decoded using Opener.deserialize().static voidsetBufferSize(int bufferSize)Sets the BufferedOutputStream buffer size in bytes (default is 32K).static voidsetJpegQuality(int quality)Specifies the image quality (0-100).voidupdateImagePlus(String path, int fileFormat)
-
-
-
Field Detail
-
DEFAULT_JPEG_QUALITY
public static final int DEFAULT_JPEG_QUALITY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FileSaver
public FileSaver(ImagePlus imp)
Constructs a FileSaver from an ImagePlus.
-
-
Method Detail
-
save
public boolean save()
Resaves the image. Calls saveAsTiff() if this is a new image, not a TIFF, or if the image was loaded using a URL. Returns false if saveAsTiff() is called and the user selects cancel in the file save dialog box.
-
saveAsTiff
public boolean saveAsTiff()
Saves the image or stack in TIFF format using a save file dialog. Returns false if the user selects cancel. Equivalent to IJ.saveAsTiff(imp,""), which is more convenient.
-
saveAsTiff
public boolean saveAsTiff(String path)
Saves the image in TIFF format using the specified path. Equivalent to IJ.saveAsTiff(imp,path), which is more convenient.
-
getOverlay
public static byte[][] getOverlay(ImagePlus imp)
-
saveAsTiffStack
public boolean saveAsTiffStack(String path)
Saves the stack as a multi-image TIFF using the specified path. Equivalent to IJ.saveAsTiff(imp,path), which is more convenient.
-
serialize
public byte[] serialize()
Converts this image to a TIFF encoded array of bytes, which can be decoded using Opener.deserialize().
-
saveAsZip
public boolean saveAsZip()
Uses a save file dialog to save the image or stack as a TIFF in a ZIP archive. Returns false if the user selects cancel.
-
saveAsZip
public boolean saveAsZip(String path)
Save the image or stack in TIFF/ZIP format using the specified path.
-
okForGif
public static boolean okForGif(ImagePlus imp)
-
saveAsGif
public boolean saveAsGif()
Save the image in GIF format using a save file dialog. Returns false if the user selects cancel or the image is not 8-bits.
-
saveAsGif
public boolean saveAsGif(String path)
Save the image in Gif format using the specified path. Returns false if the image is not 8-bits or there is an I/O error.
-
okForJpeg
public static boolean okForJpeg(ImagePlus imp)
Always returns true.
-
saveAsJpeg
public boolean saveAsJpeg()
Save the image in JPEG format using a save file dialog. Returns false if the user selects cancel.- See Also:
setJpegQuality(int),getJpegQuality()
-
saveAsJpeg
public boolean saveAsJpeg(String path)
Save the image in JPEG format using the specified path.- See Also:
setJpegQuality(int),getJpegQuality()
-
saveAsBmp
public boolean saveAsBmp()
Save the image in BMP format using a save file dialog. Returns false if the user selects cancel.
-
saveAsBmp
public boolean saveAsBmp(String path)
Save the image in BMP format using the specified path.
-
saveAsPgm
public boolean saveAsPgm()
Saves grayscale images in PGM (portable graymap) format and RGB images in PPM (portable pixmap) format, using a save file dialog. Returns false if the user selects cancel.
-
saveAsPgm
public boolean saveAsPgm(String path)
Saves grayscale images in PGM (portable graymap) format and RGB images in PPM (portable pixmap) format, using the specified path.
-
saveAsPng
public boolean saveAsPng()
Save the image in PNG format using a save file dialog. Returns false if the user selects cancel.
-
saveAsPng
public boolean saveAsPng(String path)
Save the image in PNG format using the specified path.
-
saveAsFits
public boolean saveAsFits()
Save the image in FITS format using a save file dialog. Returns false if the user selects cancel.
-
saveAsFits
public boolean saveAsFits(String path)
Save the image in FITS format using the specified path.
-
okForFits
public static boolean okForFits(ImagePlus imp)
-
saveAsRaw
public boolean saveAsRaw()
Save the image or stack as raw data using a save file dialog. Returns false if the user selects cancel.
-
saveAsRaw
public boolean saveAsRaw(String path)
Save the image as raw data using the specified path.
-
saveAsRawStack
public boolean saveAsRawStack(String path)
Save the stack as raw data using the specified path.
-
saveAsText
public boolean saveAsText()
Save the image as comma or tab-delimited text using a save file dialog. Returns false if the user selects cancel.
-
saveAsText
public boolean saveAsText(String path)
Save the image as tab-delimited text using the specified path.
-
saveAsLut
public boolean saveAsLut()
Save the current LUT using a save file dialog. Returns false if the user selects cancel.
-
saveAsLut
public boolean saveAsLut(String path)
Save the current LUT using the specified path.
-
updateImagePlus
public void updateImagePlus(String path, int fileFormat)
-
getDescriptionString
public String getDescriptionString()
Returns a string containing information about the specified image.
-
setJpegQuality
public static void setJpegQuality(int quality)
Specifies the image quality (0-100). 0 is poorest image quality, highest compression, and 100 is best image quality, lowest compression.
-
getJpegQuality
public static int getJpegQuality()
Returns the current JPEG quality setting (0-100).
-
setBufferSize
public static void setBufferSize(int bufferSize)
Sets the BufferedOutputStream buffer size in bytes (default is 32K).
-
-