I have a small problem… There are hundreds of images in a folder. they should scale down to specific height and specific width. so, the problem is… Retrieving images from a folder, and scale down them, and save them into another folder. Is it possible with Java? if yes, please help me, how? This is only for reducing memory size in my application. ( all files should be in JPEG format).
Share
You can use ImageIO to read and Image, then use the Image.getScaledInstance() method to scale the image. Finally you can use ImageIO to write out the new image.
Oops, I’m not sure what type of Image gets returned when you use the getScaledInstance() method. The ImageIO.write() method needs a RenderedImage, so you may need to create a BufferedImage first and paint the scaled image onto the buffer and then write out the BufferedImage.