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

is it possible to ignore the exif orientation? #2724

Closed
rdyar opened this issue May 18, 2021 · 2 comments
Closed

is it possible to ignore the exif orientation? #2724

rdyar opened this issue May 18, 2021 · 2 comments
Labels

Comments

@rdyar
Copy link

rdyar commented May 18, 2021

I have a front end using cropperjs that passes an image to the backend where we process it with Sharp.

We are rotating the image on our own so that the actual pixel dimensions determine whether the image is horizontal or vertical and then rotating it if needed to match a canvas nodes orientation. The actual exif orientation is not important and needs to be ignored.

Cropperjs has a flag to ignore it and it works great.

Then the image goes to our backend where Sharp processes it and if an image has exif orientation then it ends up being incorrect.

I see that withMetadata can edit exif orientation, but I don't see a way to remove it or ignore it. I tried using this anyways and setting it to 1 hoping that would be the same as nothing but it didn't work - nor did 8 for some reason. I did this as .withMetadata({orientation:8}) before any other operations. Seems like it should have done something so maybe I am doing it incorrectly? I think 1 could almost work as that seems like default/no rotation to me.

I also tried rotate(0) hoping it would take precedence over the exif orientation but it doesn't. If I know the exif is going to rotate it -90 then I can tell it to .rotate(-90) and it will correct it, but other then that on the backend I have not found a way to ignore the rotation like I can on the frontend.

Is it possible to ignore the exif rotation?
Thanks for any info!

@rdyar rdyar added the question label May 18, 2021
@lovell
Copy link
Owner

lovell commented May 18, 2021

The default behaviour is to ignore and remove EXIF metadata, so perhaps try removing any use of rotate() and withMetadata().

https://sharp.pixelplumbing.com/api-operation#rotate
https://sharp.pixelplumbing.com/api-output#withmetadata

If you need further help, please provide complete, standalone code and sample image to allow someone else to reproduce the problem.

@rdyar
Copy link
Author

rdyar commented May 18, 2021

got it. It is our code not Sharp that is causing it, Sharp is ignoring the exif but not getting told that we rotated it.

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants