File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes HELP! finding image compression type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "HELP! finding image compression type" Watch "HELP! finding image compression type" New topic

HELP! finding image compression type

mike dib

Joined: Feb 09, 2011
Posts: 3
Hello Everyone!
I am in the process of writing an application that processes tiff files.

I have a requirement that I have to check to confirm that the image has group 4 compression type.

I have successfully implemented this using imagemagick/jmagick..... but due to certain circumstances, we are not able to use jmagick.

I am now using JAI to split multi page tiff files and iText.jar to find the DPI of these images... however I still need to find the compression type!

Does anyone know how to find an image compression type using a method other than image magick/ jmagick?? If so... please provide me with any download links and a few lines of example code!!!

A big virtual hug to whoever might have a solution for me!!!

Thanks so much!

p.s. it is in a linux environment.
mike dib

Joined: Feb 09, 2011
Posts: 3
P.S. I've alredy tried the functions:

Method Summary
int getCompression()
Returns the value of the compression parameter.
int getDeflateLevel()
Gets the compression level for DEFLATE compression.

located at:

They return 1 for getCompression and -1 for getDeflateLevel regardless of what compression type the image i run through them are.

mike dib

Joined: Feb 09, 2011
Posts: 3
I Resolved this issue- for those of you who attempt to do the same here is how:

reference jar files jai-core-1.1.3-alpha.jar

start code

File file = new File(filepath);
RenderedOp page = JAI.create("fileload",file.getCanonicalPath());
TIFFDirectory dir = (TIFFDirectorypage.getProperty("tiff_directory");
TIFFField compress = dir.getField(259);
System.out.println("The compression is: " compress.getAsInt(0));

end code

The value 4 is equal to group 4 compression.

I agree. Here's the link:
subject: HELP! finding image compression type
It's not a secret anymore!