搭建独立图像处理服务(Thumbor)

本文介绍了基于Python的开源图像处理服务Thumbor,它支持图片裁剪、缩放、翻转和滤镜等功能。通过特殊的URL结构,用户可以方便地创建和定制缩略图。Thumbor支持PIL、GraphicsMagick和OpenCV作为图像处理引擎,并提供了多种存储选项。文章详细讲解了安装、启动、测试过程,以及安全模式、URL签名、智能裁剪和图片上传等功能的使用。
摘要由CSDN通过智能技术生成
Thumbor是基于Python的开源的On-Demand图片处理服务,可以实现图片裁剪crop、缩放resize、翻转flip、滤镜filter,甚至是人脸识别。

官网:[url=https://github.com/thumbor/thumbor]https://github.com/thumbor/thumbor[/url]

目前版本: 6.3.2

图像处理是系统开发中的必备组件,各种开发语言都内置图像处理API,也有大量的开源图像处理库做补充。

[1] 图像变换引擎([url=https://www.imagemagick.org/]ImageMagick[/url]、[url=http://www.graphicsmagick.org/]Graphicsmagick[/url]、[url=http://opencv.org/]OpenCV[/url])
[2] 图像优化工具([url=http://www.jpegmini.com/]JPEGMini[/url]、[url=https://tinypng.com/]TinyPNG[/url]、[url=https://imageoptim.com/]ImageOptim[/url]、[url=https://pngmini.com/]ImageAlpha[/url]、[url=https://pngquant.org/]pngquant[/url]、[url=https://github.com/mozilla/mozjpeg]MozJPEG[/url])
[3] 图像处理系统([url=https://github.com/agschwender/pilbox]Pilbox[/url]、[url=https://github.com/thumbor/thumbor]Thumbor[/url])

Thumbor通过特殊构成的URL来创建缩略图,比如:
[quote]http://thumbor.example.com/320x240/http://images.example.com/llamas.jpg[/quote]
含义是:Thumbor服务器thumbor.example.com通过HTTP从images.example.com获取图像llamas.jpg,将其缩放到320x240之后返回图像数据。

Thumbor内部支持以下三种图像变换引擎:
PIL (Python Image Library)、GraphicsMagick (pgmagick)、OpenCV

Thumbor存储图片支持的方式有File、Memcached、MongoDB、Redis。根据实际的使用情况选择存储方式。默认选用文件系统的存储方式。

具体详细的使用方法可以参考官方文档: [url=http://thumbor.readthedocs.io/en/latest/index.html]http://thumbor.readthedocs.io/en/latest/index.html[/url]

需要注意的是:Thumbor目前还不支持Python3!
[quote] File "/usr/local/tensorflow/lib/python3.5/site-packages/thumbor/context.py", line 293
print "Joining threads...."
SyntaxError: Missing parentheses in call to 'print'[/quote]
print "Hello world"    # python 2.x
print("Hello world") # python 3.x


[b](1)安装[/b]

# python -V
Python 2.7.5

# pip search thumbor
thumbor (6.3.2) - thumbor is an open-source photo thumbnail service by globo.com

# pip install thumbor
# pip install -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com thumbor


[b](2)启动[/b]

# mkdir /usr/local/thumbor
# thumbor-config > /usr/local/thumbor/thumbor.conf
# cp /usr/local/thumbor/thumbor.conf /usr/local/thumbor/thumbor.conf.default
# thumbor --port=8888 --conf=/usr/local/thumbor/thumbor.conf


以下警告提示是没有安装opencv。
[quote]2017-08-15 15:34:02 thumbor:WARNING Module thumbor.filters.distributed_collage could not be imported: No module named cv2[/quote]

[b](3)测试[/b]

- 原图
[color=blue]http://desk.fd.zol-img.com.cn/t_s1920x1200c5/g5/M00/01/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值