https://www.cnblogs.com/jicki/p/5546972.html
Nginx Image Module image thumbnail watermark processing module
Download Tengine
tar- zxvf tengine-1.4.5.tar.gz
cd tengine-1.4.5
Download Nginx
tar -zxvf nginx-1.4.0.tar. gz
cd nginx-1.4.0
wget https://github.com/3078825/nginx-image/archive/master.zip
unzip master .zip
./configure –add-module=/opt/software/nginx-image-master
make
make install
< p>
Configuration method
Open nginx.conf
In
location / {
#Add the following configuration
Image on;
image_output on;
}
Or open in designated directory
location /upload {
Image on;
image_output on;
}
Other parameter description:
image on/off Whether to turn on the thumbnail function, the default is off
Whether image_backend on/off is turned on Mirror service, when this function is enabled, if you request a picture that does not exist in the directory (judging the original picture), the original picture will be automatically downloaded from the mirror server address
image_backend_server mirror server address
image_output on /off Whether to directly process the output without generating the image, the default value is off
image_jpeg_quality 75 The default quality of the generated JPEG image is 75
image_water on/off Whether to enable the watermark function
< p>image_water_type 0/1 Watermark type 0: Image watermark 1: Text watermark
image_water_min 300 300 The watermark is only added when the image width is 300 and the height is 300.
image_water_pos 0-9 Watermark position default The value 90 is a random position, 1 is the top left, 2 is the top center, 3 is the top right, 4 is the middle left, 5 is the middle center, 6 is the middle right, 7 is the bottom left, and 8 is the bottom center. , 9 is the bottom right.
image_water_file watermark file (jpg/png/gif), watermark image with absolute path or relative path
image_water_transparent watermark transparency, default 20
image_water_text watermark text “Power By Vampire”
image_water_font_size default watermark size 5
image_water_font text watermark font file path
image_water_color watermark text color, default# 000000
Call instructions
< p>
< p>It is assumed here that your nginx access address is http://127.0.0.1/
and there is a picture of test.jpg in the root directory of the nginx website
via access
http://127.0.0.1/test.jpg!c300x200.jpg will generate/output a 300×200 thumbnail of test.jpg
where c is the parameter for generating image thumbnails and 300 is The width 200 of the generated thumbnail is the height of the generated thumbnail
A total of four different types of thumbnails can be generated.
Support jpeg / png / gif (Gif is turned into a static picture after it is generated)
The C parameter starts at 10% of the height of the picture according to the requested aspect ratio to intercept the picture, and then zoom/zoom in To the specified size (the size of the image thumbnail is equal to the requested width and height)
The M parameter centers the screenshot image according to the requested aspect ratio, and then zooms/enlarges to the specified size (the size of the image thumbnail is equal to the requested width and height)
The T parameter is scaled/zoomed in proportion to the specified size according to the requested aspect ratio (the size of the image thumbnail may be smaller than the requested width and height)
The W parameter is scaled according to the requested aspect ratio/ Zoom in to the specified size, fill the blank with a white background color (the size of the image thumbnail is equal to the requested width and height)
Call example
< p>
http://127.0.0.1/test.jpg!c300x300.jpg
http://127.0.0.1/test.jpg!t300x300.jpg
http://127.0.0.1/test.jpg!m300x300.jpg
http://127.0.0.1/test.jpg!w300x300.jpg
http:/ /127.0.0.1/test.c300x300.jpg
http://127.0.0.1/test.t300x300.jpg
http://127.0.0.1/test.m300x300.jpg
http://127.0.0.1/test.w300x300.jpg
https://www.cnblogs.com/jicki/p/5546972.html< /pre>
https://www.cnblogs.com/jic ki/p/5546972.html
Nginx Image Module image thumbnail watermark processing module< /p>
Download Tengine
tar -zxvf tengine-1.4.5.tar.gz
cd tengine-1.4.5
Download Nginx
tar -zxvf nginx-1.4.0.tar.gz
cd nginx-1.4.0
wget https:// github.com/3078825/nginx-image/archive/master.zip
unzip master.zip
./configure --add-module=/opt/software/nginx-image -master
make
make install
Configuration method
< /p>
Open nginx.conf
In
location / {< /p>
#Add the following configuration
Image on;
Image_output on;
}
< p>Or open in the specified directory
location /upload {
image on;
image_output on ;
}
Other parameter description:
p>
image on/off Whether to enable the thumbnail function, the default is off
image_backend on/off Whether to enable the mirroring service, when the function is enabled, the requested directory does not exist Picture (judging the original picture), it will be automatically mirrored Server address to download the original image
image_backend_server mirror server address
image_output on/off Whether the image is not generated but directly processed and output is the default off
image_jpeg_quality 75 Generate JPEG image The quality default value of 75
image_water on/off whether to enable the watermark function
image_water_type 0/1 watermark type 0: image watermark 1: text watermark
image_water_min 300 300 The watermark is added only when the image width is 300 and the height is 300.
image_water_pos 0-9 The default value of watermark position is 9 0 is a random position, 1 is the top left, 2 is the top center, 3 is the top right, 4 is The middle part is left, 5 is middle middle, 6 is middle right, 7 is bottom left, 8 is bottom middle, 9 is bottom right
image_water_file watermark file (jpg/png/gif), Watermark image with absolute path or relative path
image_water_transparent watermark transparency, default 20
image_water_text watermark text "Power By Vampire"
image_water_font_size default watermark size 5
p>
image_water_font text watermark font file path
image_water_color watermark text color, default #000000
Calling instructions
Here, suppose your nginx access address is http://127.0.0.1/
And there is a picture of test.jpg in the root directory of the nginx website
By visiting
http://127.0.0.1/test.jpg!c300x200. jpg will generate/output a 300x200 thumbnail of test.jpg
where c is the parameter for generating image thumbnails, 300 is the width of the generated thumbnail, 200 is the height of the generated thumbnail
A total of four different types of thumbnails can be generated.
Support jpeg / png / gif (Gif is turned into a static picture after it is generated)
The C parameter starts at 10% of the height of the picture according to the requested aspect ratio to intercept the picture, and then zoom/zoom in To the specified size (the size of the image thumbnail is equal to the requested width and height)
The M parameter centers the screenshot image according to the requested aspect ratio, and then zooms/enlarges to the specified size (the size of the image thumbnail is equal to the requested width and height)
The T parameter is scaled/zoomed in proportion to the specified size according to the requested aspect ratio (the size of the image thumbnail may be smaller than the requested width and height)
The W parameter is scaled according to the requested aspect ratio/ Zoom in to the specified size, fill the blank with a white background color (the size of the image thumbnail is equal to the requested width and height)
Call example
< p>
http://127.0.0.1/test.jpg!c300x300.jpg
http://127.0.0.1/test.jpg!t300x300.jpg
http://127.0.0.1/test.jpg!m300x300.jpg
http://127.0.0.1/test.jpg!w300x300.jpg
http:/ /127.0.0.1/test.c300x300.jpg
http://127.0.0.1/test.t300x300.jpg
http://127.0.0.1/test.m300x300.jpg
http://127.0.0.1/test.w300x300.jpg
Nginx Image Module image thumbnail watermark processing module
Download Tengine
tar -zxvf tengine-1.4.5.tar.gz
cd tengine-1.4.5
< p> Download Nginx
tar -zxvf nginx-1.4.0.tar.gz
cd nginx-1.4.0
wget https://github. com/3078825/nginx-image/archive/master.zip
unzip master.zip p>
./configure --add-module=/opt/software/nginx-image-master
make
make install
p>
Configuration method
Open nginx.conf
In
location / {
#Add the following configuration
Image on;
Image_output on;
}
Or open the specified directory
location /upload {
image on;
image_output on;
}
< p>
Other parameter description:
image on/off Whether to turn on the thumbnail function, the default is off
image_backend on/off Whether to turn on the mirroring service, when this function is turned on, if you request a picture that does not exist in the directory (judging the original picture), the original picture will be automatically downloaded from the mirror server address
image_backend_server mirror server address
If image_output on/off does not generate images but directly processed and output the default off
image_jpeg_quality 75 The default quality of the generated JPEG images is 75
image_water on/off Whether to enable the watermark function
image_water_type 0/1 Watermark type 0: image watermark 1: text watermark
image_water_min 300 300 image width 300 height 300 only add watermark
< p>image_water_pos 0-9 The default value of watermark position is 9 0 is a random position, 1 is the top left, 2 is the top center, 3 is the top right, 4 is the middle left, 5 is the middle center, 6 is the middle right, 7 is The bottom is left, 8 is the bottom is centered, and 9 is the bottom is right
image_water_file watermark file (jpg/pn g/gif), watermark image with absolute path or relative path
image_water_transparent watermark transparency, default 20
image_water_text watermark text "Power By Vampire"
image_water_font_size watermark The default size is 5
image_water_font text watermark font file path
image_water_color watermark text color, default #000000
< p>
Calling instructions
Here, suppose your nginx access address is http:/ /127.0.0.1/
And there is a picture of test.jpg in the root directory of the nginx website
By visiting
http://127.0.0.1/test .jpg!c300x200.jpg will generate/output a 300x200 thumbnail of test.jpg
where c is the parameter for generating the thumbnail of the picture, 300 is the width of the generated thumbnail and 200 is the height of the generated thumbnail< /p>
A total of four different types of thumbnails can be generated.
Support jpeg / png / gif (Gif is turned into a static picture after it is generated)
The C parameter starts at 10% of the height of the picture according to the requested aspect ratio to intercept the picture, and then zoom/zoom in To the specified size (the size of the image thumbnail is equal to the requested width and height)
The M parameter centers the screenshot image according to the requested aspect ratio, and then zooms/enlarges to the specified size (the size of the image thumbnail is equal to the requested width and height)
The T parameter is scaled/zoomed in proportion to the specified size according to the requested aspect ratio (the size of the image thumbnail may be smaller than the requested width and height)
The W parameter is scaled according to the requested aspect ratio/ Zoom in to the specified size, fill the blank with a white background color (the size of the image thumbnail is equal to the requested width and height)
Call example
< p>
http://127.0.0.1/test.jpg!c300x300.jpg
http://127.0.0.1/test.jpg!t300x300.jpg
http://127.0.0.1/test.jpg!m300x300.jpg
http://127.0.0.1/test.jpg!w300x300.jpg
http:/ /127.0.0.1/test.c300x300.jpg
http://127.0.0.1/test.t300x300.jpg
http://127.0.0.1/test.m300x300.jpg
http://127.0.0.1/test.w300x300.jpg