0

I am using tapestry5 framework, in which I am using uploadedFile component which is returning me a file which is type of an image.

Now I want to resize that image to 20 x 20, irrespective of the type of the image.

Is there any way with Java API or with Tapestry5 framework to achieve this?

halfer
  • 19,824
  • 17
  • 99
  • 186
Nirmal
  • 4,789
  • 13
  • 72
  • 114
  • 1
    Related : http://stackoverflow.com/questions/244164/resize-an-image-in-java-any-open-source-library – jmj May 30 '12 at 05:28

2 Answers2

2

This is not functionality that is part of Tapestry, or every likely to be. The Java2D API has more than sufficient support for converting byte streams into images, rescaling them, and storing them back out.

Howard M. Lewis Ship
  • 2,247
  • 15
  • 23
0

Try this:

BufferedImage resizedImage = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, type);
Graphics2D g = resizedImage.createGraphics();
g.drawImage(originalImage, 0, 0, IMG_WIDTH, IMG_HEIGHT, null);
g.dispose();
David Kroukamp
  • 36,155
  • 13
  • 81
  • 138
Ravi
  • 11
  • 3