Class TiffEncoder

  • All Implemented Interfaces:

    public class TiffEncoder
    extends com.idrsolutions.image.JDeliImage
    implements com.idrsolutions.image.Encoder
    Class writes BufferedImages as Tiff Example 1 (single-page tiff):
     TiffEncoder encoder = new TiffEncoder();
     encoder.getEncoderOptions().setCompressionFormat(TiffCompressionFormat.DEFLATE); //default is NONE
     encoder.write(image, bos);
    Example 2 (multi-page tiff)
     TiffEncoder encoder = new TiffEncoder();
     for (BufferedImage image : yourImageArray) {
         encoder.append(image, fileName);
    • Constructor Detail

      • TiffEncoder

        public TiffEncoder()
    • Method Detail

      • write

        public void write​(BufferedImage image,
                          OutputStream outputStream)
                   throws IOException
        Writes BufferedImage as Tiff to OutputStream

        This method does not close the provided OutputStream after the write operation has completed; it is the responsibility of the caller to close the stream.

        Specified by:
        write in interface com.idrsolutions.image.Encoder
        image - BufferedImage The image to write
        outputStream - The stream to write to
        IOException - if the image wasn't written
      • append

        public void append​(BufferedImage image,
                           String fileName)
                    throws IOException
        Appends image to specified tiff file

        If the file is empty then this method will write the image to the file, otherwise it will append the image after previous image.

        image - BufferedImage The image to append
        fileName - The name of the file where the image will be written
        IOException - if the file is unreadable
      • isCompressed

        public boolean isCompressed()
        - use getEncoderOptions().getCompressionFormat().equals(TiffCompressionFormat.DEFLATE); Returns whether Deflate compression is enabled in tiff generation.
        Whether compression is enabled
      • setEncoderOptions

        public void setEncoderOptions​(TiffEncoderOptions tiffEncoderOptions)
      • setCompressed

        public void setCompressed​(boolean compress)
        - use tiffEncoderOptions.setCompressionFormat(TiffCompressionFormat tiffCompression); setEncoderOptions(tiffEncoderOptions);
        compress - value to determine if compression used
      • setXMPMetaData

        public void setXMPMetaData​(String xmpMetaData)
        - use tiffEncoderOptions.setXmpMetaData("string"); setEncoderOptions(tiffEncoderOptions);
        set XMP MetaData to be written on images;
        xmpMetaData - header data for Tiff file