[Feature Request] Add directive to control EXIF data preservation in image_filter module
@vinaykumar-1591 is already working on this.
Since Aug 20, 2026.
- Dominant language
- C
- Stars
- 31.7k
- Forks
- 8.3k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 13
Description
Add directive to control EXIF data preservation in image_filter module
Summary
Request for a new directive image_filter_preserve_exif to control whether EXIF and other application-specific data should be preserved during image processing.
Background
Currently, the ngx_http_image_filter_module automatically strips EXIF and other application-specific data when it exceeds 5% of the JPEG file size. This behavior was introduced in nginx 0.7.66 (2010) as a performance optimization for the bandwidth-constrained era.
Problem
The current automatic EXIF removal causes several issues for modern web applications:
1. Color Profile Loss
- EXIF contains crucial color profile information (sRGB, Adobe RGB, etc.)
- Images display with incorrect colors across different devices and browsers
- Related to existing issue #1343
2. Image Orientation Problems
- EXIF rotation metadata is lost, causing images to display incorrectly
- Particularly problematic with smartphone photos: Modern mobile devices automatically add orientation metadata
- In 2010 when the 5% rule was introduced, smartphone adoption was minimal, but today most user-generated content comes from mobile devices
- Users frequently encounter rotated images (portrait photos appearing as landscape, etc.)
- Forces manual pre-processing or client-side rotation workarounds
3. Copyright and Attribution Loss
- Photographer and copyright information is stripped
- Legal and attribution requirements cannot be met
- Important for media, photography, and portfolio websites
4. Location and Technical Metadata
- GPS coordinates and camera settings are removed
- Valuable for photography communities and educational content
Current Workarounds
Users currently need to:
- Implement separate microservices for image processing
- Use ImageMagick or other tools outside nginx
- Manually preserve EXIF before nginx processing
Proposed Solution
Add a new directive to control EXIF preservation:
Syntax: image_filter_preserve_exif on | off;
Default: image_filter_preserve_exif off;
Context: http, server, location
Example Usage
location /photos/ {
image_filter resize 800 600;
image_filter_preserve_exif on; # Keep EXIF data
}
location /thumbnails/ {
image_filter resize 150 150;
image_filter_preserve_exif off; # Strip EXIF for smaller files
}
Benefits
- Flexibility: Users can choose based on their specific needs
- Backward Compatibility: Default behavior remains unchanged
- Modern Web Standards: Supports proper color management and metadata handling
- Performance Control: Allow optimization where needed, preservation where important
Use Cases
- Photography websites: Need color profiles and technical metadata
- E-commerce sites: Require accurate color representation
- Portfolio sites: Need to preserve copyright and attribution
- Media platforms: Must maintain image metadata for legal compliance
Technical Implementation
The change would modify the JPEG parsing logic in ngx_http_image_size() to conditionally skip the EXIF removal when preserve_exif is enabled, while maintaining the current 5% threshold behavior when disabled.
This enhancement would bring nginx's image processing capabilities in line with modern web development needs while preserving the performance benefits for users who prefer smaller file sizes.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.