Image orientation in plupload, using EXIF

Do not post support requests, bug reports or feature requests. Discuss phpBB here. Non-phpBB related discussion goes in General Discussion!
Scam Warning
sp3ctre
Registered User
Posts: 274
Joined: Sun Jul 15, 2007 11:06 am

Image orientation in plupload, using EXIF

Post by sp3ctre » Sat Jul 01, 2017 10:03 am

I know this has been an age old discussion on here but as far as I know it hasn't been "solved".

The issue:

Some phones don't rotate images based on the orientation of the camera, resulting in a side-on image with some EXIF data telling the user that it needs to be rotated. When images are displayed in the browser they rotate accordingly, but when they are embedded in IMG tags (like in phpbb) they display in their original form, ignoring the EXIF.

Possible solutions:

- Tell the users their phones are crap and they should get a new one (not ideal ;) )
- Complain that it is the browser's job to handle it better (Firefox can do it in CSS, the others can't)
- Look for the EXIF tag on upload and rotate the image then... followed by stripping the EXIF tag to prevent further browser manipulation

It's the last option I am interested in solving. I know PHPBB uses Plupload to upload images, I believe this support auto-rotation if you use the "preserve-headers = false" flag. I haven't managed to test this yet as I can't see where to set it. Can anyone point me in the right direction?

I apologise if there is an easy solution for this that I haven't seen, but I did do quite a bit of searching.

Any help much appreciated

User avatar
Mick
Support Team Member
Support Team Member
Posts: 19986
Joined: Fri Aug 29, 2008 9:49 am
Location: Cardiff

Re: Image orientation in plupload, using EXIF

Post by Mick » Sat Jul 01, 2017 1:16 pm

Some mobile phone models, particularly iPhones, set incorrect EXIF parameters on images. There is no simple way to fix that and it's not really a phpBB problem. Do you have an issue if the shot is taken in landscape?

I think I read somewhere 3Di was writing an extension to handle EXIF.
"The more connected we get the more alone we become" - Kyle Broflovski

There are no ‘threads’ in phpBB, they are topics.

sp3ctre
Registered User
Posts: 274
Joined: Sun Jul 15, 2007 11:06 am

Re: Image orientation in plupload, using EXIF

Post by sp3ctre » Sat Jul 01, 2017 2:44 pm

Not sure if it is just landscape or not. The issues seem to be on Sony phones mainly. I realise it's not just a phpbb issue but the issue is so many upload sites do handle it correctly (well, image is oriented as expected). Telling the users of the forum that it's not our fault when other sites work isn't really ideal.

sp3ctre
Registered User
Posts: 274
Joined: Sun Jul 15, 2007 11:06 am

Re: Image orientation in plupload, using EXIF

Post by sp3ctre » Sat Jul 01, 2017 6:41 pm

OK, I solved it by getting the plupload script to use "preserve_headers: false".

Now the plupload script does whatever EXIF transformation (i.e Rotate 90 CW) to the image before saving it and stripping the EXIF data.

Seems to work fine and it's so far been tested with iPhones and Sony phones.

sakm
Registered User
Posts: 502
Joined: Sun Jan 21, 2007 8:14 pm
Location: Hull, uk
Name: Stu
Contact:

Re: Image orientation in plupload, using EXIF

Post by sakm » Sat Jul 01, 2017 7:13 pm

I too have a lot of users who upload photos that are all sideways!

I don't think phone model is the issue here! I have had my huawei do it also Iphones sony samsung and google phones!

I have found the problem is that if you open the camera and dont hold the phone upright then rotate it to landscape then you end up with photos that are not rotated!

I have also found that if you right click an image and open in new window/tab that the image is then rotated and shown as it should be!

sp3ctre
Registered User
Posts: 274
Joined: Sun Jul 15, 2007 11:06 am

Re: Image orientation in plupload, using EXIF

Post by sp3ctre » Sat Jul 01, 2017 7:18 pm

sakm wrote:
Sat Jul 01, 2017 7:13 pm
I have also found that if you right click an image and open in new window/tab that the image is then rotated and shown as it should be!
Yeah, the reason for that is when you open in new window the browser reads the EXIF data but when it's in a web page it ignores it.

Tests are looking good so far, all images appearing as they should

sakm
Registered User
Posts: 502
Joined: Sun Jan 21, 2007 8:14 pm
Location: Hull, uk
Name: Stu
Contact:

Re: Image orientation in plupload, using EXIF

Post by sakm » Sat Jul 01, 2017 7:28 pm

sp3ctre wrote:
Sat Jul 01, 2017 7:18 pm
sakm wrote:
Sat Jul 01, 2017 7:13 pm
I have also found that if you right click an image and open in new window/tab that the image is then rotated and shown as it should be!
Yeah, the reason for that is when you open in new window the browser reads the EXIF data but when it's in a web page it ignores it.

Tests are looking good so far, all images appearing as they should
That's pretty much what I thought to be honest what is it you changed exactly?

sp3ctre
Registered User
Posts: 274
Joined: Sun Jul 15, 2007 11:06 am

Re: Image orientation in plupload, using EXIF

Post by sp3ctre » Sat Jul 01, 2017 7:35 pm

In /phpbb/plupload/plupload.php (around line 269)

Code: Select all

'resize: {width: %d, height: %d, quality: 85},',
... becomes...

Code: Select all

'resize: {width: %d, height: %d, quality: 85,preserve_headers: false},',

sakm
Registered User
Posts: 502
Joined: Sun Jan 21, 2007 8:14 pm
Location: Hull, uk
Name: Stu
Contact:

Re: Image orientation in plupload, using EXIF

Post by sakm » Sat Jul 01, 2017 7:44 pm

Thanks for that I will give it a try

Is this likely to work with images already uploaded?

sp3ctre
Registered User
Posts: 274
Joined: Sun Jul 15, 2007 11:06 am

Re: Image orientation in plupload, using EXIF

Post by sp3ctre » Sat Jul 01, 2017 7:45 pm

sakm wrote:
Sat Jul 01, 2017 7:44 pm
Thanks for that I will give it a try

Is this likely to work with images already uploaded?
No worries... no it won't, only on new images

sakm
Registered User
Posts: 502
Joined: Sun Jan 21, 2007 8:14 pm
Location: Hull, uk
Name: Stu
Contact:

Re: Image orientation in plupload, using EXIF

Post by sakm » Sat Jul 01, 2017 7:47 pm

Ah ok I will stop trying to refresh and clear cache then :lol:

sp3ctre
Registered User
Posts: 274
Joined: Sun Jul 15, 2007 11:06 am

Re: Image orientation in plupload, using EXIF

Post by sp3ctre » Sat Jul 01, 2017 7:51 pm

sakm wrote:
Sat Jul 01, 2017 7:47 pm
Ah ok I will stop trying to refresh and clear cache then :lol:
lol, let me know how you get on :D

sakm
Registered User
Posts: 502
Joined: Sun Jan 21, 2007 8:14 pm
Location: Hull, uk
Name: Stu
Contact:

Re: Image orientation in plupload, using EXIF

Post by sakm » Sat Jul 01, 2017 8:13 pm

sp3ctre wrote:
Sat Jul 01, 2017 7:51 pm
sakm wrote:
Sat Jul 01, 2017 7:47 pm
Ah ok I will stop trying to refresh and clear cache then :lol:
lol, let me know how you get on :D
Seems to be working so far

I have tested it with a few images and all seem to show correctly then when removing the change they are rotated wrongly!

I think this should be added as a bud IMO

sp3ctre
Registered User
Posts: 274
Joined: Sun Jul 15, 2007 11:06 am

Re: Image orientation in plupload, using EXIF

Post by sp3ctre » Sat Jul 01, 2017 8:20 pm

sakm wrote:
Sat Jul 01, 2017 8:13 pm
sp3ctre wrote:
Sat Jul 01, 2017 7:51 pm
sakm wrote:
Sat Jul 01, 2017 7:47 pm
Ah ok I will stop trying to refresh and clear cache then :lol:
lol, let me know how you get on :D
Seems to be working so far

I have tested it with a few images and all seem to show correctly then when removing the change they are rotated wrongly!

I think this should be added as a bud IMO
Just to be clear, when you remove the change you re-upload? The uploaded images are still ok.

This method does strip the EXIF data (GPS etc) so it would ideally be an option in the main release rather than a forced change, but it does appear to work well.

I run forums that are used by lots of non-technical folks (and some technical ones). They expect these things to "just work". That's why I can't understand the "it's not our problem" point of view... people upload images to Facebook, Flick etc all the time and it "just works"... phpbb should be the same (or at least have it as an option)

sakm
Registered User
Posts: 502
Joined: Sun Jan 21, 2007 8:14 pm
Location: Hull, uk
Name: Stu
Contact:

Re: Image orientation in plupload, using EXIF

Post by sakm » Sat Jul 01, 2017 8:42 pm

I tested by doing the edit to plupload then uploading the image then I removed the edit then uploaded the image again just to make sure things where working

with the edit the image was the correct way removing the edit and re uploading the same image the image orientation was wrong

Basically it works as you describe
sp3ctre wrote:
Sat Jul 01, 2017 8:20 pm

I run forums that are used by lots of non-technical folks (and some technical ones). They expect these things to "just work". That's why I can't understand the "it's not our problem" point of view... people upload images to Facebook, Flick etc all the time and it "just works"... phpbb should be the same (or at least have it as an option)
Yes I know where you are coming from with people think it should just work :lol:

Post Reply

Return to “phpBB Discussion”

Who is online

Users browsing this forum: No registered users and 16 guests