zengde / nginx_image_filter

Nginx image_filter module with ability to add placement for cropped images.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nginx image_filter

This is basically the same image_filter module, but with ability to place cropped images.

Goals

Humans usually have faces at the top of their photos, but nginx always crop image to center. We needed to make it more flexible.

Configuration

This module has additional configuration option:

image_filter_crop_offset {left,center,right} {top,center,bottom};

build

download nginx source,override the ngx_http_image_filter_module.c

  • nginx installed
nginx -V
./configure // copy config from nginx-v
make

replace objs/modules/ngx_http_image_filter_module.so

  • nginx not installed
./configure --with-http_image_filter_module=dynamic
// other configs
make && make install

Examples

conf

example conf

http://localhost:8888/crop/768/example.jpg

Vertical images

  • Original image

Original vertical image

  • Crop and align to top: image_filter_crop_offset center top;

Aligned to top vertical image

  • Crop and align to center (original behavior): image_filter_crop_offset center center;

Aligned to center vertical image

  • Crop and align to bottom: image_filter_crop_offset center bottom;

Aligned to bottom vertical image

Horizontal images

  • Original image

Original horizontal image

  • Crop and align to left: image_filter_crop_offset left center;

Aligned to left horizontal image

  • Crop and align to center (original behavior): image_filter_crop_offset center center;

Aligned to center horizontal image

  • Crop and align to right: image_filter_crop_offset right center;

Aligned to right horizontal image

ChangLog

2019/10/15 base on nginx 1.13.0/src/http/modules/ngx_http_image_filter_module.c,works on nginx-1.10.3 above

Authors

About

Nginx image_filter module with ability to add placement for cropped images.


Languages

Language:C 100.0%