Skip to main content

Covnerting TIF to JPG

2 replies [Last post]
emidio
Offline
Joined: 2004-10-20

Hello Guys !!

I'm using some classes from API JAI to convert TIFF files to JPG files (then I'll show image on a browser, because this does not support TIFF files). The problem is the original file (TIFF) has 31k, but after converted (JPG) has 531k, and the convertion is consuming too much time. Does anybody know why this occur and have some tips for me to solve this problem ?

Thanks !!!

ps: his my source code:

[code]
import com.sun.media.jai.codec.FileSeekableStream;
import com.sun.media.jai.codec.ImageCodec;
import com.sun.media.jai.codec.ImageDecoder;
import java.awt.image.RenderedImage;
import javax.media.jai.JAI;

public String ConvTifJpg(){
String sourcefilename = "g:\\java\\00000001.TIF";
String targetfilename = "g:\\java\\00000001.JPG";
try {
FileSeekableStream stream = null;
stream = new FileSeekableStream(sourcefilename);
ImageDecoder dec = ImageCodec.createImageDecoder("tiff", stream,null);
RenderedImage image = dec.decodeAsRenderedImage(0);
JAI.create("filestore",image ,targetfilename,"JPEG");
} catch (IOException e) {
e.printStackTrace();
System.exit(0);
}
return targetfilename;
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
emidio
Offline
Joined: 2004-10-20

Hello Guys !!

I'm using some classes from API JAI to convert TIFF files to JPG files (then I'll show image on a browser, because this does not support TIFF files). The problem is the original file (TIFF) has 31k, but after converted (JPG) has 531k, and the convertion is consuming too much time. Does anybody know why this occur and have some tips for me to solve this problem ?

Thanks !!!

ps: his my source code:

patrikbeno
Offline
Joined: 2004-10-11

Wrong forum for these kind of questions. This one (Mustang) is about Java 6 proposals/improvements/suggestions.