我正在使用 imgscalr-lib-3.1 创建缩略图以在我的 Galleria-classic 相册中使用。它正在减小大小(我的意思是像 100 * 100 的像素),但不是千字节(像 10K、20K)。这是我的代码:
public static void createThumbNails(String path) throws ImageFormatException, IOException{
File image ;
FileInputStream in = null ;
JPEGImageDecoder decoder;
BufferedImage bufferedImage ;
BufferedImage outBufferedImage ;
Scalr scalr = new Scalr();
File folder = new File(path+"/images/album/award/");
File[] files = folder.listFiles();
File outputfile ;
for(File file : files){
image = file;
in = new FileInputStream(file);
decoder = JPEGCodec.createJPEGDecoder(in);
bufferedImage = decoder.decodeAsBufferedImage();
outBufferedImage = scalr.resize(bufferedImage, Scalr.Method.SPEED,100);
ImageIO.write(outBufferedImage, "jpg", file);
}
in.close();
}
你们知道该怎么做吗?谢谢你。