问题
Okay, it seems to be a stupid question, since we have this
However, up to the moment, I can only succeed in displaying the thumbnails by using:
PhotoEntry photo = //somehow I get the instance
photo.getMediaThumbnails().get(0).getUrl()
The biggest photo I can display through this method is up to 300 pixel or so[which is photo.getMediaThumbnails().get(3)
]. How can I display the a thumbnail up to 400 pixel or even 800 pixel? Or How can I even refer back to the google picasa page that can actually help me display this photo?
Thanks
回答1:
Quite Simple
PhotoEntry photo = //somehow I get the instance
photo.getMediaThumbnails().get(0).getUrl()
You can use this way to get that 400/800px photo.
You only have to change the result URL that is given. Change the s144/s400/s800 value of the URL
BLAH com/_BwderBVv7wg/XXXXXXXXX/AAAAAAAAAME/HdXja0HclK0/s72/DSC09176.JPG
BLAH com/_BwderBVv7wg/XXXXXXXXX/AAAAAAAAAME/HdXja0HclK0/s144/DSC09176.JPG
BLAH com/_BwderBVv7wg/XXXXXXXXX/AAAAAAAAAME/HdXja0HclK0/s288/DSC09176.JPG
BLAH com/_BwderBVv7wg/XXXXXXXXX/AAAAAAAAAME/HdXja0HclK0/s400/DSC09176.JPG
BLAH com/_BwderBVv7wg/XXXXXXXXX/AAAAAAAAAME/HdXja0HclK0/s800/DSC09176.JPG
回答2:
The following was answered by a community member of google picasa api:
Take a look at
http://code.google.com/apis/picasaweb/docs/2.0/reference.html#Parameters
It explains how you can control the size of the image that the media:content link points to as well as how you can request different thumbsizes for the media:thumbnail links. Also listed are the valid size values available. Note though, that you can only access images up to 800px in size (width or height, whatever is larger) from websites.
For instance:
GET /feed/api/user//albumid/? kind=photo&imgmax=800&thumbsize=512,400,160c
will give you a link to an 800px version in the media:content link, a link to the uncropped 512px and 400px version in the first two media:thumbnail elements and a square-cropped 160x160 thumbnail in the third thumbnail element.
Cheers, Detlev
回答3:
If you are using Picasa Java API and need to get image URL after uploading try to use following code
try {
File photoFile = new File(getFileName());
service = new PicasawebService(applicationName);
MediaFileSource photoMedia = new MediaFileSource(photoFile, "image/jpg");
URL albumPostUrl = new URL(String.format("http://picasaweb.google.com/data/feed/api/user/%1$s/albumid/%2$s", getUserName(), getAlbumId()));
PhotoEntry returnedPhoto = service.insert(albumPostUrl, PhotoEntry.class, photoMedia);
String href = returnedPhoto.getHtmlLink().getHref();
if (returnedPhoto.getMediaContents().size() > 0) {
// !!!!!!!!!!!!!!!This is exactly JPEG URL
href = returnedPhoto.getMediaContents().get(0).getUrl();
}
logger.info(String.format("Image published: <%s>", href));
return href;
} catch (AuthenticationException e) {
logger.error(e.getMessage(), e);
e.printStackTrace();
} catch (MalformedURLException e) {
logger.error(e.getMessage(), e);
e.printStackTrace();
} catch (IOException e) {
logger.error(e.getMessage(), e);
e.printStackTrace();
} catch (ServiceException e) {
logger.error(e.getMessage(), e);
e.printStackTrace();
}
来源:https://stackoverflow.com/questions/1315437/how-do-we-display-a-photo-from-picasa-java-api