int imageIndex = 0;
Iterator
.getImageReadersByFormatName("JPG");
ImageReader reader = readers.next();
File bigFile = new File("E:\\big.JPG");
ImageInputStream iis = ImageIO.createImageInputStream(bigFile);
reader.setInput(iis, true);
IIOMetadata metadata = reader.getImageMetadata(imageIndex);
}
/**
* 生成缩略图
*
* @throws IOException
*/
public void generateSmall() throws IOException {
File bigFile = new File("E:\\big.JPG");
Image image = ImageIO.read(bigFile);
int width = image.getWidth(null); // 3264
BufferedImage buffi = new BufferedImage(width / 2, height / 2,
BufferedImage.TYPE_INT_RGB);
Graphics g = buffi.getGraphics();
g.drawImage(image, 0, 0, width / 2, height / 2, null);
g.dispose();
ImageIO.write(buffi, "JPG", new File("E:\\small.JPG"));// width:1632 height:1224
}
public static void main(String[] args) throws IOException {
ImageIOTest iot = new ImageIOTest();
iot.generateSmall();
iot.formatImageNames();
iot.imageReaderOp();
iot.imageReadParamOp();
iot.ImageMetadata();
}
}
作者:cdl2008sky