jpeg_filter_arithmetric
The `jpeg_filter_arithmetric` directive enables or disables arithmetic coding in the JPEG filter module.
Description
The jpeg_filter_arithmetric directive controls whether arithmetic coding is applied when generating JPEG images. Arithmetic coding is an advanced compression technique that can potentially improve the quality of the resulting JPEGs by allowing for a more efficient representation of pixel values compared to traditional Huffman coding. By setting this directive to on, NGINX will use this method during JPEG encoding, which could lead to smaller file sizes and better image quality, particularly in images with complex color distributions. Conversely, setting it to off will revert to the standard Huffman coding method.
This directive can be utilized in various contexts, including http, server, and location, allowing for flexible configuration depending on the needs of the application. To activate arithmetic coding globally for all JPEG images served by the server, include this directive in the http block. For more granular control, it can also be set at the server or location level to target specific images or gallery sections. However, it is important to note that enabling arithmetic coding may result in increased CPU usage, as the encoding process becomes more computationally demanding than standard Huffman coding.
Config Example
http {
jpeg_filter on;
jpeg_filter_arithmetric on;
jpeg_filter_optimize on;
location /images/ {
jpeg_filter_max_pixel 1000000;
}
}Enabling arithmetic coding can increase CPU usage during JPEG processing, which may impact server performance if high traffic occurs.
Make sure that the underlying implementation of the JPEG filter module supports arithmetic coding, as some configurations may require specific dependencies.