when user register with image. Now what i want to do is what ever rotation of the picture he uploaded, I just need to fetch all the user with there name and image. Here is the thing when fetching the details of the users i need image to be in the correct rotation. whether user uploaded in landscape or any angel i want it in correct. I have tried so many method like exif_read_data but it does not worked in the latest php and when i tried to dis on old version of the php it gives me the error Illegal IFD size. Is their another method to this. Let se the code.
<?php
$host="localhost";
$uname="root";
$upass="";
$link=mysqli_connect($host,$uname,$upass,"test");
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
<script type="text/javascript" charset="utf8" src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function() {
var table = $('#example').DataTable();
} );
</script>
</head>
<body>
<table id="example" class="display" style="width:100%">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Salary</th>
<th>Image</th>
</tr>
</thead>
<tbody>
<?php
$sql="select * from imageproblem";
$result=mysqli_query($link,$sql) or die('mysqli error:query is wrong');
while($row=mysqli_fetch_assoc($result))
{
echo '<tr>';
echo '<td>';
echo $row['id'];
echo '</td>';
echo '<td>';
echo $row['name'];
echo '</td>';
echo '<td>';
echo $row['salary'];
echo '</td>';
$destination='images/'.$row['image'];
$exif = exif_read_data($destination);
if (!empty($exif['Orientation'])) {
switch ($exif['Orientation']) {
case 8:
$command = 'mogrify -rotate "90" -auto-orient ' . $destination;
exec("$command");
break;
case 3:
$command = 'mogrify -rotate "180" -auto-orient ' . $destination;
exec("$command");
break;
case 6:
$command = 'mogrify -rotate "-90" -auto-orient ' . $destination;
exec("$command");
break;
}
}
echo '<td>';
echo '<img src="images/'.$row['image'].'" width="50" />';
echo '</td>';
echo '</tr>';
}
?>
</tbody>
</table>
</body>
</html>