拇指图像服务的最小接口

django-thumborize的Python项目详细描述


https://api.travis-ci.org/tpisani/django-thumborize.svg

thumbor映像服务的最小接口。

功能

简易拇指网址

通过调用简单的函数,轻松构建带有参数和过滤器的thumborurl。

默认过滤器

将默认筛选器设置为在缩略图URL上使用。 这些过滤器可以被任何使用不同参数指定相同过滤器的调用重写。

柔性过滤器规范< EH3>

筛选器可以是由:、alistdict分隔的字符串。有关更多信息,请参见用法。

链接

简单,查询集式链接,用于应用过滤器和调整大小。

有关可用筛选器的完整列表,请选中thumbor’s wiki

用法

fromthumborizeimportThumborURL# Filters as string.thumbor_url=ThumborURL("http://path/to/image.png",width=320,filters="quality(80):grayscale()")# Filters as list.thumbor_url=ThumborURL("http://path/to/image.png",width=320,filters=["quality(80)","grayscale()"])# Filters as dict.thumbor_url=ThumborURL("http://path/to/image.png",width=320,filters={"quality":"(80)","grayscale":"()",})thumbor_url.generate()'http://localhost:8888/JiuVg9d5Mry_kw4odvb5Zh1C_BY=/320x0/filters:quality(80):grayscale()/http://path/to/image.png'

链接

fromthumborizeimportThumborURLthumbor_url=ThumborURL("http://path/to/image.png")small_gray_image=thumbor_url.grayscale().resize(width=100,height=100)small_gray_image.generate()'http://localhost:8888/RFsfJakG9BsJUcbY2l1M6D5tthQ=/100x100/filters:grayscale()/http://path/to/image.png'low_quality_image=thumbor_url.quality(40).width(200)'http://localhost:8888/SB1ILIArmGzsd90-Mz-TxJVHwqI=/200x0/filters:quality(40)/http://path/to/image.png'# Original ThumborURL instance.thumbor_url.generate()'http://localhost:8888/O0Zqo6DMqqXHORdYncuspoaJlr0=/http://path/to/image.png'

快捷方式

importthumborizethumborize.url("http://path/to/image.png",width=320,height=300)'http://localhost:8888/DYStA-Xwisc37dVz7bdXZ3u63QI=/320x300/http://path/to/image.png'

模板

{% load thumborize %}

<!-- Filters as string --><imgsrc="{% thumborize some_url width=320 filters='quality(80):grayscale()' %}"/><!-- Filters as a list object --><imgsrc="{% thumborize some_url width=320 filters=filter_list %}"/>

安装

使用pip安装

$ pip install django-thumborize

要使用django thumborize模板标记,必须将应用程序添加到INSTALLED_APPS

INSTALLED_APPS=(# Other django apps.."thumborize",# Any order is fine.)

配置基本拇指设置:

# Thumbor host URL.THUMBOR_SERVER="http://localhost:8888/"# This key must be the same used in thumbor# host to build safe URLs correctly.THUMBOR_SECURITY_KEY="MY_SECURE_KEY"# Default filters are optional.THUMBOR_DEFAULT_FILTERS={"quality":"(80)","grayscale":"()",}

测试

安装

首先克隆存储库,然后运行make install以安装开发人员需求。

运行测试

运行make test以运行测试。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java中是否有数字的默认类型   java调用一个类的方法来使用另一个类的实例   java HtmlUnit不适用于javascript处理   java需要帮助才能连接MongoDB   java如何从Maven中的src/main/resources复制文件?   java保存Int值(共享首选项)   从另一个类调用方法时,java Autowired组件出现空指针异常   java Spring JPA:PropertyAccessException 1:。。。MethodInvocationException:。'driverClassName'。。。org/postgresql/Driver:不支持的专业。次要版本52.0   java使用增强的JDO模型类在Eclipse中运行Junit测试   java如何使用eclipse IDE为junit创建可运行的jar文件   java如何在安卓中检测应用程序的启动和退出   java在其他线程可以访问静态映射时从数据库更新静态映射   java@Entitty和@EntityScan不起作用。我正在使用SpringBoot和jpa存储库,发生了很多次   java如何与google日历集成?