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!
Get Involved
User avatar
thecoalman
Community Team Member
Community Team Member
Posts: 4259
Joined: Wed Dec 22, 2004 3:52 am
Location: Pennsylvania, U.S.A.
Contact:

Re: Image orientation in plupload, using EXIF

Post by thecoalman »

tojag wrote:
Sun Oct 28, 2018 9:57 pm
Is it possible that the image published from the iPad displays wrong, and the same image published from another system displays correctly? It seems impossible.
EXIF orientation can be quite confusing if not handled properly. For example suppose you were using editing software that doesn't support it. The image would be oriented wrong. You rotate the raw file data and save, the EXIF orientation is preserved . Loks fine in the editor but when you view it in something that does support it now it's flipped again. LOL... That's worse case because the orientation is no longer accurate.

How this applies here is as I just mentioned in previous post the thumbnails are not handled by plupload. The EXIF data is stripped when thumbnails are created so they will always have wrong orientation if they are oriented with EXIF.
“Results! Why, man, I have gotten a lot of results! I have found several thousand things that won’t work.”

Attributed - Thomas Edison
KYPREO
Registered User
Posts: 392
Joined: Fri Feb 02, 2018 9:56 am
Contact:

Re: Image orientation in plupload, using EXIF

Post by KYPREO »

thecoalman wrote:
Sun Nov 04, 2018 4:20 am
KYPREO wrote:
Sat Oct 27, 2018 11:15 am
But, the attachments don't render in post with the correct orientation. However, if you open the direct URL of the uploaded image in a new tab it is correctly oriented. The means the EXIF data is just being retained and properly interpreted by the browser, but not phpBB.
Plupload only handles the full size image it doesn't handle the thumbnail.
Thanks for the reply. I don't think that's it because I don't use thumbnails for attachments on my forum at all. The file size attachment is not being rendered with correct rotation within phpBB.
phpBB user since 2002
www.AusRotary.com
KYPREO
Registered User
Posts: 392
Joined: Fri Feb 02, 2018 9:56 am
Contact:

Re: Image orientation in plupload, using EXIF

Post by KYPREO »

Well I just managed to fix it!

I implemented this change to /phpbb/plupload/plupload.php (around line 269):

From

Code: Select all

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

Code: Select all

'resize: {width: %d, height: %d, quality: 85,preserve_headers: false},',
Previously this edit did nothing for me. Now, with the new version of plupload it works. Image is correctly orientated according to EXIF data and then the EXIF data is then stripped. 8-)

I know v12mike was able to get it working without this code change, but for me it was required. I will do some more testing, but all the test images and sample photos taken in landscape mode on my Samsung S9+ now display as they should.
phpBB user since 2002
www.AusRotary.com
benwtf
Registered User
Posts: 6
Joined: Mon Nov 05, 2018 10:52 pm

Re: Image orientation in plupload, using EXIF

Post by benwtf »

Testing with an image provided by a user who complained, I was able to use this extension with max dimensions set in attachments with no code modifications in 3.2.4.

Thank you!

EDIT: The extension here: viewtopic.php?f=456&t=2477256&p=15143616#p15143616
That's where I meant to post
Streamer76
Registered User
Posts: 58
Joined: Mon Dec 17, 2007 6:26 pm

Re: Image orientation in plupload, using EXIF

Post by Streamer76 »

Phpbb 3.2.5 seems to have plupload 2.3.6 version about plupload.full.min.js but there's still the same problem wit the images.

I added to "preserve_headers: false" to /phpbb/plupload/plupload.php but does not help. Somehow this trick worked fine with 3.1.x but not for the 3.2.5, at least not my phone images (LG G6).

Cannot use ImageMagick extension because my host does not support it.

Any ideas? :?:
User avatar
canonknipser
Registered User
Posts: 2096
Joined: Thu Sep 08, 2011 4:16 am
Location: Germany
Name: Frank Jakobs
Contact:

Re: Image orientation in plupload, using EXIF

Post by canonknipser »

Streamer76 wrote:
Thu Jan 17, 2019 6:23 pm
Any ideas?
Do it the old fashioned way: rotate (and maybe resize also) the image with a image manipulation program (gimp, photoshop, paint ...) or use jpegtran or a web service before uploading the images. I recommend it this way because rotating with plupload will only happen when the images needs to be resized. And the resizing with plupload is using a poor quality algorithm.
Greetings, Frank
phpbb.de support team member
English is not my native language - no support via PM or mail
New arrival - Extensions and scripts for phpBB
Streamer76
Registered User
Posts: 58
Joined: Mon Dec 17, 2007 6:26 pm

Re: Image orientation in plupload, using EXIF

Post by Streamer76 »

canonknipser wrote:
Thu Jan 17, 2019 8:16 pm
Streamer76 wrote:
Thu Jan 17, 2019 6:23 pm
Any ideas?
Do it the old fashioned way: rotate (and maybe resize also) the image with a image manipulation program (gimp, photoshop, paint ...) or use jpegtran or a web service before uploading the images. I recommend it this way because rotating with plupload will only happen when the images needs to be resized. And the resizing with plupload is using a poor quality algorithm.
I can do that but I know that 99% users does not want to do that.
User avatar
canonknipser
Registered User
Posts: 2096
Joined: Thu Sep 08, 2011 4:16 am
Location: Germany
Name: Frank Jakobs
Contact:

Re: Image orientation in plupload, using EXIF

Post by canonknipser »

Some small questions:
  • Is image resizing in effect on your board, which means do you have set maximum image dimensions?
  • Is image resizing in effect for the pictures you mentioned
    Streamer76 wrote:
    Thu Jan 17, 2019 6:23 pm
    at least not my phone images (LG G6).
    - are they bigger in dimension than those values set in acp?
  • Do you generate thumbnails?
  • Why does you host not support ImageMagick?
Greetings, Frank
phpbb.de support team member
English is not my native language - no support via PM or mail
New arrival - Extensions and scripts for phpBB
GentekPower
Registered User
Posts: 41
Joined: Wed Nov 21, 2018 2:13 am
Name: Chris
Contact:

Re: Image orientation in plupload, using EXIF

Post by GentekPower »

I wanted to add some input about the same issues I was having and the fix that finally got them...

Same rotation issues for me. Most were 90 deg counterclockwise. I tried the new bit of code with no success and then also the new version of plupload with what seemed no success...

The trick was that I had to purge the cache on both the server, phhpbb, AND MY BROWSER... That's what really fixed it. I had not been clearing the cached files on my local browser, but continuing to test and it wasn't working. For now it seems to be working... Board is running 3.2.3
Owner - Gentek Power.
Generac generator troubleshooting & help forums. https://gentekpower.com/forums
Streamer76
Registered User
Posts: 58
Joined: Mon Dec 17, 2007 6:26 pm

Re: Image orientation in plupload, using EXIF

Post by Streamer76 »

canonknipser wrote:
Fri Jan 18, 2019 8:43 pm
Some small questions:
  • Is image resizing in effect on your board, which means do you have set maximum image dimensions?
  • Is image resizing in effect for the pictures you mentioned
    Streamer76 wrote:
    Thu Jan 17, 2019 6:23 pm
    at least not my phone images (LG G6).
    - are they bigger in dimension than those values set in acp?
  • Do you generate thumbnails?
  • Why does you host not support ImageMagick?
Here is our board settings. I have no idea why my host does not support ImageMagick.
Attachments
phpbbimagesettings.png
Streamer76
Registered User
Posts: 58
Joined: Mon Dec 17, 2007 6:26 pm

Re: Image orientation in plupload, using EXIF

Post by Streamer76 »

This is really annoying problem. Any ideas on this? (cannot test this on this forum because of file size limit, I can send someone some pictures if someone is willing to test those on some other board)
Streamer76
Registered User
Posts: 58
Joined: Mon Dec 17, 2007 6:26 pm

Re: Image orientation in plupload, using EXIF

Post by Streamer76 »

Any new ideas to solve this :?:
KYPREO
Registered User
Posts: 392
Joined: Fri Feb 02, 2018 9:56 am
Contact:

Re: Image orientation in plupload, using EXIF

Post by KYPREO »

Streamer76 wrote:
Tue Apr 30, 2019 6:11 pm
Any new ideas to solve this :?:
The image rotation based on EXIF is performed by plupload. This only happens when you set maximum image dimensions which then forces plupload to reduce the image size.

In your settings, maximum image size is 0 x 0 so plupload is not engaged.

Change the maximum image dimensions in the ACP to say 960x720.

Now try uploading an image again.

In order to fix image rotation when you don't have a maximum image dimension set, you need to use this extension: viewtopic.php?f=456&t=2477256
phpBB user since 2002
www.AusRotary.com
Streamer76
Registered User
Posts: 58
Joined: Mon Dec 17, 2007 6:26 pm

Re: Image orientation in plupload, using EXIF

Post by Streamer76 »

Thanks!
Last edited by Mick on Sat May 04, 2019 10:40 am, edited 1 time in total.
Reason: Removed unnecessary quoting.
User avatar
mtn
Registered User
Posts: 4
Joined: Wed May 03, 2017 1:58 am
Contact:

Re: Image orientation in plupload, using EXIF

Post by mtn »

After searching the general forums and in area51 I thought this the best place to continue this discussion. The thread here also is good. I've done very careful debugging and there is indeed a genuine problem with plupload and current browsers. I'm happy to present my debugging for your review, but I thought I would just cut to the chase with my results and see if you agree or disagree as some of you may already know about this.

I'm not a developer but I know a lot of s/w. I have a thick skin so if you think I'm wrong let me know. Also, I believe this explains some of the confusion posted previously, why something worked for someone and not others, etc.

The bottom line is that current browsers now support auto image rotation natively. Plupload always draws to the browser's canvas which will, in turn, auto-rotate the image. However, plupload is designed to also rotate the image as part of its resizing code, independent of what the browser may or may not do. You'll essentially get a double rotation affect. The displayed image will not be correct, certainly not what you expected. Note that an original image that hasn't been rotated (orientation bit = 1) will not be affected by any of this.

Chrome 81, for example, was released about beginning of 2020 with first-time support for auto image rotation. If you were to use Chrome before this, then the combination of phpBB + plupload would work fine. Likewise, newer releases of Edge does auto-rotate and so on.

Drag-and-drop photo uploading, resizing, and EXIF stripping are incredibly important to me on my forums. To test my conclusions I wrote a patch that seems to work. I hesitate to post my patch as it modifies a core file and plupload (the code mods are very small though). I'd like to first hear from y'all since you know a lot more about how all these pieces fit together than I do.

I upgraded my forums from 3.2.0 to 3.3.2 and I was hoping the rotation problem would somehow fix itself. When it didn't I started this debugging.

My other concern, if you agree with me, is that going forward there's another possible issue. plupload has been commercialized and is no longer supported in the public domain. I looked at this company's licensing and I'm very suspicious about their lack of support and that it'll even work with the new browsers. At any rate, not sure what phpBB's position is on this. Again, I'm not expert on all this but surveying github and the websites seems to indicate this is what's happening.
Post Reply

Return to “phpBB Discussion”