You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Guys, I'm trying to generate a TIFF image and it must have compression G4 (CCITT_T_6) and also the StripOffsets must be 8.
The problem that I have is that when I don't set the TAG_STRIP_OFFSETS it's creating usually with the vale 188 on this tag. But if I try to set TAG_STRIP_OFFSETS as 8, it's changing the compression to LZW.
Can you check my below code and give me any idea in how to solve this?
private IIOMetadata getMetadata(ImageWriter iw) throws IIOInvalidTreeException {
TIFFImageMetadata tiffMd = (TIFFImageMetadata) iw.getDefaultImageMetadata(null, tiffImageWriteParam);
tiffMd.addShortOrLongField(BaselineTIFFTagSet.TAG_NEW_SUBFILE_TYPE,0);
tiffMd.addShortOrLongField(BaselineTIFFTagSet.TAG_IMAGE_WIDTH,CHECK_WIDTH);
tiffMd.addShortOrLongField(BaselineTIFFTagSet.TAG_IMAGE_LENGTH,CHECK_HEIGHT);
tiffMd.addShortOrLongField(BaselineTIFFTagSet.TAG_BITS_PER_SAMPLE,1);
tiffMd.addShortOrLongField(BaselineTIFFTagSet.TAG_COMPRESSION,BaselineTIFFTagSet.COMPRESSION_CCITT_T_6);
tiffMd.addShortOrLongField(BaselineTIFFTagSet.TAG_PHOTOMETRIC_INTERPRETATION,0);
tiffMd.addShortOrLongField(BaselineTIFFTagSet.TAG_SAMPLES_PER_PIXEL,1);
tiffMd.addShortOrLongField(BaselineTIFFTagSet.TAG_ROWS_PER_STRIP,CHECK_HEIGHT);
tiffMd.addShortOrLongField(BaselineTIFFTagSet.TAG_STRIP_OFFSETS,8); // Problematic line -> changes to LZW
// Workaround for Rational X/Y Resolutions
long[] xRes = new long[]{200, 1};
long[] yRes = new long[]{200, 1};
Node node = tiffMd.getAsTree(tiffMd.getNativeMetadataFormatName());
TIFFField fieldXRes = new TIFFField(
BaselineTIFFTagSet.getInstance().getTag(BaselineTIFFTagSet.TAG_X_RESOLUTION),
TIFFTag.TIFF_RATIONAL, 1, new long[][]{xRes});
TIFFField fieldYRes = new TIFFField(
BaselineTIFFTagSet.getInstance().getTag(BaselineTIFFTagSet.TAG_Y_RESOLUTION),
TIFFTag.TIFF_RATIONAL, 1, new long[][]{yRes});
node.getFirstChild().appendChild(fieldXRes.getAsNativeNode());
node.getFirstChild().appendChild(fieldYRes.getAsNativeNode());
tiffMd.mergeTree(tiffMd.getNativeMetadataFormatName(), node);
tiffMd.addShortOrLongField(BaselineTIFFTagSet.TAG_RESOLUTION_UNIT, 2);
return tiffMd;
}
Thank you, and sorry if it's not an issue in the library.
The text was updated successfully, but these errors were encountered:
Guys, I'm trying to generate a TIFF image and it must have compression G4 (CCITT_T_6) and also the StripOffsets must be 8.
The problem that I have is that when I don't set the TAG_STRIP_OFFSETS it's creating usually with the vale 188 on this tag. But if I try to set TAG_STRIP_OFFSETS as 8, it's changing the compression to LZW.
Can you check my below code and give me any idea in how to solve this?
Thank you, and sorry if it's not an issue in the library.
The text was updated successfully, but these errors were encountered: