Auto Image Rotate for iPhone and iPad [Deleted]

AndyB

Well-known member
AndyB submitted a new resource:

Auto Image Orientation for iPhone and iPad - Uploaded images from iPhone and iPad will auto orient

This hack will fix the problem when images uploaded from an iPhone or iPad end up in the wrong orientation (sideways).

You must have ImageMagick installed.

Code:
library/Xenforo/Upload.php

Line #189

Add hack to auto orient iPhone and iPad images.

$imageInfo = @getimagesize($this->_tempFile);
if (!$imageInfo)
{
    return;
}

// start hack	

exec("/usr/bin/mogrify -auto-orient $this->_tempFile");

// end hack

Read more about this resource...
 
OK, just eyeballing things here, this is where the hack must go in XF 1.2, inserting it around line 204.

Code:
        $imageInfo = @getimagesize($this->_tempFile);
        if (!$imageInfo)
        {
            if (in_array($this->_extension, array('gif', 'jpg', 'jpe', 'jpeg', 'png')))
            {
                $this->_errors['extension'] = new XenForo_Phrase('the_uploaded_file_was_not_an_image_as_expected');
            }
            return;
        }

// START HACK
exec("/usr/bin/mogrify -auto-orient $this->_tempFile");
// END HACK

        $imageInfo['width'] = $imageInfo[0];
        $imageInfo['height'] = $imageInfo[1];
        $imageInfo['type'] = $imageInfo[2];

Untested!
 
For Xenforo version 1.2.

File: library/Xenforo/Upload.php

At line #195

Code:
		$imageInfo = @getimagesize($this->_tempFile);
		if (!$imageInfo)
		{
			if (in_array($this->_extension, array('gif', 'jpg', 'jpe', 'jpeg', 'png')))
			{
				$this->_errors['extension'] = new XenForo_Phrase('the_uploaded_file_was_not_an_image_as_expected');
			}
			return;
		}
		
		// start hack	
		
		exec("/usr/bin/mogrify -auto-orient $this->_tempFile");
		
		// end hack
 
Back
Top Bottom