-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support to set the new orientation as EXIF metadata #189
Comments
Is this due to a side effect of using the existing auto-orient feature of If more than this, then It's possible to set the orientation value; the complexity is in what value it should be set to. What would you expect to happen if there is already an existing orientation value combined with an explicit rotation or flip? A few worked examples or test cases would help the implementor of such a feature. Simplifying things slightly, would exposing the ability to manually set arbitrary EXIF headers provide enough API for you to plug in your own logic? |
Thank you Lovell for the quick response. The idea is, essentially, in the case that the user want to flip an image, and then reprocess it, I think there's no way to auto detect the rotation degrees of the processed image. Regarding to the original value, the idea could be simply override the previous rotation value, if it exists o not. Regarding to the EXIF headers, I think it could be a good solution, therefore supporting native bindings from the public API could be a reasonable approach to provide the freedom to manipulate the EXIF metadata with more versatility. |
My current thinking around the behaviour and API to support this is to do both of the following:
|
The current libvips logic seems to be only able to set EXIF tags in JPEG output where those tags already existed in the input (and have not been explicitly removed). This means the use of |
What about |
@h2non Whilst it's possible to set arbitrary image headers during the pipeline, libvips' JPEG writer seems to loop over the input's EXIF headers to set the output headers and therefore is ignoring any inserted EXIF headers. @jcupitt Would it make sense for libvips' logic to be modified to instead loop over all image headers with an |
Oh yes, you're right, you can't set new EXIF tags, I hadn't thought of that. You're right, it should probably look for any metadata starting with "exif-". I'll have a look. On autorotate, I think my 2p would be to have a special autorotate() method which looked at the orientation tag, applied it, then removed it. I'd think it would be unexpected to auto remove it anywhere else. |
Clear Orientation when rotate/flip/flop are used
Thanks for confirming John. sharp's parameter-less version of With commit d303703 I've added the ability to override the Any change to libvips to allow the insertion of new EXIF tags should get automagically picked up too. The default behaviour of sharp, which I believe meets most web use cases, is to strip EXIF metadata anyway. Should someone rotate or mirror an image then any existing |
This is now in master awaiting release. |
v0.11.0 will be released today with this improvement, thanks for the original suggestion. |
@lovell Thank you! |
change exif names again: we were storing under @title, but that's both subject to i18n, and unlookupable in libexif we now use @name, which is not subject to i18n and can be searched for ... this will break most code which expects certain exif tag names also, when we update exif, allow any tag, not just updates to existing tags, see: lovell/sharp#189
I've made a vips branch with this change. Unfortunately I had to change the way exif tags are encoded as vips metadata fields :( before it was
I'm not sure why. But the I've changed it to be
where Of course this means most vips exif metadata has been renamed, very unfortunate. The only good thing seems to be that the "Orientation" tag has the same All code which looks at exif tags needs checking and updating. |
Thanks John, your libvips' change feels like the right future-proof approach (even though it breaks the API). Currently the only EXIF tag sharp cares about is |
I've fixed up some more stuff, added a test for exif modification, and merged to master. |
In case of image rotation / flip, it could be useful to store the new orientation as image metadata header before saving?
I guess it could be done from image headers functions:
http://www.vips.ecs.soton.ac.uk/supported/7.40/doc/html/libvips/libvips-header.html#vips-image-set
Thanks
The text was updated successfully, but these errors were encountered: