File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Other JSE/JEE APIs and the fly likes How to set photometricInterpretation property while storing TIFF using JAI? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "How to set photometricInterpretation property while storing TIFF using JAI?" Watch "How to set photometricInterpretation property while storing TIFF using JAI?" New topic
Author

How to set photometricInterpretation property while storing TIFF using JAI?

Baskaran Kandhasamy
Greenhorn

Joined: Nov 19, 2007
Posts: 2
I am converting JPG Grey Sale image in to bilevel image and saving in TIFF format with Group IV compression.

When I view the output TIFF, some applications displaying it properly and some others by inverting the image.

After a long time, I found that photometricInterpretation property is used to control this property of White_on_Black or Black_on_White in TIFF files.

In web I have found that, if we use IndexColorModel, then there is no problem. But, I am not using it and I don't know how to convert from RenderedOp's color model into IndexColorModel. Did anybody know it?

Is there any other way to set the PHOTOMETRICINTERPRETATION property ?

Any solution or suggestions are welcome...
Baskaran Kandhasamy
Greenhorn

Joined: Nov 19, 2007
Posts: 2
Its Windows applications bug :

http://www.data-tech.com/help/imnet/DTI.ImageMan.Codecs~DTI.ImageMan.Codecs.TifEncoder~PhotometricInterpretation.html
Kam Eley
Greenhorn

Joined: Aug 27, 2010
Posts: 4
I think you desire to change photometricintepretation property programmatically.

If so, in my experience I was trying all sorts of ways to change this property - a) set extrafields on parameter (TIFFField) b) customized ColorModel, SampleModel, etc. c) creating own TIFFImageWriter. None of these worked for me.

The only thing that changed this property from MinIsBlack to MinIsWhite was to use the JAI.create("invert"...) command.

This is the method I used returning an inverted BufferedImage. You can change this to return an object less memory intensive.

private BufferedImage invertImage(String fileName) {
RenderedOp src = JAI.create("fileload", fileName);
RenderedOp op1 = JAI.create("invert", src);
return op1.getAsBufferedImage();
}

Hope this helps.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to set photometricInterpretation property while storing TIFF using JAI?