Skip to content
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

Auto rotation without any other modification #315

Closed
digilist opened this issue Jun 16, 2020 · 9 comments
Closed

Auto rotation without any other modification #315

digilist opened this issue Jun 16, 2020 · 9 comments

Comments

@digilist
Copy link

I would be great if there is an option/endpoint to fix the orientation of an image based on the EXIF data without modifying the image in any other way. The rotate endpoint works only if a rotate parameter is given and a 0-value does not work.

Not sure, if I am missing something and this works already, but I didn't find it. I did not explore workarounds such as doing a resize that keeps the current size of the image (with auto-rotation), but this does not feel right anyway.

@h2non h2non added the question label Jun 17, 2020
@h2non
Copy link
Owner

h2non commented Jun 17, 2020

By default, images are automatically rotated based on its EXIF metadata, if available and the image is not properly oriented according to it.

You can disable this behavior by passing the URL query param norotation=true, and then explicitly pass the rotation behavior via rotate=degrees if needed.

@digilist
Copy link
Author

Thanks for your answer. But what I mean is that the image is only rotated without any other modification, so I do not want to resize etc. and only fix the orientation. Is there a way?

So I mean something like an /autorotate endpoint that fixes the orientation and returns a new image. If the orientation is already correct, it returns the original image.

@h2non
Copy link
Owner

h2non commented Jun 17, 2020

There is an endpoint specifically for that:
https://github.com/h2non/imaginary#get--post-rotate

@digilist
Copy link
Author

But with that endpoint the rotate parameter must be provided to define the angle of the rotation. A value of 0 does not work and results in an error that the parameter is required.

@h2non
Copy link
Owner

h2non commented Jun 17, 2020

The autorotate endpoint might be a good option and easy to implement.

In the meanwhile, you might try getting the image info, and based on the returned orientation field value, make another call to rotate the image, if needed:
https://github.com/h2non/imaginary#get--post-info

Alternatively, you can try using the /convert endpoint with no actual image transformation and passing the same image format in the type query param:
https://github.com/h2non/imaginary#get--post-convert

@h2non
Copy link
Owner

h2non commented Aug 4, 2020

The /autorate endpoint feature is now available in imaginary v1.2.3.

More details here: https://github.com/h2non/imaginary#get--post-autorotate

@h2non h2non closed this as completed Aug 4, 2020
@digilist
Copy link
Author

Great, thank you :) I gave it a try and it is able to fix a few rotations, but unfortunately not all of them.

I used the images in repository for testing: https://github.com/recurser/exif-orientation-examples
The cases 2, 4, 5 and 7 are not rotated correctly.

I saw that you implemented the autoration using the AutoRotate method from libvips and it looks like libvips does not support all orientations yet, but it will with libvips 8.10 which should come out soon (libvips/libvips#1766)

So I think it's worth waiting for the new libvips version and I just wanted to post this for your information.

@h2non
Copy link
Owner

h2non commented Aug 11, 2020

Cool, thanks! We will sure upgrade to libvips 8.10 as soon as the stable version is available.

@digilist
Copy link
Author

Thanks for the update! I just tested it again and it works like a charm.

j-keck pushed a commit to artidis/imaginary that referenced this issue Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants