This article is a mirror article of machine translation, please click here to jump to the original article.

View: 20940|Reply: 2

[Web] Nginx implements the function of adding watermark to images

[Copy link]
Posted on 9/6/2021 8:07:21 PM | | | |
I used Alibaba Cloud to purchase a pay-as-you-go server, the system is: centos 7, first, install the necessary package, the command is as follows:


Review:

nginx adds third-party modules, as well as enabling modules that are natively supported by nginx
https://www.itsvse.com/thread-4713-1-1.html

Centos installation nginx-1.10.2 tutorial
https://www.itsvse.com/thread-3267-1-1.html

Centos installation nginx-1.14.0 tutorial
https://www.itsvse.com/thread-4855-1-1.html

Install nginx service with CentOS source code
https://www.itsvse.com/thread-10058-1-1.html


Download nginx-1.20.1

Download using the wget command, as follows:



Unzip nginx-1.20.1

The command is as follows:



Download Nginx-image-filter-watermark

nginx-image-filter-watermark patches Nginx with watermarking. http_image_filter_module-based patches,It can convert images in JPEG, GIF, PNG, and WebP formats

Should work fine on nginx >= 1.11.6. GitHub address:The hyperlink login is visible.

It can be understood that the ngx_http_image_filter_module module that comes with nginx does not have an image watermark function, and this module is an enhanced version of the nginx image module

ngx_http_image_filter_module:The hyperlink login is visible.

The command is as follows:




Compile and install

configure the command is as follows:

The error is as follows:

./configure: error: the HTTP image filter module requires the GD library.
You can either do not enable the module or install the libraries.
Install the GD library with the following command:

Re-execute the ./configure command again, and then do the following:





Turn on the image watermark

Create a site directory with the following command:

Start and restart the nginx service command (omitted).

I uploaded the image watermark watermark.png image under the /data directory. (omitted)

At the beginning of my nginx.conf configuration file, it looks like this:

image_filter_watermark_position - Watermark position, the available values are top-left|top-right|bottom-right|bottom-left|right-center|left-center|bottom-center|top-center|center-center|center-random.

I triedChange a notepad file suffix to a.jpg and upload oneBMP, HTML formatfile, or accessing a non-existent file via nginx, will report a 415 error, as shown in the figure below:
415 Unsupported Media Type




Try modifying the configuration file as follows, only blocking files in jpg, jpeg, png format:





(End)




Previous:Install nginx service with CentOS source code
Next:【Practical Practice】XXL-JOB Distributed Task Scheduling Platform Use and Development Tutorial
Posted on 3/31/2023 11:53:56 PM |
Thank you to the owner for your hard work and learning
Posted on 3/13/2025 2:56:16 PM |
Thank you to the owner for your hard work and learning
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com