<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>阅微堂 &#187; API</title>
	<atom:link href="http://zhiqiang.org/blog/tag/api/feed" rel="self" type="application/rss+xml" />
	<link>http://zhiqiang.org/blog</link>
	<description>理工科背景的证券从业人员</description>
	<lastBuildDate>Sun, 05 Feb 2012 03:59:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>用Web Picasa API搭建站内相册</title>
		<link>http://zhiqiang.org/blog/it/local-mirror-of-picasaweb-using-api.html</link>
		<comments>http://zhiqiang.org/blog/it/local-mirror-of-picasaweb-using-api.html#comments</comments>
		<pubDate>Fri, 09 Nov 2007 20:01:25 +0000</pubDate>
		<dc:creator>zhiqiang</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Picasaweb]]></category>

		<guid isPermaLink="false">http://zhiqiang.org/blog/posts/local-mirror-of-picasaweb-using-api.html</guid>
		<description><![CDATA[博客 » IT技术 » Google » 在flickr时代，为了专门把站内嵌入相册，还专门写了一篇文章把Flickr相册搬回家。flickr被墙之后，我就把个人相册转到了Web Picasa上。用Picasa Web就简单多了，官方提供了Slideshow Flash，而且形式也比较漂亮，阅微堂之前也是用这样的方式，不过这种方法麻烦的一点是在Picasa上添加相册，就要手动到blog这边更新一次。这两天看到了 Web Picasa API，感觉这玩意...]]></description>
			<content:encoded><![CDATA[<p id="breadcrumb" class="breadcrumb"><a href="http://zhiqiang.org/blog/">博客</a> » <a href="http://zhiqiang.org/blog/category/it">IT技术</a> » <a href='http://zhiqiang.org/blog/tag/google'>Google</a>  » </p><p>在flickr时代，为了专门把站内嵌入相册，还专门写了一篇文章把Flickr相册搬回家。flickr被墙之后，我就把个人相册转到了<a title="Zhang-Zi的web picasa" href="http://picasaweb.google.com/" target="_blank">Web Picasa</a>上。用Picasa Web就简单多了，官方提供了<a href="http://support.google.com/picasa/bin/answer.py?hl=en&amp;ctx=sibling&amp;answer=66969" target="_blank">Slideshow Flash</a>，而且形式也比较漂亮，阅微堂之前也是用这样的方式，不过这种方法麻烦的一点是在Picasa上添加相册，就要手动到blog这边更新一次。这两天看到了 <a href="http://code.google.com/apis/picasaweb/overview.html" target="_blank">Web Picasa API</a>，感觉这玩意儿的功能太强了，完全可以做一个Picasa的站内镜像版。</p>
<p>最后的效果见阅微堂<a href="http://zhiqiang.org/blog/photo.html" target="_blank" rel="web picasa站内相册">相册</a>。</p>
<p>更令人惊讶的是，这种效果完全是javascript（<a href="http://code.google.com/apis/picasaweb/docs/2.0/reference.html" target="_blank">JSON API</a>）实现的（虽然我觉得如果在后台用php实现效果会更好）。主要用的是<a href="http://sourceforge.net/projects/pwa/" target="_blank">JavaScript interface to PicasaWeb Albums</a>，一个开源项目，其实就一个单js文件。使用也非常简单，就下面几行代码：</p>
<blockquote><pre><span style="color: #0000ff">&lt;</span><span style="color: #800000">script</span> <span style="color: #ff0000">type</span>=<span style="color: #0000ff">'text/javascript'</span><span style="color: #0000ff">&gt;</span>
	username = 'your.username'; photosize='800';
<span style="color: #0000ff">&lt;/</span><span style="color: #800000">script</span><span style="color: #0000ff">&gt;</span>

<span style="color: #0000ff">&lt;</span><span style="color: #800000">script</span> <span style="color: #ff0000">type</span>=<span style="color: #0000ff">'text/javascript'</span> <span style="color: #ff0000">src</span>=<span style="color: #0000ff">'http://yourpath/pwa.js'</span><span style="color: #0000ff">&gt;</span>
<span style="color: #0000ff">&lt;/</span><span style="color: #800000">script</span><span style="color: #0000ff">&gt;</span></pre>
</blockquote>
<p align="left">不过我改了很多地方，除了界面UI上的改变外，主要是改进页面加载速度。有兴趣的可以参考一下我的代码。</p>
<p>在修改过程中，仔细学习并应用了picasaweb的照片展示方式。Google的图片预载入做的非常好，浏览图片的时候会自动开始载入下一张图片，而且每张图片有若干种大小，它会从小到大预先载入，以便察看下一张的时候便能使用已经载入的图片，所以经常出现察看下一张图片时刚开始比较模糊，过一会就会变得清晰的情形（其实这种效果用小波编码的图像可以自动实现，但不知为何一直没见到什么应用）。这样做的相册，用户体验非常好，xiaonei等网站的相册可以学一学。不过这种方法会增加网站的带宽成本，Google财大气粗...</p>
<p><img src="http://lh6.ggpht.com/mathzqy/Rtv3OWtBvfI/AAAAAAAABFQ/N8h4O1FeeCU/s160/DSCN6503.JPG" align="right"/>另外，我终于知道了为何我以前有时候引用Google的图片却不成功了。Google的图片分为好多种大小，通过imgmax参数调用，比如右边图片的原始地址是<a title="http://lh6.google.com/mathzqy/Rtv3OWtBvfI/AAAAAAAABFQ/N8h4O1FeeCU/DSCN6503.JPG?imgmax=800" href="http://lh6.ggpht.com/mathzqy/Rtv3OWtBvfI/AAAAAAAABFQ/N8h4O1FeeCU/DSCN6503.JPG">DSCN6503.JPG</a>，但直接在网页上引用这个地址是不行的，一定要明确指出需要的图片大小，而且还不能太大，太大了只能提供下载（如果直接输入地址，浏览器会提示你保存图片，而不是显示出来）。能在网页上引用的图片最大宽度（高度）为800px，也即<a title="http://lh6.google.com/mathzqy/Rtv3OWtBvfI/AAAAAAAABFQ/N8h4O1FeeCU/DSCN6503.JPG?imgmax=800" href="http://lh6.ggpht.com/mathzqy/Rtv3OWtBvfI/AAAAAAAABFQ/N8h4O1FeeCU/s800/DSCN6503.JPG">DSCN6503.JPG?imgmax=800</a>。更详细的资料见下表。</p>
<p style="text-align: center">
<table>
<tbody>
<tr>
<th>输出大小</th>
<th>是否可剪切</th>
<th>是否可嵌入</th>
<th>输出大小</th>
<th>是否可剪切</th>
<th>是否可嵌入</th>
</tr>
<tr>
<td>32</td>
<td>Yes</td>
<td>Yes</td>
<td>576</td>
<td>No</td>
<td>Yes</td>
</tr>
<tr>
<td>48</td>
<td>Yes</td>
<td>Yes</td>
<td>640</td>
<td>No</td>
<td>Yes</td>
</tr>
<tr>
<td>64</td>
<td>Yes</td>
<td>Yes</td>
<td>720</td>
<td>No</td>
<td>Yes</td>
</tr>
<tr>
<td>72</td>
<td>No</td>
<td>Yes</td>
<td>800</td>
<td>No</td>
<td>Yes</td>
</tr>
<tr>
<td>144</td>
<td>No</td>
<td>Yes</td>
<td>912</td>
<td>No</td>
<td>No</td>
</tr>
<tr>
<td>160</td>
<td>Yes</td>
<td>Yes</td>
<td>1024</td>
<td>No</td>
<td>No</td>
</tr>
<tr>
<td>200</td>
<td>No</td>
<td>Yes</td>
<td>1152</td>
<td>No</td>
<td>No</td>
</tr>
<tr>
<td>288</td>
<td>No</td>
<td>Yes</td>
<td>1280</td>
<td>No</td>
<td>No</td>
</tr>
<tr>
<td>320</td>
<td>No</td>
<td>Yes</td>
<td>1440</td>
<td>No</td>
<td>No</td>
</tr>
<tr>
<td>400</td>
<td>No</td>
<td>Yes</td>
<td>1600</td>
<td>No</td>
<td>No</td>
</tr>
<tr>
<td>512</td>
<td>No</td>
<td>Yes</td>
<td>d</td>
<td>No</td>
<td>No</td>
</tr>
</tbody>
</table>
<p>从表中可以看出Google输出的图片种类之多，难道Google在服务器端保存了这么多副本么？那得耗费多少空间啊？</p>
<div><h4>相关文章</h4><ul><li><a href="http://zhiqiang.org/blog/it/gmail-contact.html">关于Gmail联系人</a></li><li><a href="http://zhiqiang.org/blog/memopad/google-code-jam-end-of-the-trip.html">Google Code Jam之旅结束了</a></li><li><a href="http://zhiqiang.org/blog/resource/google-2007-summer-intern-recruitment-and-campus-recruitment-full-time.html">Google 2007暑期实习生招聘及Full Time校园招聘</a></li><li><a href="http://zhiqiang.org/blog/science/googles-crazy-face-questions.html">Google的疯狂面试题</a></li><li><a href="http://zhiqiang.org/blog/it/google-is-better-than-baidu-at-yueweitang.html">Google更懂阅微堂</a></li><li><a href="http://zhiqiang.org/blog/scribble/guge-is-not-google-china.html">&ldquo;谷歌&rdquo;在中国：他不是Google</a></li><li><a href="http://zhiqiang.org/blog/scribble/news-about-google-out-china.html">关于Google退出中国的报道</a></li></ul></div>    <p></p>
    <hr noshade style="margin:0;height:1px" />
    <p>&copy; zhiqiang for <a href="http://zhiqiang.org/blog">阅微堂</a>, 2007. | <a href="http://zhiqiang.org/blog/it/local-mirror-of-picasaweb-using-api.html">&#38142;&#25509;</a> | <a href="http://zhiqiang.org/blog/it/local-mirror-of-picasaweb-using-api.html#comments">43 &#26465;&#35780;&#35770;</a></p>]]></content:encoded>
			<wfw:commentRss>http://zhiqiang.org/blog/it/local-mirror-of-picasaweb-using-api.html/feed</wfw:commentRss>
		<slash:comments>43</slash:comments>
		</item>
	</channel>
</rss>

