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
  • 26,733
  • 16
  • 74
  • 87
Raja
  • 1,297
  • 3
  • 15
  • 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,095
  • 1
  • 46
  • 42
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
  • 17,899
  • 9
  • 46
  • 62