Created
March 28, 2014 13:07
-
-
Save south37/b8f5ea138df4588ad3ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local path, ext = | |
ngx.var.path, ngx.var.ext | |
local images_dir = "/usr/local/var/www/manga/img/" -- where images come from | |
local cache_dir = "/usr/local/var/www/manga/cache/" -- where images are cached | |
local function return_not_found(msg) | |
ngx.status = ngx.HTTP_NOT_FOUND | |
ngx.header["Content-type"] = "text/html" | |
ngx.say(msg or "not found") | |
ngx.exit(0) | |
end | |
local source_fname = images_dir .. path | |
-- make sure the file exists | |
local file = io.open(source_fname) | |
if not file then | |
return_not_found() | |
end | |
file:close() | |
local dest_fname = cache_dir .. path | |
-- resize the image | |
os.execute("/usr/local/var/www/manga/manga.out " .. source_fname .. ' ' .. dest_fname); | |
ngx.exec(ngx.var.request_uri) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment