Update Image width and height
Hello Friends,
I Create One java class for Getting an image from hard drive and Update its width and Height of that Image through AffineTransform and then after save it back to hard drive through BufferedImage.
But when i save my image into hard drive it is not display proper manner.
That means after updating the image i can not get its updated width and Height from AffineTransform.
my code is as bellow :
publicstaticvoid main(String[] args)
{
AffineTransform tx =new AffineTransform();
float scalingFactor = 1.0f;
Dimension size =new Dimension( 600, 600 );
Point origin =new Point( size.width / 2, size.height / 2 );
File f =new File("aa.jpg");
try{
BufferedImage bufi = ImageIO.read(f);
tx.translate( origin.x, origin.y );
scalingFactor += 2.0;
tx.scale( scalingFactor, scalingFactor );
tx.setToScale(scalingFactor, scalingFactor);
//BufferedImage bi = new BufferedImage(100, 180, BufferedImage.TYPE_INT_RGB);
BufferedImage bi =new BufferedImage(600, 600, BufferedImage.TYPE_INT_RGB);
Graphics2D big = bi.createGraphics();
big.drawImage( bufi, tx,null );
//big.drawImage(bufi, 0, 0, null);
ImageIO.write(bi,"jpg",new File("aaa.jpg"));
OutputStream out =new FileOutputStream("aa2.jpg");
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(bi);
f =null;
bufi =null;
bi =null;
out.close();//
}catch (Exception ex){
ex.printStackTrace();
}
}
Please give me right solution of this as soon as possible.
Thanks
Anup A. Patel.

