How to resize a JPG image file
- From: Chris Berg <spam.spam.eggs@xxxxxxx>
- Date: Sat, 31 Dec 2005 05:44:35 +0100
I need to re-size a .jpg image. This is what I do:
(tDim is the required new Dimension)
Image newImg =
javax.imageio.ImageIO.read(myFile).getScaledInstance(tDim.width,
tDim.height,Image.SCALE_SMOOTH);
java.awt.image.BufferedImage bim =
new java.awt.image.BufferedImage(tDim.width,
tDim.height, java.awt.image.BufferedImage.TYPE_INT_RGB);
bim.createGraphics().drawImage(newImg, 0, 0, null);
FileOutputStream fos = new FileOutputStream(ofName);
javax.imageio.ImageIO.write(bim, "jpg", fos);
fos.close();
Is this the smartest (fastest, least ressource-using) way to do it?
And is TYPE_INT_RGB the right choice?
Chris
.
- Follow-Ups:
- Re: How to resize a JPG image file
- From: Knute Johnson
- Re: How to resize a JPG image file
- Prev by Date: [OT] The President of Columbia University
- Next by Date: Re: compare xml dom documents
- Previous by thread: how to working java.lang.reflect.Proxy
- Next by thread: Re: How to resize a JPG image file
- Index(es):