日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

OpenResty+lua+GraphicsMagick生成缩略图

發布時間:2024/6/18 编程问答 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 OpenResty+lua+GraphicsMagick生成缩略图 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、安裝GraphicsMagick

下載地址:http://sourceforge.net/projects/graphicsmagick/files/graphicsmagick/1.3.19/GraphicsMagick-1.3.19.tar.gz/download?use_mirror=ncu

tar zxvf GraphicsMagick-1.3.19.tar.gz cd GraphicsMagick-1.3.19 make make install

安裝依賴包Ghostscript,不安裝的話加水印會找不到字體

yum install -y ghostscript

?2、配置nginx.conf

location /down/PersonImg {set $image_root /usr/local/openresty/nginx/html;set $file "$image_root$uri";rewrite_by_lua ' local index = string.find(ngx.var.uri, "([0-9]+)x([0-9]+)");local originalUri = string.sub(ngx.var.uri, 0, index-2);local area = string.sub(ngx.var.uri, index);index = string.find(area, "([.])");area = string.sub(area, 0, index-1);local image_sizes = {"140x140", "800x800", "90x90"};function table.contains(table, element)for _, value in pairs(table) doif value == element thenreturn trueendendreturn falseendif table.contains(image_sizes, area) thenlocal command = "/usr/local/GraphicsMagick/bin/gm convert " .. ngx.var.image_root .. originalUri .. " -thumbnail " .. area .. " -gravity center -extent " .. area .. " " .. ngx.var.file;os.execute(command);elsengx.exit(401)end';alias /usr/local/openresty/nginx/html/down/PersonImg/;}

3、訪問
http://10.10.3.221/down/PersonImg/3AFAE457-FDC8-27D3-E2B5-6C10A145A3A6.jpg.90x90.jpg

4、要加水印的話命令如下

/usr/local/GraphicsMagick/bin/gm convert /usr/local/openresty/nginx/html/down/PersonImg/3AFAE457-FDC8-27D3-E2B5-6C10A145A3A6.jpg -font ArialBold -pointsize 45 -fill red -draw "text 10,10 dsideal" /usr/local/openresty/nginx/html/down/PersonImg/3AFAE457-FDC8-27D3-E2B5-6C10A145A3A61111.jpg

?

?

?

轉載于:https://www.cnblogs.com/kgdxpr/p/3837264.html

總結

以上是生活随笔為你收集整理的OpenResty+lua+GraphicsMagick生成缩略图的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。