• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reading tif files on x64 system

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JAI is dead; don't use it for anything new.

The standard javax.imageio.ImageIO class can be made to read TIFFs, though: https://coderanch.com/t/445956/open-source/add-tiff-writer-imageio-package and it can write PNGs.
 
Tomas Toss
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow, thank you for such a fast reply. I'll definitely take look at that.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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




 
Whoever got anywhere by being normal? Just ask this exceptional tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic