onurzorluer / react-image-file-resizer

Resize Local Images with React 🌄 🌅
MIT License
317 stars 41 forks source link

Some Images are getting rotated inspite of rotate is 0 #12

Closed arpitalopa closed 4 years ago

arpitalopa commented 5 years ago

Some Images are getting rotated inspite of rotate is 0.

arpitalopa commented 4 years ago

not fixed

eminx commented 4 years ago

I'm also having the same problem.

Why is the issue closed?

eminx commented 4 years ago

@onurzorluer ??

onurzorluer commented 4 years ago

I think this problem caused by images EXIF Data. Did you try remove it? @eminx @arpitalopa

alexvirga commented 4 years ago

Having the same issue. Any work-arounds?

onurzorluer commented 4 years ago

I think this problem caused by images EXIF Data. Did you try remove it? @eminx @arpitalopa

@alexvirga

arpitalopa commented 4 years ago

@onurzorluer currently, i am not working on it

onurzorluer commented 4 years ago

@arpitalopa any update?

oggktlmr commented 4 years ago

is going to read the exif orientation and rotate the image automatically?

onurzorluer commented 4 years ago

Yep, I think this is happening.

emma-adams-machine commented 4 years ago

I have the same issue :( Maybe the description can help you. It just happened on the iPhone with the front camera. I put rotation property 0 but it is not working in this case.

kocur4d commented 4 years ago

EDIT:

I did a bit more testing and it appears that the problem is browser related. Different browser, Chrome and Samsung one, does things differently. So just to describe what I am doing:

I receive images via phone camera. Usually those can be rotated with EXIF for a rotation to be set accordingly to 0,90, 180, 270... I want to have all of my pictures with rotation 0. So I check EXIF of the image and got a value 0,90, 180 or 270 returned. Then I pass the image with the rotation, found in a previous step, too the imageFileResizer. Problem is that Samsung browser does what I need but Chrome is rotating the image overshooting the rotation. When I implement tthe fix to alway pass rotation 0 together with the image Chrome is working but Samsung is broken.

~What I have observed is that couple of weeks ago the behaviour changed.~

~What I believe was happening in the past is that the EXIF rotation data was ignored and I was extracting it in a separate function and then passed the result to the imageFileResizer as a rotation so mine images got zero orientation as expected.~

~But now it stoped working. The images that have any rotation get extra rotation applied to it. So what I think is happening is this: The EXIF is no longer ignored and the image is automatically zeroed and then the rotation I am passing to the imageFileResizer is applied resulting in the rotated image.~

What is not helping that readme has two conflicting statements about rotation:

So there is a possibility that something have changed in a behaviour outside of the scope of react-image-file-resizer but I am not sure where.

Hope it makes sense.

emma-adams-machine commented 4 years ago

@kocur4d As I was said I checked it on a lot of phones such as iPhone, Xiaomi, Samsung, ... but just on the iPhone, this happened. I set rotation prop 0 but it rotates 180degree.

kocur4d commented 4 years ago

OK, so mine problem was fixed by implementing this:

https://stackoverflow.com/questions/61334936/drawing-photo-from-file-to-canvas-rotates-in-chrome-based-on-exif

In the end it was browser related and support for image-orientation. I am not sure how related it is to other people issues in this thread.

eminx commented 4 years ago

I'm not totally sure, but I have a very strong feeling that this is due to the phone camera orientation thing. Often when we have taken a photo, perhaps it's saved as portrait whereas user thinks it's landscape. So it may have nothing to do with this module.

A rotator may be necessary... Not sure.

OK, so mine problem was fixed by implementing this:

https://stackoverflow.com/questions/61334936/drawing-photo-from-file-to-canvas-rotates-in-chrome-based-on-exif

In the end it was browser related and support for image-orientation. I am not sure how related it is to other people issues in this thread.

I think what you say is in line with my opinion. Perhaps a PR on that regard??

onurzorluer commented 4 years ago

I have developed a new module for exif orientation resetting. I think it will fix your problem.

Try & give a feedback please: https://github.com/onurzorluer/exif-auto-rotate @arpitalopa @alexvirga @eminx @oggktlmr @emma-adams-machine @kocur4d