jpeg_filter_dropon_memory
The `jpeg_filter_dropon_memory` directive allows for overlaying an image directly from memory onto JPEG images during filtering.
Description
The jpeg_filter_dropon_memory directive is part of the NGINX JPEG filter module, which utilizes the libmodjpeg library to handle JPEG images efficiently. This directive is designed to overlay a specified image or mask directly onto a JPEG image processed by NGINX without needing to write the overlay to disk. The command accepts one or two arguments: the first is the name of the image that will be overlaid, and the second optional argument specifies a mask image that defines the transparency or blending of the overlay. If no mask is provided, the overlay will be applied as is.
When a JPEG image is requested, if this directive is specified in the configuration for a particular location, NGINX dynamically injects the overlay image during the image processing phase. This allows servers to maintain modularity and flexibility, enabling overlays for various scenarios—like adding logos or watermarks without altering the original image files on disk. If the image to overlay is large or complex, it's essential to manage server memory effectively, as loading large images directly into memory can potentially exhaust available resources.
Config Example
location /images/ {
jpeg_filter on;
jpeg_filter_dropon_memory /path/to/overlay.png /path/to/mask.png;
}Ensure the overlay image is in a compatible format (e.g. PNG) and is accessible by the NGINX worker processes.
Large images can consume significant memory, potentially leading to performance issues or crashes.
If using a mask image, make sure its dimensions align with the overlay image to avoid unexpected behavior.