aspose file tools*
The moose likes Java in General and the fly likes Converting tif to jpg Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Converting tif to jpg" Watch "Converting tif to jpg" New topic
Author

Converting tif to jpg

Rashid Darvesh
Ranch Hand

Joined: Feb 13, 2004
Posts: 189
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

Joined: Feb 13, 2004
Posts: 189
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

Joined: Feb 13, 2004
Posts: 189
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

Joined: Feb 13, 2004
Posts: 189
Any help on this. What i am trying to do is realistic or not
Rashid
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42602
    
  65
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).


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Converting tif to jpg