imgproxy: strip_metadata doesn't actually strip all metadata for certain output formats
Certain EXIF metadata is always included in imgproxy thumbnails regardless of the presence of the strip_metadata:1 option. I would like all metadata to be stripped from the output, especially fields related to DPI (xres, yres, etc).
Sample source image:

Has this metadata:
$ exiftool relaxation-mode.jpg
ExifTool Version Number : 12.00
File Name : relaxation-mode.jpg
Directory : .
File Size : 502 kB
File Modification Date/Time : 2021:07:09 10:10:27-05:00
File Access Date/Time : 2021:07:09 10:11:14-05:00
File Inode Change Date/Time : 2021:07:09 10:10:27-05:00
File Permissions : rw-r--r--
File Type : JPEG
File Type Extension : jpg
MIME Type : image/jpeg
Image Width : 5120
Image Height : 3686
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:4:4 (1 1)
Image Size : 5120x3686
Megapixels : 18.9
When asking for a JPEG thumbnail, stripping metadata, the image produced has this metadata:
$ curl -s 'http://localhost:8181/insecure/w:640/sm:1/scp:1/plain/local:///relaxation-mode.jpg' | exiftool -
ExifTool Version Number : 12.00
File Type : JPEG
File Type Extension : jpg
MIME Type : image/jpeg
Exif Byte Order : Little-endian (Intel, II)
Orientation : Horizontal (normal)
X Resolution : 72
Y Resolution : 72
Resolution Unit : inches
Y Cb Cr Positioning : Centered
Exif Version : 0210
Components Configuration : Y, Cb, Cr, -
Flashpix Version : 0100
Color Space : Uncalibrated
Exif Image Width : 640
Exif Image Height : 460
Image Width : 640
Image Height : 460
Encoding Process : Baseline DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2)
Image Size : 640x460
Megapixels : 0.294
Similarly, for WebP:
$ curl -s 'http://localhost:8181/insecure/w:640/sm:1/scp:1/plain/local:///relaxation-mode.jpg@webp' | exiftool -
ExifTool Version Number : 12.00
File Type : WEBP
File Type Extension : webp
MIME Type : image/webp
VP8 Version : 0 (bicubic reconstruction, normal loop)
Image Width : 640
Horizontal Scale : 0
Image Height : 460
Vertical Scale : 0
Exif Byte Order : Little-endian (Intel, II)
Orientation : Horizontal (normal)
X Resolution : 72
Y Resolution : 72
Resolution Unit : inches
Y Cb Cr Positioning : Centered
Exif Version : 0210
Components Configuration : Y, Cb, Cr, -
Flashpix Version : 0100
Color Space : Uncalibrated
Exif Image Width : 640
Exif Image Height : 460
Image Size : 640x460
Megapixels : 0.294
For these two formats at least, it seems that you must instruct libvips to not write a standard EXIF block with default values when writing the output. For example, vips_jpegsave() has a strip option that should be set to true:
If
stripis set, no EXIF data, IPTC data, ICC profile or XMP metadata is written into the output file.
Similarly, vips_webpsave() also has a strip option:
The writer will attach ICC, EXIF and XMP metadata, unless
stripis set toTRUE.
I think the right behavior here would be to pass along the strip_metadata preference into the save routine so that if true, certain format writers can set their various strip options if requested.
It seems that “pixels per unit” is also included for PNG outputs:
curl -s 'http://localhost:8181/insecure/w:640/sm:1/scp:1/plain/local:///relaxation-mode.jpg@png' | exiftool -
ExifTool Version Number : 12.00
File Type : PNG
File Type Extension : png
MIME Type : image/png
Image Width : 640
Image Height : 460
Bit Depth : 8
Color Type : RGB
Compression : Deflate/Inflate
Filter : Adaptive
Interlace : Noninterlaced
Pixels Per Unit X : 2835
Pixels Per Unit Y : 2835
Pixel Units : meters
Image Size : 640x460
Megapixels : 0.294
but seeing as vips_pngsave() has no equivalent strip option, I don’t know if anything can be done about that.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 16 (8 by maintainers)
@jcupitt Unfortunately,
stripis not an option as it removes ICC profiles as well. Anyway, resettingxresandyreson copy solves the issue. Thanks again!@sagebind
v2.16.7is ready to pull