Class TiffEncoder


  • public class TiffEncoder
    extends com.idrsolutions.image.JDeliImage
    Class writes BufferedImages as Tiff

    Example 1 (single-page tiff):

    
     TiffEncoder encoder = new TiffEncoder();
     encoder.setCompress(true); //default is false
     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.

        Parameters:
        image - BufferedImage The image to write
        outputStream - The stream to write to
        Throws:
        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.

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

        public boolean isCompressed()
        Returns whether Deflate compression is enabled in tiff generation.
        Returns:
        Whether compression is enabled
      • setCompressed

        public void setCompressed​(boolean compress)
        Set true to enable Deflate compression in tiff generation
        Parameters:
        compress - If compression should be enabled
      • setXMPMetaData

        public void setXMPMetaData​(String xmpMetaData)
        set XMP MetaData to be written on images;
        Parameters:
        xmpMetaData -