<?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>翻相册 &#8211; 李辉 / Grey Li</title>
	<atom:link href="https://greyli.com/tag/%e7%bf%bb%e7%9b%b8%e5%86%8c/feed/" rel="self" type="application/rss+xml" />
	<link>https://greyli.com</link>
	<description>一个编程和写作爱好者的在线记事本</description>
	<lastBuildDate>Sat, 15 Nov 2025 10:55:15 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.9.26</generator>

<image>
	<url>https://greyli.com/wp-content/uploads/2025/03/avatar-500-compressed-144x144.jpg</url>
	<title>翻相册 &#8211; 李辉 / Grey Li</title>
	<link>https://greyli.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>图片墙生成器</title>
		<link>https://greyli.com/picture-wall-builder/</link>
		<comments>https://greyli.com/picture-wall-builder/#comments</comments>
		<pubDate>Wed, 18 Jan 2017 03:56:14 +0000</pubDate>
		<dc:creator><![CDATA[李辉]]></dc:creator>
				<category><![CDATA[计算机与编程]]></category>
		<category><![CDATA[Flask]]></category>
		<category><![CDATA[翻相册]]></category>

		<guid isPermaLink="false">http://greyli.com/?p=1352</guid>
		<description><![CDATA[用Flask重写了图片墙生成器。 Github项目：https://github.com/greyli/ima [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>用Flask重写了图片墙生成器。</p>
<p>Github项目：<a class="" href="https://github.com/greyli/image-wall" data-editable="true" data-title="greyli/image-wall">https://github.com/greyli/image-wall<br /></a>图片墙Demo：<a class="" href="http://fanxiangce.com/demo1" data-editable="true" data-title="照片墙">http://fanxiangce.com/demo1</a>（旧Demo）</p>
<p>&nbsp;</p>
<h2>主要变化</h2>
<p>和之前的Python版本相比的变动：</p>
<ul>
<li>实现了上传功能</li>
<li>优化了CSS和JS代码</li>
<li>简化了页面元素，去掉了没用的赞助页面</li>
<li>把HTML分离出Python，代码结构更清晰</li>
</ul>
<p>&nbsp;</p>
<h2><b>实现步骤</b></h2>
<p>1、用户上传图片；</p>
<p>2、生成用户文件夹，重命名图片；</p>
<pre lang="python">@app.route('/', methods=['GET', 'POST'])
def index():
    # 为每一个用户创建文件夹
    username = hashlib.md5('demo' + str(time.time())).hexdigest()[:7]
    if request.method == 'POST' and 'photo' in request.files:
        amount = len(request.files.getlist('photo'))
    if amount in range(10, 101):  # 控制图片数量在10~100之间
        for num, img in enumerate(request.files.getlist('photo')):
            filename = username + str(num)  # 使用用户名加序号命名图片
            photos.save(img, name=username + '/' + filename + '.')
        return redirect(url_for('image_wall', username=username))
    return render_template('index.html')</pre>
<p>3、根据图片数量分配相应的行列图片数量，并为每一张图片生成三维坐标；</p>
<p>4、渲染模板，传入这些坐标；</p>
<pre lang="html" class="">{% for image in images %}
&lt;div class="step center-text" data-x="{{ image[1] }}" data-y="{{ image[2] }}" data-z="{{ image[3] }}"&gt;
    &lt;img class="image" src="{{ url_for('static', filename='photos/') }}{{ image[0] }}"&gt;
&lt;/div&gt;
{% endfor %}</pre>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://greyli.com/picture-wall-builder/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>翻相册（fanxiangce.com）</title>
		<link>https://greyli.com/album-fanxiangce-com/</link>
		<comments>https://greyli.com/album-fanxiangce-com/#comments</comments>
		<pubDate>Fri, 01 Jul 2016 04:47:57 +0000</pubDate>
		<dc:creator><![CDATA[李辉]]></dc:creator>
				<category><![CDATA[计算机与编程]]></category>
		<category><![CDATA[照片墙]]></category>
		<category><![CDATA[翻相册]]></category>

		<guid isPermaLink="false">http://withlihui.com/?p=740</guid>
		<description><![CDATA[搭积木 本来说要好好学习一下前端技术，可没过几天，又开始了堆积木式的创造：把各种JS库，CSS库搭配起来，最终 [&#8230;]]]></description>
				<content:encoded><![CDATA[<h2>搭积木</h2>
<p>本来说要好好学习一下前端技术，可没过几天，又开始了堆积木式的创造：把各种JS库，CSS库搭配起来，最终用Python做胶水实现了一个网页相册生成器。顺便用Bootstrap的模板做了一个介绍页：<a href="http://fanxiangce.com" target="_blank" rel="noopener">翻相册（fanxiangce.com）</a>。</p>
<p>&nbsp;</p>
<h2>翻相册</h2>
<p>故事还要从我上次做幻灯片讲起。用<a href="http://greyli.com/html-for-impress-js-write-slides/" target="_blank" rel="noopener">impress.js</a>做了<a href="http://greyli.com/make-a-fun-slide/" target="_blank" rel="noopener">幻灯片</a>不久，就想着用Python搭配impress.js做一个幻灯片生成器，最终实现的效果是：可以从一个文本文档里读取文本，每一行创建一张幻灯片，坐标可以固定（通过在每一行的结尾传入坐标参数），也可以随机（没解决遮盖问题）。做着做着，发现这并不实用。估计没人愿意用这种死板无聊的幻灯片。没过几天，又想用<a href="http://greyli.com/html-for-impress-js-write-slides/" target="_blank" rel="noopener">impress.js</a>搭配<a href="http://greyli.com/css-shake/" target="_blank" rel="noopener">csshke</a>做一个记单词的网页程序，几天后因为能力不够被暂时搁置了。</p>
<p>接着，又有了新的想法，在原来的幻灯片生成器的基础上改了改，做成了一个照片墙生成器。<span lang="zh-CN">原理很简单。就是通过获取图片的数量和文件名，生成足量的坐标，然后用</span><span lang="en-US">Python</span><span lang="zh-CN">生成相应的div，最后连接头尾组成一个完整的</span><span lang="en-US">HTML</span><span lang="zh-CN">文件。</span>做成这样一个照片墙：</p>
<div id="attachment_749" style="width: 1080px" class="wp-caption aligncenter"><a href="http://greyli.com/wp-content/uploads/2016/07/imagewall.jpg" rel="attachment wp-att-749"><img class="size-full wp-image-749" src="http://greyli.com/wp-content/uploads/2016/07/imagewall.jpg" alt="图片墙示例" width="1070" height="746" srcset="https://greyli.com/wp-content/uploads/2016/07/imagewall.jpg 1070w, https://greyli.com/wp-content/uploads/2016/07/imagewall-150x105.jpg 150w, https://greyli.com/wp-content/uploads/2016/07/imagewall-300x209.jpg 300w, https://greyli.com/wp-content/uploads/2016/07/imagewall-1024x714.jpg 1024w, https://greyli.com/wp-content/uploads/2016/07/imagewall-624x435.jpg 624w" sizes="(max-width: 1070px) 100vw, 1070px" /></a><p class="wp-caption-text">点击任一张图片可以拉近，点击相邻图片可以移动位置。</p></div>
<p>又过了几天，照片墙实现了tooltip功能，可以自动把文件名（没有格式后缀）设为tooltip内容。我想到的一个理想的应用场景是：集体制作照片墙，每个人上传自己的照片给某个人，以自己的名字作为文件名，收集照片的人只需要上传照片，设置标题，然后点击生成。打开后每张照片在鼠标掠过时都会用tooltip显示姓名。像这样：</p>
<div id="attachment_750" style="width: 941px" class="wp-caption aligncenter"><a href="http://greyli.com/wp-content/uploads/2016/07/hint.jpg" rel="attachment wp-att-750"><img class="size-full wp-image-750" src="http://greyli.com/wp-content/uploads/2016/07/hint.jpg" alt="tooltip" width="931" height="781" srcset="https://greyli.com/wp-content/uploads/2016/07/hint.jpg 931w, https://greyli.com/wp-content/uploads/2016/07/hint-150x126.jpg 150w, https://greyli.com/wp-content/uploads/2016/07/hint-300x252.jpg 300w, https://greyli.com/wp-content/uploads/2016/07/hint-624x523.jpg 624w" sizes="(max-width: 931px) 100vw, 931px" /></a><p class="wp-caption-text">tooltip的颜色可以自定义。</p></div>
<p>故事还没完。又过了几天，我买了<strong><a href="http://fanxiangce.com" target="_blank" rel="noopener">fanxiangce.com</a></strong>，做了一个粗糙的<a href="http://fanxiangce.com" target="_blank" rel="noopener">介绍页</a>。发现功能还太单调，和其他的在线相册相比没有什么吸引力。又实现了立体相册，像这样：</p>
<div id="attachment_745" style="width: 1404px" class="wp-caption aligncenter"><a href="http://greyli.com/wp-content/uploads/2016/07/3d.jpg"><img class="wp-image-745 size-full" src="http://greyli.com/wp-content/uploads/2016/07/3d.jpg" alt="3d" width="1394" height="741" srcset="https://greyli.com/wp-content/uploads/2016/07/3d.jpg 1394w, https://greyli.com/wp-content/uploads/2016/07/3d-150x80.jpg 150w, https://greyli.com/wp-content/uploads/2016/07/3d-300x159.jpg 300w, https://greyli.com/wp-content/uploads/2016/07/3d-1024x544.jpg 1024w, https://greyli.com/wp-content/uploads/2016/07/3d-624x332.jpg 624w" sizes="(max-width: 1394px) 100vw, 1394px" /></a><p class="wp-caption-text">点击任意一张照片可以拉近</p></div>
<p>随机散落（仍然没有解决遮盖问题），像这样：</p>
<div id="attachment_1750" style="width: 635px" class="wp-caption aligncenter"><a href="http://greyli.com/wp-content/uploads/2016/07/style-1.jpg"><img class="size-large wp-image-1750" src="http://greyli.com/wp-content/uploads/2016/07/style-1-1024x730.jpg" alt="随机散落的照片，点击任一张可以拉近" width="625" height="446" srcset="https://greyli.com/wp-content/uploads/2016/07/style-1-1024x730.jpg 1024w, https://greyli.com/wp-content/uploads/2016/07/style-1-150x107.jpg 150w, https://greyli.com/wp-content/uploads/2016/07/style-1-300x214.jpg 300w, https://greyli.com/wp-content/uploads/2016/07/style-1-624x445.jpg 624w, https://greyli.com/wp-content/uploads/2016/07/style-1.jpg 1160w" sizes="(max-width: 625px) 100vw, 625px" /></a><p class="wp-caption-text">随机散落的照片，点击任一张可以拉近</p></div>
<p>标签云（使用svg3dtagcloud.js）：</p>
<div id="attachment_747" style="width: 829px" class="wp-caption aligncenter"><a href="http://greyli.com/wp-content/uploads/2016/07/tagcloud.jpg" rel="attachment wp-att-747"><img class="size-full wp-image-747" src="http://greyli.com/wp-content/uploads/2016/07/tagcloud.jpg" alt="基于文本的标签云" width="819" height="743" srcset="https://greyli.com/wp-content/uploads/2016/07/tagcloud.jpg 819w, https://greyli.com/wp-content/uploads/2016/07/tagcloud-150x136.jpg 150w, https://greyli.com/wp-content/uploads/2016/07/tagcloud-300x272.jpg 300w, https://greyli.com/wp-content/uploads/2016/07/tagcloud-624x566.jpg 624w" sizes="(max-width: 819px) 100vw, 819px" /></a><p class="wp-caption-text">基于文本的标签云</p></div>
<p>点击标签就会打开相应的图片：</p>
<div id="attachment_748" style="width: 966px" class="wp-caption aligncenter"><a href="http://greyli.com/wp-content/uploads/2016/07/detail.jpg" rel="attachment wp-att-748"><img class="size-full wp-image-748" src="http://greyli.com/wp-content/uploads/2016/07/detail.jpg" alt="使用remodal.js实现的弹窗" width="956" height="693" srcset="https://greyli.com/wp-content/uploads/2016/07/detail.jpg 956w, https://greyli.com/wp-content/uploads/2016/07/detail-150x109.jpg 150w, https://greyli.com/wp-content/uploads/2016/07/detail-300x217.jpg 300w, https://greyli.com/wp-content/uploads/2016/07/detail-624x452.jpg 624w" sizes="(max-width: 956px) 100vw, 956px" /></a><p class="wp-caption-text">使用remodal.js实现的弹窗</p></div>
<p>现在只是一个简单的demo，未来还会实现很多功能，比如把标签换成图片缩略图。可以参见<a href="http://www.goat1000.com/tagcanvas.php" target="_blank" rel="noopener">TagCanvas</a>。</p>
<p>&nbsp;</p>
<h2>总结</h2>
<p>上面的相册都有相应的demo，欢迎到<a href="http://fanxiangce.com" target="_blank" rel="noopener">翻相册</a>上体验。也欢迎申请试用。虽然已经花了很多时间在上面，但是要做的事情还有很多。比如实现模拟翻页的相册，让图片更美观的排列，不是单一的对齐。等我暑假学习一下Flask和JS，把网站做出来，顺便把电脑端程序和在线程序做出来，就可以开放注册和在线自动生成相册了。</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://greyli.com/album-fanxiangce-com/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
