I have a problem with users taking photos with an IPAD . When you view in windows and they do not use landcape view with external lens on upper left, the phprunner upload file turns the photo 90 degress to the right.
It has something to do with EXIF data on IOS , I tried this fix but I also use misc upload to change filesnames. here is my code if someone has any ideas.
//read EXIF header from uploaded file
$exif = exif_read_data($_FILES['photo_upload']['tmp_name']);
//fix the Orientation if EXIF data exist
if(!empty($exif['Orientation'])) {
switch($exif['Orientation']) {
case 8:
$createdImage = imagerotate($image,90,0);
break;
case 3:
$createdImage = imagerotate($image,180,0);
break;
case 6:
$createdImage = imagerotate($image,-90,0);
break;
}
}
// The above does not work and can't see why it would not__
// end fix orientation from IOS to Windows please note IOS strips EXIF data so we need to change orientation before we save to windows server
// change file name - this works fine
// get information about uploaded files
$fileArray = my_json_decode($values["photo_upload"]);
// **rename each file. In this example - convert to timestamp and userid in database **
for($i = 0; $i < count($fileArray); $i++)
{
$fileArray[$i]["usrName"] = date('m-d-Y-h-i-s'). "" . $values["brand"] . "". $values["custname"] ." .jpg";
}
// update values of the field that stores file names **** my photo upload field ****
$values["photo_upload"] = my_json_encode($fileArray);
//****End change filename in database ****
// ***Start change filename on disk folder ****
$fileArray = my_json_decode($values["photoupload"]);
//rename files in Upload folder**
for($i = 0; $i < count($fileArray); $i++)
{
$fileName = $fileArray[$i]["name"];
$newFileName = "C:\\Inetpub\\vhosts\\mywebsite.com\\Photos/".date('m-d-Y-h-i-s'). "" . $values["brand"] . "_". $values["custname"] ." .jpg";
rename($fileName,$newFileName);
$fileArray[$i]["name"] = $newFileName;
}
// update values of the field that stores file names *my photo upload field ***
$values["photo_upload"] = my_json_encode($fileArray);
return true;
Can someone comment here on how to fix this problem. reall annoying that I have phprunner uploads with the photo sideways.