Class TIFFMeta
public class TIFFMeta
extends java.lang.Object
-
Field Summary
Fields Modifier and Type Field Description static intFIRST_WRITE_OFFSETstatic intOFFSET_TO_WRITE_FIRST_IFD_OFFSETstatic intSTREAM_HEAD -
Constructor Summary
Constructors Constructor Description TIFFMeta() -
Method Summary
Modifier and Type Method Description static byte[]extractICCProfile(int pageNumber, RandomAccessInputStream rin)Extracts ICC_Profile from certain page of TIFF if anystatic byte[]extractICCProfile(RandomAccessInputStream rin)static IRBThumbnailextractThumbnail(int pageNumber, RandomAccessInputStream rin)static IRBThumbnailextractThumbnail(RandomAccessInputStream rin)static voidextractThumbnail(RandomAccessInputStream rin, java.lang.String pathToThumbnail)static voidinsertComments(java.util.List<java.lang.String> comments, int pageNumber, RandomAccessInputStream rin, RandomAccessOutputStream rout)static voidinsertComments(java.util.List<java.lang.String> comments, RandomAccessInputStream rin, RandomAccessOutputStream rout)static voidinsertExif(RandomAccessInputStream rin, RandomAccessOutputStream rout, Exif exif, boolean update)static voidinsertExif(RandomAccessInputStream rin, RandomAccessOutputStream rout, Exif exif, int pageNumber, boolean update)Insert EXIF data with optional thumbnail IFDstatic voidinsertICCProfile(byte[] icc_profile, int pageNumber, RandomAccessInputStream rin, RandomAccessOutputStream rout)Insert ICC_Profile into TIFF pagestatic voidinsertICCProfile(byte[] icc_profile, RandomAccessInputStream rin, RandomAccessOutputStream rout)static voidinsertIPTC(RandomAccessInputStream rin, RandomAccessOutputStream rout, int pageNumber, java.util.Collection<IPTCDataSet> iptcs, boolean update)Insert IPTC data into TIFF image.static voidinsertIPTC(RandomAccessInputStream rin, RandomAccessOutputStream rout, java.util.Collection<IPTCDataSet> iptcs, boolean update)static voidinsertIRB(RandomAccessInputStream rin, RandomAccessOutputStream rout, int pageNumber, java.util.Collection<_8BIM> bims, boolean update)static voidinsertIRB(RandomAccessInputStream rin, RandomAccessOutputStream rout, java.util.Collection<_8BIM> bims, boolean update)static voidinsertThumbnail(RandomAccessInputStream rin, RandomAccessOutputStream rout, java.awt.image.BufferedImage thumbnail)Insert a thumbnail into PHOTOSHOP private tag fieldstatic voidinsertXMP(byte[] xmp, int pageNumber, RandomAccessInputStream rin, RandomAccessOutputStream rout)Insert XMP data into TIFF imagestatic voidinsertXMP(byte[] xmp, RandomAccessInputStream rin, RandomAccessOutputStream rout)static voidinsertXMP(java.lang.String xmp, RandomAccessInputStream rin, RandomAccessOutputStream rout)static voidinsertXMP(XMP xmp, int pageNumber, RandomAccessInputStream rin, RandomAccessOutputStream rout)static voidinsertXMP(XMP xmp, RandomAccessInputStream rin, RandomAccessOutputStream rout)static voidprintIFD(IFD currIFD, java.lang.Class<? extends Tag> tagClass, java.lang.String indent)static voidprintIFDs(java.util.Collection<IFD> list, java.lang.String indent)static voidreadIFDs(java.util.List<IFD> list, RandomAccessInputStream rin)static java.util.Map<MetadataType,Metadata>readMetadata(RandomAccessInputStream rin)static java.util.Map<MetadataType,Metadata>readMetadata(RandomAccessInputStream rin, int pageNumber)static java.util.Map<MetadataType,Metadata>removeMetadata(int pageNumber, RandomAccessInputStream rin, RandomAccessOutputStream rout, MetadataType... metadataTypes)Remove meta data from TIFF imagestatic java.util.Map<MetadataType,Metadata>removeMetadata(java.util.Set<MetadataType> metadataTypes, int pageNumber, RandomAccessInputStream rin, RandomAccessOutputStream rout)Remove meta data from TIFF imagestatic java.util.Map<MetadataType,Metadata>removeMetadata(java.util.Set<MetadataType> metadataTypes, RandomAccessInputStream rin, RandomAccessOutputStream rout)Remove meta data from TIFF imagestatic java.util.Map<MetadataType,Metadata>removeMetadata(RandomAccessInputStream rin, RandomAccessOutputStream rout, MetadataType... metadataTypes)Remove meta data from TIFF imagestatic intretainPages(int startPage, int endPage, RandomAccessInputStream rin, RandomAccessOutputStream rout)static intretainPages(RandomAccessInputStream rin, RandomAccessOutputStream rout, int... pages)static voidwrite(TIFFImage tiffImage, RandomAccessOutputStream rout)
-
Field Details
-
OFFSET_TO_WRITE_FIRST_IFD_OFFSET
public static final int OFFSET_TO_WRITE_FIRST_IFD_OFFSET- See Also:
- Constant Field Values
-
FIRST_WRITE_OFFSET
public static final int FIRST_WRITE_OFFSET- See Also:
- Constant Field Values
-
STREAM_HEAD
public static final int STREAM_HEAD- See Also:
- Constant Field Values
-
-
Constructor Details
-
TIFFMeta
public TIFFMeta()
-
-
Method Details
-
extractICCProfile
public static byte[] extractICCProfile(int pageNumber, RandomAccessInputStream rin) throws java.lang.ExceptionExtracts ICC_Profile from certain page of TIFF if any- Parameters:
pageNumber- page number from which to extract ICC_Profilerin- RandomAccessInputStream for the input TIFF- Returns:
- a byte array for the extracted ICC_Profile or null if none exists
- Throws:
java.lang.Exception
-
extractICCProfile
- 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.IOExceptionInsert EXIF data with optional thumbnail IFD- Parameters:
rin- input image streamrout- output image streamexif- EXIF wrapper instancepageNumber- page offset where to insert EXIF (zero based)update- True to keep the original data, otherwise false- Throws:
java.lang.Exceptionjava.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.IOExceptionInsert ICC_Profile into TIFF page- Parameters:
icc_profile- byte array holding the ICC_ProfilepageNumber- page offset where to insert ICC_Profilerin- RandomAccessInputStream for the input imagerout- RandomAccessOutputStream for the output image- Throws:
java.lang.Exceptionjava.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.IOExceptionInsert 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 TIFFrout- RandomAccessOutputStream for the output TIFF with IPTC insertedpageNumber- page offset where to insert IPTCiptcs- A list of IPTCDataSet to insert into the TIFF imageupdate- 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.IOExceptionInsert a thumbnail into PHOTOSHOP private tag field- Parameters:
rin- RandomAccessInputStream for the input TIFFrout- RandomAccessOutputStream for the output TIFFthumbnail- a Bitmap to be inserted- Throws:
java.lang.Exceptionjava.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.IOExceptionInsert XMP data into TIFF image- Parameters:
xmp- byte array for the XMP data to be insertedpageNumber- page offset where to insert XMPrin- RandomAccessInputStream for the input imagerout- 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
-
printIFD
-
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.IOExceptionRemove meta data from TIFF image- Parameters:
rin- RandomAccessInputStream for the input imagerout- RandomAccessOutputStream for the output imagepageNumber- working page from which to remove metadatametadataTypes- 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.IOExceptionRemove meta data from TIFF image- Parameters:
rin- RandomAccessInputStream for the input imagerout- RandomAccessOutputStream for the output imagemetadataTypes- 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.IOExceptionRemove meta data from TIFF image- Parameters:
pageNumber- working page from which to remove EXIF and GPS datarin- RandomAccessInputStream for the input imagerout- 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.IOExceptionRemove meta data from TIFF image- Parameters:
metadataTypes- a set of MetadataType to be removedrin- RandomAccessInputStream for the input imagerout- 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
-