Skip to content

Instantly share code, notes, and snippets.

@perusio
Created March 20, 2012 09:17
Show Gist options
  • Select an option

  • Save perusio/2133228 to your computer and use it in GitHub Desktop.

Select an option

Save perusio/2133228 to your computer and use it in GitHub Desktop.

Revisions

  1. perusio renamed this gist Mar 20, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. perusio created this gist Mar 20, 2012.
    12 changes: 12 additions & 0 deletions gistfile1.lua
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    ## Get the size of the image file using Lua.
    ## Cf. http://wiki.nginx.org/HttpLuaModule#set_by_lua.
    location ~* \.(?:gif|jpe?g|png)$ {
    set_by_lua $img_file_size '
    function fsize (file)
    local current = file:seek() -- get current position
    local size = file:seek("end") -- get file size
    file:seek("set", current) -- restore position
    return size
    end
    fsize(ngx.var.request_filename)';
    }