public class TIFFTweaker
extends java.lang.Object
Constructor and Description |
---|
TIFFTweaker() |
Modifier and Type | Method and Description |
---|---|
static void |
append(RandomAccessInputStream rin,
RandomAccessOutputStream rout,
java.awt.image.BufferedImage... images) |
static void |
append(RandomAccessInputStream rin,
RandomAccessOutputStream rout,
ImageFrame... frames)
Append ImageFrames to the end of the original TIFF image
|
static void |
append(RandomAccessInputStream rin,
RandomAccessOutputStream rout,
ImageParam[] imageParam,
java.awt.image.BufferedImage... images) |
static void |
copyCat(RandomAccessInputStream rin,
RandomAccessOutputStream rout)
Read an input TIFF and write it to a new TIFF.
|
static byte[] |
extractICCProfile(int pageNumber,
RandomAccessInputStream rin)
Extracts ICC_Profile from certain page of TIFF if any
|
static byte[] |
extractICCProfile(RandomAccessInputStream rin) |
static IRBThumbnail |
extractThumbnail(int pageNumber,
RandomAccessInputStream rin) |
static IRBThumbnail |
extractThumbnail(RandomAccessInputStream rin) |
static void |
extractThumbnail(RandomAccessInputStream rin,
java.lang.String pathToThumbnail) |
static java.util.Collection<java.awt.image.BufferedImage> |
extractThumbnails(RandomAccessInputStream rin) |
static void |
finishInsert(RandomAccessOutputStream rout,
java.util.List<IFD> list) |
static void |
finishWrite(RandomAccessOutputStream rout,
java.util.List<IFD> list) |
static int |
getPageCount(RandomAccessInputStream rin)
Get the total number of pages for the TIFF image
|
static int[] |
getUncompressedStripByteCounts(IFD ifd,
int strips) |
static void |
insertComments(java.util.List<java.lang.String> comments,
int pageNumber,
RandomAccessInputStream rin,
RandomAccessOutputStream rout) |
static void |
insertComments(java.util.List<java.lang.String> comments,
RandomAccessInputStream rin,
RandomAccessOutputStream rout) |
static void |
insertExif(RandomAccessInputStream rin,
RandomAccessOutputStream rout,
Exif exif,
boolean update) |
static void |
insertExif(RandomAccessInputStream rin,
RandomAccessOutputStream rout,
Exif exif,
int pageNumber,
boolean update)
Insert EXIF data with optional thumbnail IFD
|
static void |
insertICCProfile(byte[] icc_profile,
int pageNumber,
RandomAccessInputStream rin,
RandomAccessOutputStream rout)
Insert ICC_Profile into TIFF page
|
static void |
insertICCProfile(java.awt.color.ICC_Profile icc_profile,
int pageNumber,
RandomAccessInputStream rin,
RandomAccessOutputStream rout)
Insert ICC_Profile into TIFF page
|
static void |
insertICCProfile(java.awt.color.ICC_Profile icc_profile,
RandomAccessInputStream rin,
RandomAccessOutputStream rout) |
static void |
insertIPTC(RandomAccessInputStream rin,
RandomAccessOutputStream rout,
java.util.Collection<IPTCDataSet> iptcs,
boolean update) |
static void |
insertIPTC(RandomAccessInputStream rin,
RandomAccessOutputStream rout,
int pageNumber,
java.util.Collection<IPTCDataSet> iptcs,
boolean update)
Insert IPTC data into TIFF image.
|
static void |
insertIRB(RandomAccessInputStream rin,
RandomAccessOutputStream rout,
java.util.Collection<_8BIM> bims,
boolean update) |
static void |
insertIRB(RandomAccessInputStream rin,
RandomAccessOutputStream rout,
int pageNumber,
java.util.Collection<_8BIM> bims,
boolean update) |
static void |
insertMetadata(RandomAccessInputStream rin,
RandomAccessOutputStream rout,
java.util.Collection<Metadata> metadata) |
static void |
insertMetadata(RandomAccessInputStream rin,
RandomAccessOutputStream rout,
int pageNumber,
java.util.Collection<Metadata> metadata)
Insert a collection of Metadata into TIFF page specified by the pageNumber
|
static int |
insertPage(java.awt.image.BufferedImage image,
int pageNumber,
RandomAccessOutputStream rout,
java.util.List<IFD> ifds,
int writeOffset,
TIFFWriter writer)
Insert a single page into a TIFF image
|
static int |
insertPage(ImageFrame page,
int pageNumber,
RandomAccessOutputStream rout,
java.util.List<IFD> ifds,
int writeOffset,
TIFFWriter writer) |
static void |
insertPages(RandomAccessInputStream rin,
RandomAccessOutputStream rout,
int pageNumber,
java.awt.image.BufferedImage... images) |
static void |
insertPages(RandomAccessInputStream rin,
RandomAccessOutputStream rout,
int pageNumber,
ImageFrame... frames)
Insert ImageFrames into existing TIFF image.
|
static void |
insertPages(RandomAccessInputStream rin,
RandomAccessOutputStream rout,
int pageNumber,
ImageParam[] imageParam,
java.awt.image.BufferedImage... images)
Insert pages into a TIFF image.
|
static void |
insertThumbnail(RandomAccessInputStream rin,
RandomAccessOutputStream rout,
java.awt.image.BufferedImage thumbnail)
Insert a thumbnail into PHOTOSHOP private tag field
|
static void |
insertTiffImage(java.io.File original,
java.io.File toBeInserted,
int pageNumber,
java.io.File output)
Insert a TIFF image into another TIFF image or append it to the end of the first image in case the first image
is only one page.
|
static void |
insertTiffImage(RandomAccessInputStream original,
RandomAccessInputStream toBeInserted,
int pageNumber,
RandomAccessOutputStream output)
Insert a TIFF image into another TIFF image or append it to the end of the first image in case the first image
is only one page.
|
static void |
insertXMP(byte[] xmp,
int pageNumber,
RandomAccessInputStream rin,
RandomAccessOutputStream rout)
Insert XMP data into TIFF image
|
static void |
insertXMP(byte[] xmp,
RandomAccessInputStream rin,
RandomAccessOutputStream rout) |
static void |
insertXMP(java.lang.String xmp,
RandomAccessInputStream rin,
RandomAccessOutputStream rout) |
static void |
insertXMP(XMP xmp,
int pageNumber,
RandomAccessInputStream rin,
RandomAccessOutputStream rout) |
static void |
insertXMP(XMP xmp,
RandomAccessInputStream rin,
RandomAccessOutputStream rout) |
static void |
mergeTiffImages(RandomAccessInputStream image1,
RandomAccessInputStream image2,
RandomAccessOutputStream merged)
Merges two TIFF images together
|
static void |
mergeTiffImages(RandomAccessOutputStream merged,
java.io.File... images)
Merges a list of TIFF images (single or multiple page) into one.
|
static void |
mergeTiffImagesEx(RandomAccessOutputStream merged,
java.io.File... images)
Merges a list of TIFF images into one regardless of the original bit depth
|
static void |
mergeTiffImagesEx(RandomAccessOutputStream merged,
java.io.InputStream... images)
Merges a list of TIFF images into one regardless of the original bit depth
|
static int |
prepareForInsert(RandomAccessInputStream rin,
RandomAccessOutputStream rout,
java.util.List<IFD> ifds)
Copy the header and pages of the input TIFF and prepare for inserting new pages one at a time
|
static int |
prepareForWrite(RandomAccessOutputStream rout)
Write TIFF header and get ready for writing pages one at a time
|
static int |
prepareForWrite(RandomAccessOutputStream rout,
ByteOrder byteOrder)
Write TIFF header and get ready for writing pages one at a time
|
static void |
printIFD(IFD currIFD,
java.lang.Class<? extends Tag> tagClass,
java.lang.String indent) |
static void |
printIFDs(java.util.Collection<IFD> list,
java.lang.String indent) |
static void |
readIFDs(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 image
|
static java.util.Map<MetadataType,Metadata> |
removeMetadata(RandomAccessInputStream rin,
RandomAccessOutputStream rout,
MetadataType... metadataTypes)
Remove meta data from TIFF image
|
static java.util.Map<MetadataType,Metadata> |
removeMetadata(java.util.Set<MetadataType> metadataTypes,
int pageNumber,
RandomAccessInputStream rin,
RandomAccessOutputStream rout)
Remove meta data from TIFF image
|
static java.util.Map<MetadataType,Metadata> |
removeMetadata(java.util.Set<MetadataType> metadataTypes,
RandomAccessInputStream rin,
RandomAccessOutputStream rout)
Remove meta data from TIFF image
|
static int |
removePages(int startPage,
int endPage,
RandomAccessInputStream rin,
RandomAccessOutputStream rout)
Remove a range of pages from a multiple page TIFF image
|
static int |
removePages(RandomAccessInputStream rin,
RandomAccessOutputStream rout,
int... pages)
Remove pages from a multiple page TIFF image
|
static int |
retainPages(int startPage,
int endPage,
RandomAccessInputStream rin,
RandomAccessOutputStream rout) |
static int |
retainPages(RandomAccessInputStream rin,
RandomAccessOutputStream rout,
int... pages) |
static void |
splitPages(RandomAccessInputStream rin,
java.util.List<byte[]> outputFilesByte)
Split a multiple page TIFF into single page TIFFs byte arrays
|
static void |
splitPages(RandomAccessInputStream rin,
java.util.List<byte[]> outputFilesByte,
int size)
Split a multiple page TIFF into size pages TIFFs byte arrays
|
static void |
splitPages(RandomAccessInputStream rin,
java.lang.String outputFilePrefix)
Split a multiple page TIFF into single page TIFFs
|
static void |
splitPages(RandomAccessInputStream rin,
java.lang.String outputFilePrefix,
int size)
Split a multiple page TIFF into multiple page TIFF with size pages each
|
static void |
write(TIFFImage tiffImage,
RandomAccessOutputStream rout) |
static void |
writeMultipageTIFF(RandomAccessOutputStream rout,
java.awt.image.BufferedImage... images) |
static void |
writeMultipageTIFF(RandomAccessOutputStream rout,
java.awt.image.BufferedImage[] images,
ImageParam... imageParams) |
static void |
writeMultipageTIFF(RandomAccessOutputStream rout,
ImageFrame... frames)
Write an array of ImageFrames as a multiple page TIFF.
|
static int |
writePage(java.awt.image.BufferedImage image,
RandomAccessOutputStream rout,
java.util.List<IFD> ifds,
int writeOffset,
TIFFWriter writer)
Write a single page to a multi-page TIFF
|
static int |
writePage(ImageFrame page,
RandomAccessOutputStream rout,
java.util.List<IFD> ifds,
int writeOffset,
TIFFWriter writer) |
public static void append(RandomAccessInputStream rin, RandomAccessOutputStream rout, java.awt.image.BufferedImage... images) throws java.io.IOException
java.io.IOException
public static void append(RandomAccessInputStream rin, RandomAccessOutputStream rout, ImageFrame... frames) throws java.io.IOException
frames
- an array of ImageFrame to be appendedrin
- RandomAccessInputStream for the input imagerout
- RandomAccessOutputStream for the output imagejava.io.IOException
public static void append(RandomAccessInputStream rin, RandomAccessOutputStream rout, ImageParam[] imageParam, java.awt.image.BufferedImage... images) throws java.io.IOException
java.io.IOException
public static void copyCat(RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
rin
- a RandomAccessInputStreamrout
- a RandomAccessOutputStreamjava.io.IOException
public static byte[] extractICCProfile(int pageNumber, RandomAccessInputStream rin) throws java.lang.Exception
pageNumber
- page number from which to extract ICC_Profilerin
- RandomAccessInputStream for the input TIFFjava.lang.Exception
public static byte[] extractICCProfile(RandomAccessInputStream rin) throws java.lang.Exception
java.lang.Exception
public static IRBThumbnail extractThumbnail(int pageNumber, RandomAccessInputStream rin) throws java.io.IOException
java.io.IOException
public static IRBThumbnail extractThumbnail(RandomAccessInputStream rin) throws java.io.IOException
java.io.IOException
public static void extractThumbnail(RandomAccessInputStream rin, java.lang.String pathToThumbnail) throws java.io.IOException
java.io.IOException
public static java.util.Collection<java.awt.image.BufferedImage> extractThumbnails(RandomAccessInputStream rin) throws java.io.IOException
java.io.IOException
public static void finishInsert(RandomAccessOutputStream rout, java.util.List<IFD> list) throws java.io.IOException
java.io.IOException
public static void finishWrite(RandomAccessOutputStream rout, java.util.List<IFD> list) throws java.io.IOException
java.io.IOException
public static int getPageCount(RandomAccessInputStream rin) throws java.io.IOException
rin
- RandomAccessInputStream to read the imagejava.io.IOException
public static int[] getUncompressedStripByteCounts(IFD ifd, int strips)
public static void insertComments(java.util.List<java.lang.String> comments, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
java.io.IOException
public static void insertComments(java.util.List<java.lang.String> comments, int pageNumber, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
java.io.IOException
public static void insertExif(RandomAccessInputStream rin, RandomAccessOutputStream rout, Exif exif, boolean update) throws java.io.IOException
java.io.IOException
public static void insertExif(RandomAccessInputStream rin, RandomAccessOutputStream rout, Exif exif, int pageNumber, boolean update) throws java.io.IOException
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 falsejava.lang.Exception
java.io.IOException
public static void insertICCProfile(byte[] icc_profile, int pageNumber, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
icc_profile
- byte array holding the ICC_ProfilepageNumber
- page offset where to insert ICC_Profilerin
- RandomAccessInputStream for the input imagerout
- RandomAccessOutputStream for the output imagejava.lang.Exception
java.io.IOException
public static void insertICCProfile(java.awt.color.ICC_Profile icc_profile, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
java.io.IOException
public static void insertICCProfile(java.awt.color.ICC_Profile icc_profile, int pageNumber, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
icc_profile
- ICC_ProfilepageNumber
- page number to insert the ICC_Profilerin
- RandomAccessInputStream for the input imagerout
- RandomAccessOutputStream for the output imagejava.lang.Exception
java.io.IOException
public static void insertIPTC(RandomAccessInputStream rin, RandomAccessOutputStream rout, java.util.Collection<IPTCDataSet> iptcs, boolean update) throws java.io.IOException
java.io.IOException
public static void insertIPTC(RandomAccessInputStream rin, RandomAccessOutputStream rout, int pageNumber, java.util.Collection<IPTCDataSet> iptcs, boolean update) throws java.io.IOException
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.
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 setjava.io.IOException
public static void insertIRB(RandomAccessInputStream rin, RandomAccessOutputStream rout, java.util.Collection<_8BIM> bims, boolean update) throws java.io.IOException
java.io.IOException
public static void insertIRB(RandomAccessInputStream rin, RandomAccessOutputStream rout, int pageNumber, java.util.Collection<_8BIM> bims, boolean update) throws java.io.IOException
java.io.IOException
public static void insertMetadata(RandomAccessInputStream rin, RandomAccessOutputStream rout, java.util.Collection<Metadata> metadata) throws java.io.IOException
java.io.IOException
public static void insertMetadata(RandomAccessInputStream rin, RandomAccessOutputStream rout, int pageNumber, java.util.Collection<Metadata> metadata) throws java.io.IOException
rin
- input image streamrout
- output image streammetadata
- a collection of Metadata to be insertedpageNumber
- page offset where to insert EXIF (zero based)java.lang.Exception
java.io.IOException
public static int insertPage(java.awt.image.BufferedImage image, int pageNumber, RandomAccessOutputStream rout, java.util.List<IFD> ifds, int writeOffset, TIFFWriter writer) throws java.io.IOException
This method is supposed to be used along with the prepareForInsert
method
and the finishInsert
method.
List<IFD> list = new ArrayList<IFD>();
RandomAccessInputStream rin = new FileCacheRandomAccessInputStream(new FileInputStream("in.tif"));
RandomAccessOutputStream rout = new FileCacheRandomAccessOutputStream(new FileOuputStream("out.tif"));
BufferedImage bi = getBufferedImageSomeWay();
int offset = TIFFTweaker.prepareForInsert(rin, rout, list);
TIFFWriter writer = new TIFFWriter();
offset = TIFFTweaker.insertPage(bi, pageNumber, rout, list, offset, writer);
//keep inserting pages until finish, then call
TIFFTweaker.finishInsert(rout, list);
image
- a BufferedImage to insertpageNumber
- page number (relative to the existing pages) to insert the pagerout
- RandomAccessOutputStream to write new imageifds
- a list of IFDs for all the existing and inserted pageswriteOffset
- stream offset to insert this pagewriter
- TIFFWriter instancejava.io.IOException
public static int insertPage(ImageFrame page, int pageNumber, RandomAccessOutputStream rout, java.util.List<IFD> ifds, int writeOffset, TIFFWriter writer) throws java.io.IOException
java.io.IOException
public static void insertPages(RandomAccessInputStream rin, RandomAccessOutputStream rout, int pageNumber, java.awt.image.BufferedImage... images) throws java.io.IOException
java.io.IOException
public static void insertPages(RandomAccessInputStream rin, RandomAccessOutputStream rout, int pageNumber, ImageFrame... frames) throws java.io.IOException
getPageCount
first.rin
- RandomAccessInputStream for the original imagerout
- RandomAccessOutputStream to write new imagepageNumber
- page offset to start page insertionframes
- an array of ImageFramejava.io.IOException
public static void insertPages(RandomAccessInputStream rin, RandomAccessOutputStream rout, int pageNumber, ImageParam[] imageParam, java.awt.image.BufferedImage... images) throws java.io.IOException
getPageCount
first.rin
- RandomAccessInputStream to read original imagerout
- RandomAccessOutputStream to write new imagepageNumber
- page offset to start page insertionimageParam
- an array of ImageParam for TIFFWriterimages
- a number of BufferedImage to insertjava.io.IOException
public static void insertThumbnail(RandomAccessInputStream rin, RandomAccessOutputStream rout, java.awt.image.BufferedImage thumbnail) throws java.io.IOException
rin
- RandomAccessInputStream for the input TIFFrout
- RandomAccessOutputStream for the output TIFFthumbnail
- a BufferedImage to be insertedjava.lang.Exception
java.io.IOException
public static void insertTiffImage(java.io.File original, java.io.File toBeInserted, int pageNumber, java.io.File output) throws java.io.IOException
This method doesn't need to decode the images if SamplesPerPixel value is less than 8 or SamplesPerPixel & 8 != 0.
original
- File for the original TIFF imagetoBeInserted
- File for the TIFF image to be insertedpageNumber
- page offset where to insert the TIFF image (zero based)output
- File for the output TIFF imagejava.io.IOException
public static void insertTiffImage(RandomAccessInputStream original, RandomAccessInputStream toBeInserted, int pageNumber, RandomAccessOutputStream output) throws java.io.IOException
This method doesn't need to decode the images if SamplesPerPixel value is less than 8 or SamplesPerPixel & 8 != 0.
original
- RandomAccessInputStream for the original TIFF imagetoBeInserted
- RandomAccessInputStream for the TIFF image to be insertedpageNumber
- offset where to insert the second TIFF image (zero based)output
- RandomAccessOutputStream for the output TIFF imagejava.io.IOException
public static void insertXMP(XMP xmp, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
java.io.IOException
public static void insertXMP(XMP xmp, int pageNumber, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
java.io.IOException
public static void insertXMP(byte[] xmp, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
java.io.IOException
public static void insertXMP(byte[] xmp, int pageNumber, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
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 imagejava.io.IOException
public static void insertXMP(java.lang.String xmp, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
java.io.IOException
public static void mergeTiffImages(RandomAccessInputStream image1, RandomAccessInputStream image2, RandomAccessOutputStream merged) throws java.io.IOException
Note: this method works for all TIFF images with BitsPerSample <= 8. For BitsPerSample > 8, the result is unpredictable: if the image is the first one in the list to be merged, or the endianness of the image is the same as the merged image, it works fine, otherwise, the merged image with BitsPerSample > 8 will contain wrong image data.
image1
- RandomAccessInputStream for the first TIFF imageimage2
- RandomAccessInputStream for the second TIFF imagemerged
- RanomAccessOutputStream for the merged TIFF imagejava.io.IOException
public static void mergeTiffImages(RandomAccessOutputStream merged, java.io.File... images) throws java.io.IOException
Note: this method works for all TIFF images with BitsPerSample <= 8. For BitsPerSample > 8, the result is unpredictable: if the image is the first one in the list to be merged, or the endianness of the image is the same as the merged image, it works fine, otherwise, the merged image with BitsPerSample > 8 will contain wrong image data.
merged
- RandomAccessOutputStream for the merged TIFFimages
- input TIFF image files to be mergedjava.io.IOException
public static void mergeTiffImagesEx(RandomAccessOutputStream merged, java.io.File... images) throws java.io.IOException
merged
- RandomAccessOutputStream for the merged TIFFimages
- input TIFF image files to be mergedjava.io.IOException
public static void mergeTiffImagesEx(RandomAccessOutputStream merged, java.io.InputStream... images) throws java.io.IOException
merged
- RandomAccessOutputStream for the merged TIFFimages
- InputStreams of TIFF images to be mergedjava.io.IOException
public static int prepareForInsert(RandomAccessInputStream rin, RandomAccessOutputStream rout, java.util.List<IFD> ifds) throws java.io.IOException
rin
- RandomAccessInputStream for the input TIFFrout
- RandomAccessOutputStream for the output TIFFjava.io.IOException
public static int prepareForWrite(RandomAccessOutputStream rout) throws java.io.IOException
rout
- RandomAccessOutputStream for the output TIFFjava.io.IOException
public static int prepareForWrite(RandomAccessOutputStream rout, ByteOrder byteOrder) throws java.io.IOException
rout
- RandomAccessOutputStream for the output TIFFbyteOrder
- ByteOrder for the output TIFFjava.io.IOException
public static void printIFDs(java.util.Collection<IFD> list, java.lang.String indent)
public static void printIFD(IFD currIFD, java.lang.Class<? extends Tag> tagClass, java.lang.String indent)
public static void readIFDs(java.util.List<IFD> list, RandomAccessInputStream rin) throws java.io.IOException
java.io.IOException
public static java.util.Map<MetadataType,Metadata> readMetadata(RandomAccessInputStream rin) throws java.io.IOException
java.io.IOException
public static java.util.Map<MetadataType,Metadata> readMetadata(RandomAccessInputStream rin, int pageNumber) throws java.io.IOException
java.io.IOException
public static java.util.Map<MetadataType,Metadata> removeMetadata(int pageNumber, RandomAccessInputStream rin, RandomAccessOutputStream rout, MetadataType... metadataTypes) throws java.io.IOException
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 removedjava.io.IOException
public static java.util.Map<MetadataType,Metadata> removeMetadata(RandomAccessInputStream rin, RandomAccessOutputStream rout, MetadataType... metadataTypes) throws java.io.IOException
rin
- RandomAccessInputStream for the input imagerout
- RandomAccessOutputStream for the output imagemetadataTypes
- a variable length array of MetadataType to be removedjava.io.IOException
public static java.util.Map<MetadataType,Metadata> removeMetadata(java.util.Set<MetadataType> metadataTypes, int pageNumber, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
pageNumber
- working page from which to remove metadatarin
- RandomAccessInputStream for the input imagerout
- RandomAccessOutputStream for the output imagejava.io.IOException
public static java.util.Map<MetadataType,Metadata> removeMetadata(java.util.Set<MetadataType> metadataTypes, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
metadataTypes
- a set of MetadataType to be removedrin
- RandomAccessInputStream for the input imagerout
- RandomAccessOutputStream for the output imagejava.io.IOException
public static int removePages(int startPage, int endPage, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
startPage
- start page number (inclusive)endPage
- end page number (inclusive)rin
- input image streamrout
- output image streamjava.io.IOException
public static int removePages(RandomAccessInputStream rin, RandomAccessOutputStream rout, int... pages) throws java.io.IOException
rin
- input image streamrout
- output image streampages
- an array of page numbers to be removedjava.io.IOException
public static int retainPages(int startPage, int endPage, RandomAccessInputStream rin, RandomAccessOutputStream rout) throws java.io.IOException
java.io.IOException
public static int retainPages(RandomAccessInputStream rin, RandomAccessOutputStream rout, int... pages) throws java.io.IOException
java.io.IOException
public static void splitPages(RandomAccessInputStream rin, java.util.List<byte[]> outputFilesByte) throws java.io.IOException
rin
- input RandomAccessInputStream to read multiple page TIFFoutputFilesByte
- output files as a list of byte arraysjava.io.IOException
public static void splitPages(RandomAccessInputStream rin, java.lang.String outputFilePrefix) throws java.io.IOException
rin
- input RandomAccessInputStream to read multiple page TIFFoutputFilePrefix
- output file name prefix for the split TIFFsjava.io.IOException
public static void splitPages(RandomAccessInputStream rin, java.lang.String outputFilePrefix, int size) throws java.io.IOException
rin
- input RandomAccessInputStream to read multiple page TIFFoutputFilePrefix
- output file name prefix for the split TIFFssize
- number of pages each output image containsjava.io.IOException
public static void splitPages(RandomAccessInputStream rin, java.util.List<byte[]> outputFilesByte, int size) throws java.io.IOException
rin
- input RandomAccessInputStream to read multiple page TIFFoutputFilesByte
- output files as a list of byte arrayssize
- number of pages each output image containsjava.io.IOException
public static void write(TIFFImage tiffImage, RandomAccessOutputStream rout) throws java.io.IOException
java.io.IOException
public static void writeMultipageTIFF(RandomAccessOutputStream rout, java.awt.image.BufferedImage... images) throws java.io.IOException
java.io.IOException
public static void writeMultipageTIFF(RandomAccessOutputStream rout, ImageFrame... frames) throws java.io.IOException
rout
- RandomAccessOutputStream for the output imageframes
- an array of ImageFramejava.io.IOException
public static void writeMultipageTIFF(RandomAccessOutputStream rout, java.awt.image.BufferedImage[] images, ImageParam... imageParams) throws java.io.IOException
java.io.IOException
public static int writePage(java.awt.image.BufferedImage image, RandomAccessOutputStream rout, java.util.List<IFD> ifds, int writeOffset, TIFFWriter writer) throws java.io.IOException
This method is supposed to be used along with the prepareForWrite
method
and the finishWrite
method.
List<IFD> list = new ArrayList<IFD>();
RandomAccessOutputStream rout = new FileCacheRandomAccessOutputStream(new FileOuputStream("out.tif"));;
BufferedImage bi = getBufferedImageSomeWay();
int offset = TIFFTweaker.prepareForWrite(rout);
TIFFWriter writer = new TIFFWriter();
offset = TIFFTweaker.writePage(bi, rout, list, offset, writer);
//keep adding pages until finish, then call
TIFFTweaker.finishWrite(rout, list);
java.io.IOException
public static int writePage(ImageFrame page, RandomAccessOutputStream rout, java.util.List<IFD> ifds, int writeOffset, TIFFWriter writer) throws java.io.IOException
java.io.IOException