为Turbogears2动态生成占位图
项目描述
关于tgapp-placeholder
tgapp-placeholder 是一个用于 TurboGears2 的可插拔应用程序,允许动态生成占位图。灵感来自 http://dummyimage.com/ 和 https://github.com/darkrho/django-dummyimage。
安装
占位符可以从PyPI或GitHub安装
pip install tgapp-placeholder
应该适用于大多数用户
插入占位符
在您的应用程序 config/app_cfg.py 中导入 plug
from tgext.pluggable import plug
然后在文件的 末尾 调用占位符的plug
plug(base_config, 'placeholder')
您将能够通过 http://localhost:8080/placeholder 访问插入的应用程序。
使用占位符
现在您可以通过调用
http://you-application/placeholder/{width} #for a square image http://you-application/placeholder/{width}x{height} http://you-application/placeholder/{width}x{height}?text={some text value}
- 实际上您可以调整的参数有
text : 一个自定义在线文本,其大小计算以适应您的图像宽度
bgcolor : 背景颜色(默认设置为‘DDDDDD’)的HEX rgb形式
color : 文本颜色(默认设置为‘888888’)的HEX rgb形式
format : 可用格式 在此(默认设置为PNG)
font_size : 实际文本的字体大小。如果没有提供,它将自动计算以适应整个图像宽度。
电影明星
通过占位符获得您的电影明星!现在您可以为Bill Murray,Steven Seagal以及所有时代最伟大的艺术家Nicolas Cage生成自定义大小的占位图!
只需在URL中添加您电影英雄的名字,例如
http://you-application/placeholder/stevenseagal/{width} #for a square image http://you-application/placeholder/nicolascage/{width}x{height} http://you-application/placeholder/billmurray/{width}x{height}
无需文本、背景色、颜色、格式或字体大小!只需英雄的名字,见证魔法!
额外:尼古拉斯·凯奇
尼古拉斯·凯奇图片支持灰色或GIF模式。只需在您的URL中添加模式即可。
http://you-application/placeholder/nicolascage/g/{width}x{height} http://you-application/placeholder/billmurray/gif/{width}x{height}
- 可用模式
g:灰色模式
gif:GIF模式
c:想看一些疯狂的东西?试试疯狂的凯奇模式!
基于Dave Cowart的著名占位符生成器(http://www.placecage.com,https://www.stevensegallery.com/,http://www.fillmurray.com)
项目详情
tgapp-placeholder-1.0.1.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 2768190eeb956043cb3f596a784372be277fe92486185ded868715de20ec6e9d |
|
MD5 | 0125cbc405920aa32f1c9c8880c5905f |
|
BLAKE2b-256 | 315f2b46f32cbadf9184ad1bddb5d0437ab0e2a91a79beebfc088e6f2d90d185 |