aspose file tools*
The moose likes I/O and Streams and the fly likes Reading tif files on x64 system Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Reading tif files on x64 system" Watch "Reading tif files on x64 system" New topic
Author

Reading tif files on x64 system

Tomas Toss
Greenhorn

Joined: Sep 06, 2011
Posts: 7
Hi ranchers!

I'm currently working on a Java program (part of my master thesis) that automatically identifies and crops document pages in digital images. The digital images that the program is supposed to read, are stored (and will by default be generated) as tiff files.
To avoid having a step of manually converting the files to another format (currently png), I would like to be able to read the tif files directly. From what I can understand, this functionality is not included in the standard libraries. And unfortunately JAI does not seem to have any support for x64 systems.

Is there a simple solution to this problem that I might have overlooked?

Best regards
Tomas
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42291
    
  64
JAI is dead; don't use it for anything new.

The standard javax.imageio.ImageIO class can be made to read TIFFs, though: http://www.coderanch.com/t/445956/open-source/add-tiff-writer-imageio-package and it can write PNGs.


Ping & DNS - my free Android networking tools app
Tomas Toss
Greenhorn

Joined: Sep 06, 2011
Posts: 7
Wow, thank you for such a fast reply. I'll definitely take look at that.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42291
    
  64
Of course, JAI-ImageIO living on java.net, nothing is as easy as it should be - the download no longer exists, just the source code. Blame the incompetent java.net transition for that.

I've uploaded the latest version at http://test.javaranch.com/ulf/jai_imageio-1.1.jar
Tomas Toss
Greenhorn

Joined: Sep 06, 2011
Posts: 7
Great, I was able to make it work!
However, it seems I must change some part of my implementation. When I run the following code it takes well over 20 seconds to load and display the image (1800x2800 pixels). Also, using my existing code for image scaling, an exception occurs which says that the image type (=0) is unknown.






However, the scaling works if I instead copy the data from the original image to another BufferedImage and apply the scalning transform on the latter. The image is now loaded and displayed almost instantly, even without scaling. But is there a better solution to this problem? The current work around feels kind of "ugly".

Thanks in advance
/Tomas




 
wood burning stoves
 
subject: Reading tif files on x64 system