• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Auto Image Rotate for iPhone and iPad [Deleted]

AndyB

Well-known member
#1
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...
 

Rambro

Well-known member
#7
Also, some better detailed instructions on what to do with that code. Since its all inside the box, some people might not know where or what to copy/paste.
 

Rudy

Well-known member
#14
This hack probably needs modification to work in XF 1.2, as the line number now puts it in the middle of an existing function. (I can probably guess where it might go.)
 

Rudy

Well-known member
#15
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!
 

AndyB

Well-known member
#16
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
 

Rudy

Well-known member
#17
Provided this works on my server, what I might do is write that line as "@exec("/usr/bin.....etc. " so it kills any error message if it fails.