-
Notifications
You must be signed in to change notification settings - Fork 62
-
Hi, I faced odd situation with converting images with different exif orientation. For example I am trying to strip metadata on save for image
raw image: raw_image.get('exif-ifd0-Orientation') => 5 (Left-top, Short, 1 components, 2 bytes)
RAW
portrait_5
RAW
processed image: image.get('exif-ifd0-Orientation') => 1 (Top-left, Short, 1 components, 2 bytes)
PROCESSED
preview_1000_photo
PROCESSED
I thought It should completely remove exif metadata
am I doing something wrong or it is proper behaviour? Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions
Hi @zorar4ik,
It should work. Please post a complete runnable program and a test image that illustrates the problem so I can reproduce it.
Replies: 1 comment 6 replies
-
Hi @zorar4ik,
It should work. Please post a complete runnable program and a test image that illustrates the problem so I can reproduce it.
Beta Was this translation helpful? Give feedback.
All reactions
-
@jcupitt thanks for quick response! One more quick question then. How to test properly that strip
method has been used? I mean what kind of metadata has been erased?
Beta Was this translation helpful? Give feedback.
All reactions
-
Ooop, sorry, my mistake, it removes EXIF too.
The EXIF you see when you reload is the minimal amount of exif necessary for an image to be in spec, and it attached by the loader if the image has no exif.
$ vipsheader -a k2.jpg | grep exif-data
exif-data: 186 bytes of binary data
$ vips copy k2.jpg x.jpg[strip]
$ vipsheader -a x.jpg
x.jpg: 1450x2048 uchar, 3 bands, srgb, jpegload
width: 1450
height: 2048
bands: 3
format: uchar
coding: none
interpretation: srgb
xoffset: 0
yoffset: 0
xres: 2.83465
yres: 2.83465
filename: x.jpg
vips-loader: jpegload
jpeg-multiscan: 0
jpeg-chroma-subsample: 4:2:0
You can see there's no exif on x.jpg
.
Beta Was this translation helpful? Give feedback.
All reactions
-
Hmm, I am a bit confused then. So strip
should remove all exif metadata, isn't it? So why does my saved file has exif metadata? In fact it seems that amount of metadata has increased after saving to file.
Beta Was this translation helpful? Give feedback.
All reactions
-
I don't think your saved file does have exif metadata, does it? I see:
$ irb
irb(main):001:0> require 'vips'
=> true
irb(main):002:0> x = Vips::Image.new_from_file("k2.jpg")
=> #<Image 1450x2048 uchar, 3 bands, srgb>
irb(main):003:0> x.write_to_file("x.jpg", strip: true)
=> nil
irb(main):004:0>
$ vipsheader -a x.jpg
x.jpg: 1450x2048 uchar, 3 bands, srgb, jpegload
width: 1450
height: 2048
bands: 3
format: uchar
coding: none
interpretation: srgb
xoffset: 0
yoffset: 0
xres: 2.83465
yres: 2.83465
filename: x.jpg
vips-loader: jpegload
jpeg-multiscan: 0
jpeg-chroma-subsample: 4:2:0
No EXIF.
If I load and save again:
$ irb
irb(main):001:0> require 'vips'
=> true
irb(main):002:0> x = Vips::Image.new_from_file("x.jpg")
=> #<Image 1450x2048 uchar, 3 bands, srgb>
irb(main):003:0> x.write_to_file("x2.jpg")
=> nil
irb(main):004:0>
$ vipsheader -a x2.jpg
x2.jpg: 1450x2048 uchar, 3 bands, srgb, jpegload
width: 1450
height: 2048
bands: 3
format: uchar
coding: none
interpretation: srgb
xoffset: 0
yoffset: 0
xres: 2.83465
yres: 2.83465
filename: x2.jpg
vips-loader: jpegload
jpeg-multiscan: 0
jpeg-chroma-subsample: 4:2:0
exif-data: 186 bytes of binary data
resolution-unit: in
exif-ifd0-Orientation: 1 (Top-left, Short, 1 components, 2 bytes)
exif-ifd0-XResolution: 72/1 (72, Rational, 1 components, 8 bytes)
exif-ifd0-YResolution: 72/1 (72, Rational, 1 components, 8 bytes)
exif-ifd0-ResolutionUnit: 2 (Inch, Short, 1 components, 2 bytes)
exif-ifd0-YCbCrPositioning: 1 (Centred, Short, 1 components, 2 bytes)
exif-ifd2-ExifVersion: Exif Version 2.1 (Exif Version 2.1, Undefined, 4 components, 4 bytes)
exif-ifd2-ComponentsConfiguration: Y Cb Cr - (Y Cb Cr -, Undefined, 4 components, 4 bytes)
exif-ifd2-FlashpixVersion: FlashPix Version 1.0 (FlashPix Version 1.0, Undefined, 4 components, 4 bytes)
exif-ifd2-ColorSpace: 65535 (Uncalibrated, Short, 1 components, 2 bytes)
exif-ifd2-PixelXDimension: 1450 (1450, Long, 1 components, 4 bytes)
exif-ifd2-PixelYDimension: 2048 (2048, Long, 1 components, 4 bytes)
orientation: 1
Now there's EXIF, because this time the JPEG saver hasn't been given the strip
option, so it's attached the minimal set of EXIF necessary to meet the spec.
Beta Was this translation helpful? Give feedback.
All reactions
-
@jcupitt thanks. Now I see the point. So images with exif orientation different from 1 will be rotated and saved with new exif orientation tag. But with proper strip option there will be no exif metadata at all. So it means that strip
didn't work when I called it. But that's a different story. Thanks for your support and for amazing work on this library
Beta Was this translation helpful? Give feedback.