• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Converting tif to jpg

 
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,

i want to know is there any good java api which allows me to convert tif/png images in jpg. please let me know
Rashid
 
Rashid Darvesh
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i was using the following code which was posted by Sun on one of their article where u can select the file and export it to differnet formats.
the link to the article is
http://java.sun.com/developer/technicalArticles/Media/AdvancedImage/index.html
here is the code

String name = prompt.getText(); //The name and path of the tif image
File file = new File(name);
if (file.exists()) {
BufferedImage image =
ImageIO.read(file.toURL());
as soon as it comes to the above line it throws
java.lang.OutOfMemoryError


Any help.
Rashid
 
Rashid Darvesh
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i increased the heap size and was able to create a jpg file out of a tif file. As assumed, the jpg file is not as clear as a tif file. I want to make sure is it really possible to create a jpeg out of tif without losing data quality by manipulating the encoder parameters. i dont want to try if there is no way u can do it.

please let me know.

Rashid
 
Rashid Darvesh
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any help on this. What i am trying to do is realistic or not
Rashid
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JPEG is an inherently lossy format. Converting a TIFF to a JPEG is going to lose quality. That may become unnoticeable if you set JPEG quality to 100% (trading away compression, i.e. file size, in the process), but then, it may not. Since TIFFs are mostly used where the exact value of pixels matter, and JPEG will not preserve those, you're probably better off not converting. (I'm not sure you actually can set JPEG quality with ImageIO; I generally use ImageJ for image processing, and it can do that).
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic