我们如何显示来自 Picasa java API 的照片?

发布于 2024-08-02 19:02:53 字数 476 浏览 4 评论 0原文

好吧,这似乎是一个愚蠢的问题,因为我们有 this

但是,到目前为止,我只能通过使用以下方法成功显示缩略图:

PhotoEntry photo = //somehow I get the instance
photo.getMediaThumbnails().get(0).getUrl()

通过此方法我可以显示的最大照片最多为 300 像素左右[即 photo.getMediaThumbnails( ).get(3)]。如何显示最大 400 像素甚至 800 像素的缩略图?或者我怎样才能参考实际上可以帮助我显示这张照片的 google picasa 页面?

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

厌倦 2024-08-09 19:02:53

很简单

 PhotoEntry photo = //somehow I get the instance
    photo.getMediaThumbnails().get(0).getUrl()

你可以用这种方法来获得 400/800px 的照片。

您只需更改给定的结果 URL。
更改 URL 的 s144/s400/s800 值

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

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
笑忘罢 2024-08-09 19:02:53

以下是 google picasa api 社区成员的回答:

看看

http://code.google.com/apis/ picasaweb/docs/2.0/reference.html#参数

它解释了如何控制
图像的大小
媒体:内容链接也指向
以及如何请求不同的
媒体的缩略图:缩略图
链接。还列出了有效尺寸
可用值。但请注意,
您只能访问最大 800 像素的图像
尺寸(宽度或高度,无论是
更大)来自网站。

例如:

获取
/feed/api/user//专辑/?
kind=照片&imgmax=800&thumbsize=512,400,160c

会给你一个800px的链接
媒体版本:内容链接,a
链接到未裁剪的 512px 和 400px
前两个版本
媒体:缩略图元素和
方形裁剪的 160x160 缩略图
第三个缩略图元素。

干杯,德特莱夫

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

蝶…霜飞 2024-08-09 19:02:53

如果您使用 Picasa Java API 并需要在上传后获取图像 URL,请尝试使用以下代码

    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();
    }

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();
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文