-- Author: Luke
-- Date: 2009-10-19
Code: Select all
do
require "gd"
--source image filename
local filename = string.gsub("%PathName", "\\","/")
--source image surface
local im = nil
--get the file extension
local suffix = string.lower(string.sub(filename,-4))
if suffix == ".jpg" or suffix == "jpeg" then
im = gd.createFromJpeg(filename)
elseif suffix == ".png" then
im = gd.createFromPng(filename)
elseif suffix == ".gif" then
im = gd.createFromGif(filename)
else
return
end
assert(im)
--create logo surface
imlogo = gd.createFromPng("d:/mylogo.png")
--draw transparent(30% opacity) logo on source surface
sx, sy = imlogo:sizeXY()
gd.copyMerge(im, imlogo, 10, 10, 0, 0, sx, sy, 30)
im:png(filename)
end
You may add above lua scripts to the FTP's onFileUploaded event.
Those scirpt uses a external image library "Lua-GD", you can visit their home page at: http://luaforge.net/projects/lua-gd/
We also provide a archived file with "Lua-GD" libs, you can download and unzip it into the working directory of Wing FTP Server. The download URL: https://www.wftpserver.com/bbsres/libgd.zip