image_filter

The image_filter directive in NGINX allows for manipulating and filtering image files on-the-fly.

Syntaximage_filter filter_type [filter_options];
Defaultnone
Contextlocation
Arguments1-3

Description

The image_filter directive is part of the NGINX image filtering module, which provides capabilities for processing image files through defined filters. You can use this directive in a location block to enable operations such as resizing, cropping, and changing the format of images served by the web server.

The directive takes one to three arguments: the filter type, its parameters, and optional configuration flags. Filters can include options like resizing an image to specific dimensions or modifying formats to optimize loading times and reduce resource usage. Depending on the specified filters and their configurations, NGINX processes the image files dynamically as they are requested, instead of serving static copies, which can significantly improve performance and flexibility.

This directive enhances the overall user experience by allowing on-the-fly image manipulation without the need for external processing tools. This can reduce server load and increase response times, especially for applications that require various image dimensions or formats for different device types.

Config Example

location /images {
    image_filter resize 800 600;
    image_filter_jpeg_quality 85;
    image_filter_cache on;
}

Ensure that the image_filter module is included in the NGINX build; otherwise, the directive will not work.

The filter options may vary depending on the filter type specified; refer to the documentation for valid parameters.

Be cautious with caching settings; improper cache management may lead to outdated images being served.

← Back to all directives