Posted By:
Mark_Wheadon
Posted On:
Friday, June 17, 2005 11:05 AM
Hello, My program needs to open a given image file and determine the image format (e.g. JPG, TIF, BMP etc.). The files may not have extensions. I know that: String image_file_name = "e:\temp\images\000174E3"; RenderedOp rop = JAI.create("fileload", image_file_name); will read a supported type, but I would like to know which type it is. My reason for doing this is that I need to know the DPI of the image in order to show it at a percentage of the original scale as the images will mostly be scanned documents. If I use: String op_name = rop.getOperationName(); I just get "fileload" - not very helpful. I have looked th
More>>
Hello,
My program needs to open a given image file and determine the image format (e.g. JPG, TIF, BMP etc.). The files may not have extensions. I know that:
String image_file_name = "e:\temp\images\000174E3";
RenderedOp rop = JAI.create("fileload", image_file_name);
will read a supported type, but I would like to know which type it is.
My reason for doing this is that I need to know the DPI of the image in order to show it at a percentage of the original scale as the images will mostly be scanned documents.
If I use:
String op_name = rop.getOperationName();
I just get "fileload" - not very helpful. I have looked through the variables in the (Eclipse) debugger and the documentation and searched the net (for days), but cannot see anything which tells me what the image format is.
I do know that if I do:
String[] names = rop.getPropertyNames();
on a TIFF image one of the properties will be tiff_directory which is quite helpful.
The JAI.create method seems to take a couple of seconds. As I am using this with a servlet app, if it is a JPEG image and doesn't need rotating or scaling, then I would rather not do JAI.create at all, but just open it with a SeekableStream and find the image format first, then decide what to do. Seems a pretty basic requirement to me.
Any comments or help much appreciated.
Regards, MarkW.
<<Less