0

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

Govind Singh
  • 15,282
  • 14
  • 72
  • 106
  • Why do you expect it to work, if you're passing a BufferedImage to something that expects a File? In other words, it's unclear what you're asking – The Archetypal Paul Sep 20 '14 at 08:48
  • 1
    Looks like you need to convert your BufferedImage to an InputStream (see http://stackoverflow.com/questions/4251383/how-to-convert-bufferedimage-to-inputstream) then write it with putObject, using the PutObjectRequest constructor that takes an input streaa. – The Archetypal Paul Sep 20 '14 at 09:01

0 Answers0