Nginx Image Filter Processing module Http_image_filter_module installation configuration note

Source: Internet
Author: User
Tags image filter

Nginx Image Filter Processing module Http_image_filter_module installation configuration note

Http_image_filter_module is an integrated image processing module provided by Nginx, Support nginx-0.7.54 later version, in the site traffic is not very high disk limited do not want to generate redundant picture files, you can use it to zoom the picture, rotate the picture, verify the validity of the picture and get the picture width and picture type information, because it is the result of the instant calculation, so the site visit is not recommended to use.

Installation is still very simple, the default Httpimagefiltermodule module is not compiled into Nginx, so in configure time to specify

./configure arguments:--prefix=/usr/local/nginx--with-http_image_filter_module

The Ps:httpimagefiltermodule module needs to rely on gd-devel support and can be easily installed using Yum or Apt-get, if no return "/configure:error:the HTTP image Filter module requires the GD library. Error

Yum Install gd-develapt-get install libgd2-xpm Libgd2-xpm-dev

Make&&make install after can be configured, do the simplest configuration, first let the module can run up ^ ^

Location ~/simg/.*\.jpg$ {    #proxy_pass     http://10.11.11.11;    #rewrite "/simg/(. *\.jpg) $"/img/$1 break;    Image_filter   resize  ;    Error_page     415   =/empty;}

Finally open Nginx, so access to the/simg/directory image, will be the height of up to 100 and the width of up to 100 by the original proportion of the interception, and output to the browser. Of course, you can also turn on the rewrite to read the source file in another directory, if not on a machine can open proxy_pass, and add rewrite.

Http_image_filter_module supports 5 types of commands:

Image_filter: Test image file Legitimacy (Image_filter test); 3 angle rotate picture (image_filter rotate 90 | 180 | 270); Output the width, height, type (image_filter size) of the picture in JSON format, the minimum edge shrinks the picture to maintain the picture integrity (resize width height), and the maximum edge to zoom the picture after the extra portion (image_filter crop [width] [height]);

Image_filter_jpeg_quality: Set the compression quality ratio for JPEG images (the official top recommendation is set to 95, but usually 75 is available);

Image_filter_buffer: Limit picture maximum read size, default is 1M;

Image_filter_transparency: The transparency of PNG images used to disable GIF and palette-based to improve image quality.

Image_filter_sharpen: this directive in nginx-1.1.8 and 1.0.11 after the increase, at present do not know what to do with, have known friends or find out what is wrong in the text of friends please leave a message to me ^ ^

Nginx Image Filter Processing module Http_image_filter_module installation configuration note

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.