UPLOAD CHANGES IMAGE ORIENTATION

7 posts by 4 authors in: Forums > CMS Builder
Last Post: May 23, 2016   (RSS)

By Chris - March 1, 2016

Hi Tina,

Thanks for the example images, that made things very easy to test! I did some research and it seems like there aren't many cameras which rely on the EXIF Orientation tag rather than saving the image content with the correct rotation in the first place, which is why we haven't seen this issue come up often. The EXIF Orientation tag seems to be poorly-supported by many software systems, and unfortunately the PHP image processing functions we're relying on don't offer support for it.

I wrote a patch which will rotate affected uploaded images before they go through the complicated "resizeOversizedImages" step, but unfortunately it seems like this approach uses a lot of memory, so we can't enable this solution by default. We're going to try to come up with a better long-term solution that will work for everyone, but in the meantime, the next version of CMS Builder will include the following code in cmsb/lib/upload_functions.php:

  // [experimental] rotate uploaded JPEG file if EXIF Orientation flag has been set
  // explanation: certain cameras save rotated JPEG content and use a poorly-supported EXIF flag to tell users the image must be rotated (90, -90, or 180)
  // our resampling code, which relies on GD, doesn't respect or preserve that flag, which can result in certain uploaded files being saved with incorrect rotation
  // in testing, doing rotations like the following before resampling caused out-of-memory errors on reasonably large image files, so this fix has been disabled by default
  $fixJpegExifOrientation = false; // defaulted to false to avoid potential out-of-memory errors
  if ($fixJpegExifOrientation) {
    _image_fixJpegExifOrientation($mainUploadWorkingPath);
  }

Once you've upgraded to the next version of CMSB, (we should be releasing it for beta testing within the next couple days,) you can edit this file and change "false" to "true", which should fix rotation issues for you. Please make sure to test it by uploading a big image to make sure your server has enough memory to be able to rotate the image. If you get an "out of memory" error, let us know and we'll let you know what your options are.

All the best,
Chris

By csdesign - April 7, 2016

Will do! thanks so much for the reply!! 

By pixelMIGHT(Josh) - May 23, 2016

Hello. I am having the same problem with images. The culprit in this case is a Samsung S5. 

I did at one time have Interactive Tools create a plugin that added a Rotate button to the upload preview, but with Version 3 it doesn't work. Here are the errors: 

E_WARNING: include(): Failed opening 'lib/menus/default/uploadModify.php' for inclusion (include_path='/data/23/2/0/101/2652264/user/2911153/htdocs/BESnet/cms:/data/23/2/0/101/2652264/user/2911153/htdocs/BESnet/cms/3rdParty:.:/usr/share/php:/usr/services/vux/lib/php')

E_WARNING: include(lib/menus/default/uploadModify.php): failed to open stream: No such file or directory

E_WARNING: include(lib/menus/default/uploadModify.php): failed to open stream: No such file or directory

E_WARNING: require_once(lib/menus/default/uploadForm_functions.php): failed to open stream: No such file or directory

(Of course www.domain.com contains the actual domain.)

I saw in the documentation "To fix replace START_TIME with $_SERVER['REQUEST_TIME_FLOAT']" but I cannot find this line in any files.

Is there something in the custom plugin files I should change?

I can upload them here or send them to you if helpful. 

Thank you

By pixelMIGHT(Josh) - May 23, 2016

Also, I what Tina suggested above but I do get the Out of Memory warning. If that can be adjusted and images upload correctly, that is fine too. 

Either solution is fine with me, but preferably it would upload correctly to start. 

Thanks

By Damon - May 23, 2016

Josh,

Can you reply to the consulting email ticket from when you had the custom Rotate image plugin written?

Then we can review the code and get back to you with details.

Thanks!

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By pixelMIGHT(Josh) - May 23, 2016

Thanks, Damon. 

I've replied to the original email.

Josh