jpeg_filter

The `jpeg_filter` directive enables or disables the JPEG filter module for processing images in an NGINX location block.

Syntaxjpeg_filter on | off;
Defaultoff
Contextlocation
Argumentsflag

Description

The jpeg_filter directive controls the activation of the JPEG filter module in NGINX, which allows for on-the-fly modifications of JPEG images served by the server. When enabled (set to on), the module uses the libmodjpeg library to apply various transformations such as overlays, which can include images or watermarks on top of the original JPEG without modifying the underlying file. This is particularly useful for scenarios where dynamic adjustments are needed, such as adding logos or watermarks to images as they are delivered to users, thereby avoiding the need to preprocess all existing images.

This directive can be set within a location block, and it accepts a simple flag as its parameter: on to enable the module or off to disable it. It is important to ensure that the proper contexts and dependencies are in place for the filter to function correctly, particularly the surrounding configuration settings that pertain to image processing and memory settings. By optimizing images and handling them effectively, NGINX can serve modified images swiftly without additional load on a back-end process.

Using jpeg_filter, administrators can conveniently manage image outputs based on server conditions, user roles, or application need. However, if the processing fails, it may fall back to serving the original image depending if jpeg_filter_graceful is enabled or not, giving an added redundancy to keep user experience consistent and reliable.

Config Example

location /images {
    jpeg_filter on;
    jpeg_filter_effect grayscale;
    jpeg_filter_dropon_file /path/to/logo.png;
}

Ensure that libmodjpeg is properly installed and accessible; otherwise, the filter will not work.

Remember that enabling the JPEG filter may increase server load due to on-the-fly image processing.

Be cautious with the filter's processing capabilities, as incorrect settings may lead to performance issues or degraded image quality.

← Back to all directives