I get exif to read orientation of upload images. The problem is in some images I'm getting this error:
warning exif_read_data(php3KLADx): File not supported in /home/i/public_html/orientation.php on line 5
any ideas how to avoid this?
<?php
function exif_orientation($file_tmp) {
$image = imagecreatefromstring(file_get_contents($file_tmp));
$exif = exif_read_data($file_tmp);
if(!empty($exif['Orientation'])) {
switch($exif['Orientation']) {
case 8:
$image = imagerotate($image,90,0);
break;
case 3:
$image = imagerotate($image,180,0);
break;
case 6:
$image = imagerotate($image,-90,0);
break;
}
imagejpeg($image, $file_tmp, 90);
}
}
?>