• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Java image reading -- Help me rewrite this code

 
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using following code instead of ImageIO.read() as we have older Java
version and it gives dark image as specified in Java bug (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6372769). It has been
working fine till now, however recently it started throwing exception for
certain photos -

java.lang.IllegalArgumentException: Invalid ICC Profile Data

When I searched, I found that it is yet another Java bug -
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6404011

We **cannot** change the Java version on our server. So I have to figure out
workaround for the following code --



How can I rewrite the code to do what I desire (read an image) by ignoring
this exception??? I tried to enclose the Exception throwing line & loop below that in try-catch block, but for some weird reason, it simply hangs the JVM and I am lost -- how do I fix this? I am not an image expert and hence finding it difficult to decide how to come up with a workaround!!

Any help, pointers would be highly appreciated!!

TIA,
- Manish
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The bug you linked to contains a workaround - does that work for you? If so, you could use it in case the ImageIO code throws an exception.
 
Manish Hatwalne
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ulf Dittmer:
The bug you linked to contains a workaround - does that work for you? If so, you could use it in case the ImageIO code throws an exception.



Ulf, if it means stripping meta-data using linux/windows tools, it is not feasible on our system. As for using JPEGImageDecoder - it doesn't work for me either as it gives exception -



Any other suggestion?
 
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
The bug also mentions using the JAI API to read the file, and then saving it back to disk (or maybe whatever JAI produces can be used directly?).
 
eat bricks! HA! And here's another one! And a tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic