修改验证码图片生成问题
This commit is contained in:
parent
4869731a99
commit
80a4e9d478
|
|
@ -18,9 +18,9 @@ local function generate_captcha()
|
||||||
local uid = uuid.generateUuid()
|
local uid = uuid.generateUuid()
|
||||||
--picgid
|
--picgid
|
||||||
local filename = uid
|
local filename = uid
|
||||||
--图片78x26
|
--图片120x40
|
||||||
local width = 78
|
local width = 120
|
||||||
local height = 26
|
local height = 40
|
||||||
-- 创建画布
|
-- 创建画布
|
||||||
local im = gd.createTrueColor(width, height)
|
local im = gd.createTrueColor(width, height)
|
||||||
|
|
||||||
|
|
@ -44,17 +44,17 @@ local function generate_captcha()
|
||||||
local x = 10 + (i - 1) * 25 + math.random(-5,5)
|
local x = 10 + (i - 1) * 25 + math.random(-5,5)
|
||||||
local y = 10 + math.random(-5,5)
|
local y = 10 + math.random(-5,5)
|
||||||
local angle = math.random(-20, 20)
|
local angle = math.random(-20, 20)
|
||||||
im:stringFT(black, "Arial:bold", 18, angle, x, 30, char)
|
im:stringFT(black, "Arial:bold", 18, angle, x, y, char)
|
||||||
end
|
end
|
||||||
-- 添加干扰线
|
-- 添加干扰线
|
||||||
for i = 1, 5 do
|
for i = 1, 5 do
|
||||||
local line_color = im:colorAllocate(math.random(0,255), math.random(0,255), math.random(0,255))
|
local line_color = im:colorAllocate(math.random(0,255), math.random(0,255), math.random(0,255))
|
||||||
im:line(math.random(0, height), math.random(0, width), math.random(0,height), math.random(0, width), line_color)
|
im:line(math.random(0, width), math.random(0, height), math.random(0,width), math.random(0, height), line_color)
|
||||||
end
|
end
|
||||||
-- 添加噪点
|
-- 添加噪点
|
||||||
for i = 1, 100 do
|
for i = 1, 100 do
|
||||||
local dot_color = im:colorAllocate(math.random(0,255), math.random(0,255), math.random(0,255))
|
local dot_color = im:colorAllocate(math.random(0,255), math.random(0,255), math.random(0,255))
|
||||||
im:setPixel(math.random(0, height), math.random(0, width), dot_color)
|
im:setPixel(math.random(0, width), math.random(0, height), dot_color)
|
||||||
end
|
end
|
||||||
-- 将图片转换为PNG格式的二进制数据
|
-- 将图片转换为PNG格式的二进制数据
|
||||||
local png_data = im:pngStr(75)
|
local png_data = im:pngStr(75)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user