사진 인쇄
location ~* /([0-9a-z\/]+)/(.*).(jpg|jpeg|png|bmp|webp|JPG)_sy(\.|\_)(.*)$ {
lua_code_cache off;
default_type text/html;
root /filesystem/;
set $image_root /filesystem/;
set $new_img_path /filesystem/sy/;
set $ways $1;
set $fileName $2.$3;
set $file $image_root$uri;
set $sy $4;
set $other $5;
if (!-f $file) {
rewrite_by_lua_file /file_lua/sy.lua;
}
}
Lua
local img_path = ngx.var.image_root .. ngx.var.ways .. "/" .. ngx.var.fileName
local new_img_path = ngx.var.new_img_path .. ngx.var.ways .. "/" .. ngx.var.fileName
local thumbnail_path = ngx.var.file
local img_dir = ngx.var.new_img_path .. ngx.var.ways
local logo = ngx.var.new_img_path .. "logo.png"
local gm = "/usr/bin/gm "
local function mkdir_img_path(img_dir)
--
local cmd = "mkdir -p " .. img_dir
os.execute(cmd)
end
local function get_wh()
--
local cmd = gm .. "identify " .. img_path
local img_origin = io.popen(cmd)
local img_info = img_origin:read("*all")
local w_h = string.match(img_info,"%d+x%d+")
local x = string.find(w_h,"x")
local w = string.sub(w_h,0,(x-1))
local h = string.sub(w_h,(x+1),string.len(w_h))
return w,h
end
local function shuiyin(in_path,out_path)
mkdir_img_path(img_dir)
local w,h = get_wh()
if tonumber(w) >= 400 or tonumber(h) >= 400 then
cmd = gm .. "composite -gravity southeast -geometry +5+5 -dissolve 100 " .. logo .. " " .. in_path .. " " .. out_path
os.execute(cmd)
else
cmd = "cp " .. in_path .. " " .. out_path
end
end
local function resiz(in_path,out_path,thumbnail,quality)
if not quality then
quality = 100
end
mkdir_img_path(img_dir)
if thumbnail then
local cmd = gm .."convert -quality " .. quality .. "% " .. in_path .. " -thumbnail " .. thumbnail .. " " .. out_path
os.execute(cmd)
end
end
local sy = ngx.var.sy
local other = ngx.var.other
local a = string.find(sy, "_")
if a == 1 then
thumbnail = string.match(other,"%d+x%d+")
local in_path = img_path
local out_path = new_img_path .. thumbnail
resiz(in_path,out_path,thumbnail,quality)
local in_path = new_img_path .. thumbnail
local out_path = thumbnail_path
shuiyin(in_path,out_path)
elseif a == nil then
local in_path = img_path
local out_path = thumbnail_path
shuiyin(in_path,out_path)
end
몇 년 전에 저희 사이트 안 단 과 지 업 아 이 디 에 게 해 준 워 터 마크 는 이렇게 했 습 니 다. 나중에 더 좋 은 방법 이 생 겨 서 무시 하고 꺼 내 서 교 류 를 했 습 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
nginx 의 if 내장nginx 설정 에 서 는 if 조건 의 논리 와 & 논리 또는 | 연산 을 지원 하지 않 으 며, if 의 내장 문법 을 지원 하지 않 습 니 다. 그렇지 않 으 면 다음 과 같은 오 류 를 보고 합 니 다: ng...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.