Adding watermark to uploaded images

You can share your Lua Scripts with everybody here.

Adding watermark to uploaded images

Postby FTP » Mon Oct 19, 2009 1:26 pm

-- Description: Adding watermark to uploaded images using alpha channel
-- Author: Luke
-- Date: 2009-10-19

Code: Select all
   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)


   --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)


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:
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:
Site Admin
Tue Sep 29, 2009 6:09 am

Return to Lua scripts

Who is online

Users browsing this forum: No registered users and 1 guest