I need some help to fix the orientation issue in regrades with iOS photos.

The images uploaded to the server are out of Orientation due to Apple. I think the below code is working but I can't seem to upload the altered image to the server.

Here is the PhP

<?php
session_start();


$filename = $_FILES['file']['name'];
$filePath = $_FILES['file']['tmp_name'];
$exif = exif_read_data($_FILES['file']['tmp_name']);
if (!empty($exif['Orientation'])) {
    $imageResource = imagecreatefromjpeg('/uploads'); // provided that the             image is jpeg. Use relevant function otherwise
    switch ($exif['Orientation']) {
        case 3:
    $image = imagerotate($imageResource, 180, 0);
    break;

case 6:
$image = imagerotate($imageResource, -90, 0);
break;

case 8:
$image = imagerotate($imageResource, 90, 0);
break;

default:
$image = $imageResource;
} 
}

imagejpeg($image, $filename, 90);



?>

This code seems to work but I havn't seen the outputted image as I can't move the altered image to the server.

I didn't even know that Apple phone did this little bit of extra evil.

Thanks for any help.

    I've attempted a great deal of solutions now without victory. I'm completely lost.

          $imageResource = imagecreatefromjpeg('/uploads');

      I'm guessing you'd rather be using [font=monospace]$filePath[/font] here instead of the string.

        Write a Reply...