I am able to resize the image:
def resize(is: java.io.InputStream, maxWidth: Int, maxHeight: Int): List[(BufferedImage, S)] = {
val originalImage = ImageIO.read(is)
val scaledBI = new BufferedImage(maxWidth, maxHeight, BufferedImage.TYPE_3BYTE_BGR)
val g = scaledBI.createGraphics
g.setComposite(AlphaComposite.Src)
g.drawImage(originalImage, 0, 0, maxWidth, maxHeight, null);
g.dispose
List((scaledBI, maxWidth.toString() + "x" + maxHeight.toString()))
} //end resize
request.body.files.map { img =>
val image = resize(new FileInputStream(img.ref.file), 120, 120)
}
But I am not able to save this to AWS S3 because:
amazonS3Client.putObject("path", "image.jpg",image(0)._1)
giving me the error:
type mismatch; found : java.awt.image.BufferedImage required: java.io.File
I am using Scala 2.10 with playframework 2.2