-
-
Notifications
You must be signed in to change notification settings - Fork 308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TIFF Photometric Interpretation Set to 1 (one) #533
Comments
I believe this is exactly the same issue as #478 . You can't (currently) use the default constructor Use the constructor that takes a two color new IndexColorModel(1, 2, new int[] {-1, 0}, 0, false, -1, DataBuffer.TYPE_BYTE); Let me know if that doesn't fix your problem! Best regards, -- |
Thank you very much for your prompt reply. Here is my code for creating the new image.
The value for photometric interpretation for the created image is 3 (three). Here is an excerpt of the meta-data for the created image.
The problem is that the person I send the created image to is using a viewer that respects this value so he sees the image "reversed", i.e. black is white and white is black. Of-course other viewers, like Windows Photo Viewer, display the image correctly. I don't have the same viewer as my client so I can't check. Will the value 3 (for photometric interpretation) yield the same result as 0 (zero)? I asked the client to supply details of his viewer but so far he has not. All I can tell is that it is called ADA System Viewer. |
Sorry, my mistake. I just wrote the above code from the top of my head without testing. I fixed the code sample above. You need to specify the And no, Photometric 3 is Here's a full unit test as proof: @Test
public void testWriteWhiteIsZero() throws IOException {
IndexColorModel icm = new IndexColorModel(1, 2, new int[] {-1, 0}, 0, false, -1, DataBuffer.TYPE_BYTE);
BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_BYTE_BINARY, icm);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
try (ImageOutputStream output = ImageIO.createImageOutputStream(bytes)) {
ImageWriter imageWriter = createImageWriter();
imageWriter.setOutput(output);
imageWriter.write(image);
}
Directory directory = new TIFFReader().read(new ByteArrayImageInputStream(bytes.toByteArray()));
assertNotNull(directory.getEntryById(TIFF.TAG_PHOTOMETRIC_INTERPRETATION));
assertEquals(TIFFBaseline.PHOTOMETRIC_WHITE_IS_ZERO, directory.getEntryById(TIFF.TAG_PHOTOMETRIC_INTERPRETATION).getValue());
} Best regards, -- |
Many thanks. Problem resolved.
|
I am using Java 8 (32 bit) on Windows 7 (32 bit) with twelvemonkeys version 3.4
I read two files where each file contains a single TIFF image and create two, separate
BufferedImage
s.I create a new
BufferedImage
that contains the two images.Then I save that image to a file.
The photometric interpretation value for the new image is 1 (one) whereas it is 0 (zero) for both the source images. I want the photometric interpretation value to be 0 (zero) for the image I create. Note that my requirements for the created image are 200 DPI and CCITT T.6 compression.
Here is sample code.
Security at my place of work is not allowing me to upload the actual TIFF images.
Both source images are binary, i.e.
BufferedImage.TYPE_BYTE_BINARY
and both have identicalIndexColorModel
.The text was updated successfully, but these errors were encountered: