Ruchika Verma

Greenhorn
+ Follow
since Sep 19, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ruchika Verma

Hi,
I have installed JAI Image I/O 1.1 but when I run this prog I get an exception- Exception in thread "main" java.lang.IllegalStateException: Input not set!
at com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader.getNumImages(TIFFImageReader.java:234)

My code is:
import javax.imageio.stream.*;
import javax.imageio.*;
import javax.swing.*;
import com.sun.media.imageioimpl.plugins.tiff.TIFFImageReader;

import java.awt.*;
import java.awt.image.*;
import java.io.*;

class convertToJpg{

public static void convert2Jpg(String path) throws IOException {
ImageReader reader = ImageIO.getImageReadersByFormatName("tiff").next();
ImageInputStream iis = ImageIO.createImageInputStream(new File(path));
reader.setInput(iis, false);
ImageWriter writer = ImageIO.getImageWritersByFormatName("jpg").next();
String filename = path.substring(path.lastIndexOf("\\")+1, path.lastIndexOf("."));
for (int i=0; i<reader.getNumImages(true); i++) {
BufferedImage image = reader.read(i);
String outputFileName = filename+"_"+(i+1)+".jpg";
ImageOutputStream ios = ImageIO.createImageOutputStream(new File(outputFileName));
writer.setOutput(ios);
writer.write(image); // (*)
}
}
public static void main(String args[])throws IOException{

convert2Jpg("/src/CCITT_1.tif");

}
Please Help!!!
15 years ago
Ok. Thanks. But when I try to compress Tiff images with same lossy compression technique I get an exception. Can you share the code to compress Tiff image using lossy compression.
15 years ago
Hi,
I have compressed an image using ImageWriteParam class in ImageIO to reduce its size for image transfer. Now I want to decompress it. I urgently need the code to decompress the image. Please help.
15 years ago