image_filter_buffer

The `image_filter_buffer` directive sets the size of the buffer used for image processing in NGINX.

Syntaximage_filter_buffer size;
Default4k
Contexthttp, server, location
Arguments1

Description

The image_filter_buffer directive configures the amount of memory allocated for processing images when using the NGINX image filter module. This directive is essential when large images are manipulated, as it enables efficient handling and avoids excessive memory allocation that could lead to performance degradation. The buffer size allows the NGINX web server to hold image data in memory temporarily while performing operations such as resizing, cropping or altering images before they are sent to clients.

This directive can be set within the contexts of http, server, or location. When specified, it takes a single argument, which denotes the size of the buffer in bytes. If the specified size is inadequate for processing an image, NGINX may return an error or fail to manipulate the image as expected. Therefore, it is crucial to ensure that the buffer is set appropriately based on the size and type of images being served or processed.

In practice, this directive helps maintain server resource efficiency while ensuring that image operations can be performed seamlessly. Consideration should be given to the server's available memory and expected traffic when setting this value to strike a balance between performance and memory usage.

Config Example

location /images/ {
    image_filter buffer 16k;
    image_filter resize 200x200;
}

Using too small a buffer can lead to errors when processing large images.

The buffer size must be a power of two and should correspond to the memory limitations of the server.

← Back to all directives