Hey guys,

Since I still haven't figured out how to do it via the API, here a the
quick and dirty workaround which transforms the link you get from the
client API to the link you get when you click "Download Image" in the
PWA interface. It uses 'd' imgmax-parameter described in the above
post in link [2].

PhotoEntry photo = ...
String resizedURL = photo.getMediaContents().get(0).getUrl();

int slashIndex = resizedURL.lastIndexOf("/");
URL originalURL = new URL(resizedURL.substring(0, slashIndex)
        + "/d" + resizedURL.substring(slashIndex));

InputStream is = originalURL.openStream();

Hope this helps some of you guys.
@Google: Could you add documentation for this in the client API docs?

Regards,
Philipp

On May 12, 10:57 pm, Philipp <[email protected]> wrote:
> Hey there,
>
> I know this has been asked before, but I couldn't find a working
> solution. I'd like to download the original image (not scaled, not re-
> calculated) from Picasa using the Java Client API (http://
> code.google.com/p/google-api-java-client/).
>
> Here is what I've tried / looked at:
>
> - I've tried the code from stackoverflow [1] that uses the
> PhotoEntry.getMediaSource() method, but it always returns "null".
>
> - I tried the PhotoEntry.getMediaContents() method, but it returns an
> object of the type
> "com.google.gdata.data.media.mediarss.MediaContent", not
> "com.google.gdata.data.MediaContent", so there is no getInputStream()
> method.
>
> - I've tried the following code, but it returns an InputStream to a
> JPG file, even though I uploaded a PNG:
>
> MediaContent media = (MediaContent) photoEntry.getContent();
> MediaSource mediaSrc = picasaWebService.getMedia(media);
> // get file with mediaSrc.getInputStream()
>
> - I also read about the "imgmax=d" [2] trick, but I couldn't figure
> out how to get it to work with the client API.
>
> I really have no idea what to do. Any ideas?
>
> Thanks in advance,
> Philipp
>
> [1]http://stackoverflow.com/questions/4515830/how-do-i-download-images-f...
> [2]http://code.google.com/apis/picasaweb/docs/2.0/reference.html#Parameters

-- 
You received this message because you are subscribed to the Google Groups 
"Google Picasa Web Albums API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-picasa-data-api?hl=en.

Reply via email to