1

I would like to reduce size of photo before uploading to picasa using picasa java api. How can I resize photo during upload with Picasa API?

apaderno
  • 28,547
  • 16
  • 75
  • 90
Raja
  • 1,317
  • 3
  • 16
  • 22

2 Answers2

0

I used a combination of ImageIO and imgscalr:

import javax.imageio.ImageIO;
import org.imgscalr.Scalr;
   
InputStream myPhotoInputStream = // new FileInputStream(file)
                                 // or FileItemStream.openStream(); from an HTTP upload
OutputStream outstream = ...
BufferedImage image = ImageIO.read( myPhotoInputStream );
int maxDimension = 1024;
image = Scalr.resize(image, maxDimension);
ImageIO.write(image, "JPEG", outstream);

Unfortunately when you resize, you lose the EXIF metadata. I have yet to find a library capable of simply saving this on read and restoring it on write. Apache commons-imaging looked promising but seems unable to write a JPEG.

Ed Randall
  • 6,887
  • 2
  • 50
  • 45
0

As far as I see in the API, photos has to be resized before the upload. Luckily, it is easy to do in Java.

Community
  • 1
  • 1
Vladimir Dyuzhev
  • 18,130
  • 10
  • 48
  • 62