^_^

2009年12月29日星期二

测试 Picasa Web 外链图片尺寸

突然发现 Picasa Web 外链图片的尺寸并非只有 144、288、400、800px 几个。但是官方文档并没有任何说明,为此我特意写了一个 python code 测试了一下:
import httplib, urlparse 

def http_exists(url): 
    host, path = urlparse.urlsplit(url)[1:3] 
    if ':' in host: 
        # port specified, try to use it 
        host, port = host.split(':', 1) 
        try: 
            port = int(port) 
        except ValueError: 
            print 'invalid port number %r' % (port,) 
            return False 
    else: 
        # no port specified, use default port 
        port = None 
        
    try: 
        connection = httplib.HTTPConnection(host, port=port) 
        connection.request("HEAD", path) 
        resp = connection.getresponse( ) 
        if resp.status == 200: # normal 'found' status 
            found = True 
        elif resp.status == 302: # recurse on temporary redirect 
            found = httpExists(urlparse.urljoin(url, resp.getheader('location', ''))) 
        else: # everything else -> not found 
#            print "Status %d %s : %s" % (resp.status, resp.reason, url) 
            found = False 
    except Exception, e: 
        print e.__class__, e, url 
        found = False
        
    connection.close()         
    return found 

if __name__ == '__main__': 
    size = 1
    while size < 10000:
        url = 'http://lh6.ggpht.com/_Eyd_-h7bEhI/SaX5Ys8m02I/AAAAAAAAIj0/JA5TPeK7APc/s%d/locater.jpg' % size
#        print url
        if http_exists(url):
            code = "s%d:\n\n" % (size, url)
            print code
        size += 1    
code 中以 url“http://lh6.ggpht.com/_Eyd_-h7bEhI/SaX5Ys8m02I/AAAAAAAAIj0/JA5TPeK7APc/s???/locater.jpg”为例,替换该 url 中的“???”为 size 即是各个 size 图片的 url。该图原始尺寸是 1279×1022,原始图片 url 为(没有“s???”路径):
http://lh6.ggpht.com/_Eyd_-h7bEhI/SaX5Ys8m02I/AAAAAAAAIj0/JA5TPeK7APc/locater.jpg"
上面的代码输出有效尺寸图片的 HTML script,验证下来尺寸有:
s32、s48、s64、s72、s94、s104、s110、s128、s144、s150、s160、s200、s220、s288、s320、s400、s512、s576、s640、s720、s800、s912、s1024、s1152、s1280、s1440、s1600
图片预览效果如下:

s32:


s48:


s64:


s72:


s94:


s104:


s110:


s128:


s144:


s150:


s160:


s200:


s220:


s288:


s320:


s400:


s512:


s576:


s640:


s720:


s800:


s912:


s1024:


s1152:


s1280:


s1440:


s1600:
本站文章除注明外,均为本站原创
转载请注明文章转载自: 大笨熊乐园 [ https://blog.foolbear.com/?m=0 ]
文章标题: 测试 Picasa Web 外链图片尺寸
文章地址: https://blog.foolbear.com/2009/12/picasa-web.html?m=0

没有评论 :

发表评论

Related Posts with Thumbnails