All Projects → linsir → ngx-lua-images

linsir / ngx-lua-images

Licence: other
OpenResty (nginx+lua)+Ceph+GraphicsMagick 动态生成处理图片

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to ngx-lua-images

Upyun Resty
UPYUN's open source software for OpenResty development
Stars: ✭ 150 (+341.18%)
Mutual labels:  openresty
Dice
前后端分离Blog系统,采用Nuxt、Vue 2.x 和 SpringBoot 全家桶。
Stars: ✭ 222 (+552.94%)
Mutual labels:  openresty
ceph-formula
docs.saltstack.com/en/latest/topics/development/conventions/formulas.html
Stars: ✭ 14 (-58.82%)
Mutual labels:  ceph
Lua Resty Repl
Interactive console (REPL) for Openresty and luajit code
Stars: ✭ 165 (+385.29%)
Mutual labels:  openresty
Lua Resty Redis Connector
Connection utilities for lua-resty-redis
Stars: ✭ 186 (+447.06%)
Mutual labels:  openresty
Lapis
A web framework for Lua and OpenResty written in MoonScript
Stars: ✭ 2,621 (+7608.82%)
Mutual labels:  openresty
Lua Resty Auto Ssl
On the fly (and free) SSL registration and renewal inside OpenResty/nginx with Let's Encrypt.
Stars: ✭ 1,786 (+5152.94%)
Mutual labels:  openresty
mocka
Mocka - The complete testing framework for LUA and Nginx
Stars: ✭ 26 (-23.53%)
Mutual labels:  openresty
Lnmp
LEMP stack/LAMP stack/LNMP stack installation scripts for CentOS/Redhat Debian and Ubuntu
Stars: ✭ 2,488 (+7217.65%)
Mutual labels:  openresty
Libvips
A fast image processing library with low memory needs.
Stars: ✭ 6,094 (+17823.53%)
Mutual labels:  graphicsmagick
Lua Resty Jit Uuid
Fast and dependency-free UUID library for LuaJIT/ngx_lua
Stars: ✭ 169 (+397.06%)
Mutual labels:  openresty
Orange
OpenResty/Nginx Gateway for API Monitoring and Management.
Stars: ✭ 2,208 (+6394.12%)
Mutual labels:  openresty
erl gm
An Erlang GraphicsMagick wrapper
Stars: ✭ 29 (-14.71%)
Mutual labels:  graphicsmagick
Oneinstack
OneinStack - A PHP/JAVA Deployment Tool
Stars: ✭ 1,983 (+5732.35%)
Mutual labels:  openresty
crowbar-core
Core deployment for Crowbar
Stars: ✭ 16 (-52.94%)
Mutual labels:  ceph
Ngx Oauth
OAuth 2.0 proxy for nginx written in Lua.
Stars: ✭ 146 (+329.41%)
Mutual labels:  openresty
Apicast
3scale API Gateway
Stars: ✭ 225 (+561.76%)
Mutual labels:  openresty
dovecot-ceph-plugin
Dovecot plugin for storing mails in a Ceph cluster
Stars: ✭ 116 (+241.18%)
Mutual labels:  ceph
nginx-lua
Nginx 1.19+ with LUA support based on Alpine Linux, Amazon Linux, Debian, Fedora and Ubuntu.
Stars: ✭ 112 (+229.41%)
Mutual labels:  openresty
imgout
On the fly thumbnail generator microservice using Elixir/OTP. (with Heroku Deploy Button)
Stars: ✭ 58 (+70.59%)
Mutual labels:  graphicsmagick

ngx-lua-images

OpenResty (nginx+lua) + ceph + GraphicsMagick ,一个类似于 zimg, 动态生成处理图片的图片服务器。

Getting Started

整个架构类似于zimg, 在http层加了redis缓存,处理后的保存为文件也算是个缓存,可以写个crontab脚本定期清理不常访问的缓存图片。

图片存储路径的规划方案。

借鉴 zimg 的方案,存储路径采用2级子目录的方案。由于 Linux 同目录下的子目录数最好不要超过2000个,再加上 MD5 的值本身就是32位十六进制数,zimg就采取了一种非常取巧的方式:根据 MD5 的前六位进行哈希,1-3位转换为十六进制数后除以4,范围正好落在1024以内,以这个数作为第一级子目录;4-6位同样处理,作为第二级子目录;二级子目录下是以 MD5 命名的文件夹,每个MD5文件夹内存储图片的原图和其他根据需要存储的版本,假设一个图片平均占用空间200KB,一台服务器支持的总容量就可以计算出来了:

1024 * 1024 * 1024 * 200KB = 200TB

Ceph

一个 Linux PB 级分布式文件系统

  • 可轻松扩展到数 PB 容量
  • 对多种工作负载的高性能(每秒输入/输出操作[IOPS]和带宽)
  • 高可靠性

Installing

GraphicsMagick OpenResty

sudo apt-get install GraphicsMagick libgraphicsmagick1-dev

or 

yum install GraphicsMagick GraphicsMagick-devel -y

## openresty
tar xvf ngx_openresty-VERSION.tar.gz
cd ngx_openresty-VERSION/
./configure
make
make install

And

cd /usr/local/openresty/nginx/conf
mkdir conf.d

add "include conf.d/*.conf;" into nginx.conf

# last, in ngx-lua_images folder.

bash deploy.sh

# and add images folder, change it at config.lua if you need.

mkdir /home/files/images/
chown -R {nginx_user}/home/fiels/images

上传图片

http://localhost:8000/static/image-upload/ 

上传成功。

如果没有错误,就可以访问了。

http://localhost:8000/fffc929444a9fb7eb754217cfd7b0d58?w=500&h=500&g=1&x=0&y=0&r=45&q=75&f=jpeg
http://localhost:8000/get_info?md5=fffc929444a9fb7eb754217cfd7b0d58

ceph

  1. 安装:略
  2. configure:
    • 修改./vendor/cephs3.lua的配置文件。
    • 修改confi.json的ceph_mode为true。
    • 删除nginx.conf的location /upload 段。

上传文件请使用ceph(s3 or swift) sdk上传文件和管理bucket.

Authors

  • Linsir - Initial work - Linsir

See also the list of contributors who participated in this project.

Benchmark

see the Benchmark.md file for details

License

This project is licensed under the MIT License

Acknowledgments

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].