Class TIFFMeta

java.lang.Object
pixy.meta.tiff.TIFFMeta

public class TIFFMeta
extends java.lang.Object
  • Field Details

  • Constructor Details

  • Method Details

    • extractICCProfile

      public static byte[] extractICCProfile​(int pageNumber, RandomAccessInputStream rin) throws java.lang.Exception
      Extracts ICC_Profile from certain page of TIFF if any
      Parameters:
      pageNumber - page number from which to extract ICC_Profile
      rin - RandomAccessInputStream for the input TIFF
      Returns:
      a byte array for the extracted ICC_Profile or null if none exists
      Throws:
      java.lang.Exception
    • extractICCProfile

      public static byte[] extractICCProfile​(RandomAccessInputStream rin) throws java.lang.Exception
      Throws:
      java.lang.Exception
    • extractThumbnail

      public static IRBThumbnail extractThumbnail​(int pageNumber, RandomAccessInputStream rin) throws java.io.IOException
      Throws:
      java.io.IOException
    • extractThumbnail

      public static IRBThumbnail extractThumbnail​(RandomAccessInputStream rin) throws java.io.IOException
      Throws:
      java.io.IOException
    • extractThumbnail

      public static void extractThumbnail​(RandomAccessInputStream rin, java.lang.String pathToThumbnail) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertComments

      public static void insertComments​(java.util.List<java.lang.String> comments, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertComments

      public static void insertComments​(java.util.List<java.lang.String> comments, int pageNumber, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertExif

      public static void insertExif​(RandomAccessInputStream rin, RandomAccessOutputStream rout, Exif exif, boolean update) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertExif

      public static void insertExif​(RandomAccessInputStream rin, RandomAccessOutputStream rout, Exif exif, int pageNumber, boolean update) throws java.io.IOException
      Insert EXIF data with optional thumbnail IFD
      Parameters:
      rin - input image stream
      rout - output image stream
      exif - EXIF wrapper instance
      pageNumber - page offset where to insert EXIF (zero based)
      update - True to keep the original data, otherwise false
      Throws:
      java.lang.Exception
      java.io.IOException
    • insertICCProfile

      public static void insertICCProfile​(byte[] icc_profile, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertICCProfile

      public static void insertICCProfile​(byte[] icc_profile, int pageNumber, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
      Insert ICC_Profile into TIFF page
      Parameters:
      icc_profile - byte array holding the ICC_Profile
      pageNumber - page offset where to insert ICC_Profile
      rin - RandomAccessInputStream for the input image
      rout - RandomAccessOutputStream for the output image
      Throws:
      java.lang.Exception
      java.io.IOException
    • insertIPTC

      public static void insertIPTC​(RandomAccessInputStream rin, RandomAccessOutputStream rout, java.util.Collection<IPTCDataSet> iptcs, boolean update) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertIPTC

      public static void insertIPTC​(RandomAccessInputStream rin, RandomAccessOutputStream rout, int pageNumber, java.util.Collection<IPTCDataSet> iptcs, boolean update) throws java.io.IOException
      Insert IPTC data into TIFF image. If the original TIFF image contains IPTC data, we either keep or override them depending on the input parameter "update."

      There is a possibility that IPTC data presents in more than one places such as a normal TIFF tag, or buried inside a Photoshop IPTC-NAA Image Resource Block (IRB), or even in a XMP block. Currently this method does the following thing: if no IPTC data was found from both Photoshop or normal IPTC tag, we insert the IPTC data with a normal IPTC tag. If IPTC data is found both as a Photoshop tag and a normal IPTC tag, depending on the "update" parameter, we will either delete the IPTC data from both places and insert the new IPTC data into the Photoshop tag or we will synchronize the two sets of IPTC data, delete the original IPTC from both places and insert the synchronized IPTC data along with the new IPTC data into the Photoshop tag. In both cases, we will keep the other IRBs from the original Photoshop tag unchanged.

      Parameters:
      rin - RandomAccessInputStream for the original TIFF
      rout - RandomAccessOutputStream for the output TIFF with IPTC inserted
      pageNumber - page offset where to insert IPTC
      iptcs - A list of IPTCDataSet to insert into the TIFF image
      update - whether we want to keep the original IPTC data or override it completely new IPTC data set
      Throws:
      java.io.IOException
    • insertIRB

      public static void insertIRB​(RandomAccessInputStream rin, RandomAccessOutputStream rout, java.util.Collection<_8BIM> bims, boolean update) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertIRB

      public static void insertIRB​(RandomAccessInputStream rin, RandomAccessOutputStream rout, int pageNumber, java.util.Collection<_8BIM> bims, boolean update) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertThumbnail

      public static void insertThumbnail​(RandomAccessInputStream rin, RandomAccessOutputStream rout, java.awt.image.BufferedImage thumbnail) throws java.io.IOException
      Insert a thumbnail into PHOTOSHOP private tag field
      Parameters:
      rin - RandomAccessInputStream for the input TIFF
      rout - RandomAccessOutputStream for the output TIFF
      thumbnail - a Bitmap to be inserted
      Throws:
      java.lang.Exception
      java.io.IOException
    • insertXMP

      public static void insertXMP​(XMP xmp, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertXMP

      public static void insertXMP​(XMP xmp, int pageNumber, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertXMP

      public static void insertXMP​(byte[] xmp, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
      Throws:
      java.io.IOException
    • insertXMP

      public static void insertXMP​(byte[] xmp, int pageNumber, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
      Insert XMP data into TIFF image
      Parameters:
      xmp - byte array for the XMP data to be inserted
      pageNumber - page offset where to insert XMP
      rin - RandomAccessInputStream for the input image
      rout - RandomAccessOutputStream for the output image
      Throws:
      java.io.IOException
    • insertXMP

      public static void insertXMP​(java.lang.String xmp, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
      Throws:
      java.io.IOException
    • printIFDs

      public static void printIFDs​(java.util.Collection<IFD> list, java.lang.String indent)
    • printIFD

      public static void printIFD​(IFD currIFD, java.lang.Class<? extends Tag> tagClass, java.lang.String indent)
    • readIFDs

      public static void readIFDs​(java.util.List<IFD> list, RandomAccessInputStream rin) throws java.io.IOException
      Throws:
      java.io.IOException
    • readMetadata

      public static java.util.Map<MetadataType,​Metadata> readMetadata​(RandomAccessInputStream rin) throws java.io.IOException
      Throws:
      java.io.IOException
    • readMetadata

      public static java.util.Map<MetadataType,​Metadata> readMetadata​(RandomAccessInputStream rin, int pageNumber) throws java.io.IOException
      Throws:
      java.io.IOException
    • removeMetadata

      public static java.util.Map<MetadataType,​Metadata> removeMetadata​(int pageNumber, RandomAccessInputStream rin, RandomAccessOutputStream rout, MetadataType... metadataTypes) throws java.io.IOException
      Remove meta data from TIFF image
      Parameters:
      rin - RandomAccessInputStream for the input image
      rout - RandomAccessOutputStream for the output image
      pageNumber - working page from which to remove metadata
      metadataTypes - a variable length array of MetadataType to be removed
      Returns:
      A map of the removed metadata
      Throws:
      java.io.IOException
    • removeMetadata

      public static java.util.Map<MetadataType,​Metadata> removeMetadata​(RandomAccessInputStream rin, RandomAccessOutputStream rout, MetadataType... metadataTypes) throws java.io.IOException
      Remove meta data from TIFF image
      Parameters:
      rin - RandomAccessInputStream for the input image
      rout - RandomAccessOutputStream for the output image
      metadataTypes - a variable length array of MetadataType to be removed
      Returns:
      A map of the removed metadata
      Throws:
      java.io.IOException
    • removeMetadata

      public static java.util.Map<MetadataType,​Metadata> removeMetadata​(java.util.Set<MetadataType> metadataTypes, int pageNumber, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
      Remove meta data from TIFF image
      Parameters:
      pageNumber - working page from which to remove EXIF and GPS data
      rin - RandomAccessInputStream for the input image
      rout - RandomAccessOutputStream for the output image
      Returns:
      A map of the removed metadata
      Throws:
      java.io.IOException
    • removeMetadata

      public static java.util.Map<MetadataType,​Metadata> removeMetadata​(java.util.Set<MetadataType> metadataTypes, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
      Remove meta data from TIFF image
      Parameters:
      metadataTypes - a set of MetadataType to be removed
      rin - RandomAccessInputStream for the input image
      rout - RandomAccessOutputStream for the output image
      Returns:
      A map of the removed metadata
      Throws:
      java.io.IOException
    • retainPages

      public static int retainPages​(int startPage, int endPage, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
      Throws:
      java.io.IOException
    • retainPages

      public static int retainPages​(RandomAccessInputStream rin, RandomAccessOutputStream rout, int... pages) throws java.io.IOException
      Throws:
      java.io.IOException
    • write

      public static void write​(TIFFImage tiffImage, RandomAccessOutputStream rout) throws java.io.IOException
      Throws:
      java.io.IOException