Welcome! Log In Create A New Profile

Advanced

Re: image_filter_jpeg_quality based on size

Quintin Par
March 20, 2012 10:42PM
Thanks Appa.



On Tue, Mar 20, 2012 at 2:38 PM, Antonio P.P. Almeida <appa@perusio.net>wrote:

> > Let me rephrase my Q :-)
> >
> > Can I find out the file size in a location directive?
> > -Quintin
>
> Using set_by_lua (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)';
> }
>
> Untested. This will give you the file size on the variable $img_file_size.
>
>
> --appa
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

image_filter_jpeg_quality based on size

Quintin Par March 17, 2012 12:04AM

Re: image_filter_jpeg_quality based on size

Quintin Par March 20, 2012 03:10AM

Re: image_filter_jpeg_quality based on size

Antonio P.P. Almeida March 20, 2012 05:10AM

Re: image_filter_jpeg_quality based on size

Quintin Par March 20, 2012 10:42PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 114
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready