BufferedImage Bi = ImageIO.read(F);
AffineTransformOp op = new AffineTransformOp(AffineTransform.getScaleInstance(Ratio, Ratio), null);
Image Itemp = op.filter(Bi, null);
File ThF = new File(newpicture.getImgDir(),newpicture.getImgfile());
ImageIO.write((BufferedImage)Itemp, ext, ThF);
}catch (Exception ex) {
throw new Exception(" ImageIo.write error in CreatThum.: "+ex.getMessage());
}
}
public double getRadio(Picture picture,int maxwidth,int maxheight){
double Ratio=1.0;
if (picture.getWidth()>picture.getHeight()){
Ratio = (new Integer(maxwidth)).doubleValue()/picture.getWidth();
}else if (picture.getWidth()<picture.getHeight()){
Ratio=(new Integer(maxheight)).doubleValue()/picture.getHeight();
}else if (picture.getWidth()==picture.getHeight()){
if (picture.getWidth()>maxwidth){
Ratio = (new Integer(maxwidth)).doubleValue()/picture.getWidth();
}
}
return Ratio;
}
public void getImagSize(Picture picture) throws Exception{
double Ratio=1.0;
try{
File F = new File(picture.getImgDir(),picture.getImgfile());
if (!F.isFile())
throw new Exception(F+" is not image file error !");
BufferedImage Bi = ImageIO.read(F);
// Image Itemp = Bi.getScaledInstance (maxwidth,maxheight,Bi.SCALE_SMOOTH);