Zamieniłem to
$exif = exif_read_data($jpgFile . $thumbFile);
$orientation = $exif['IFD0']['Orientation'];
na to
$exif = exif_read_data($jpgFile);
$orientation = $exif['Orientation'];
Teraz wszystko działa, jakby ktoś potrzebwał daję cały działający kod
$jpgFile = 'uploads/img.jpg';
$thumbFile = 'uploads/img.jpg';
$width = 1024;
$exif = exif_read_data($jpgFile);
$orientation = $exif['Orientation'];
function resample($jpgFile, $thumbFile, $width, $orientation) {
// Get new dimensions
$height = (int) (($width / $width_orig) * $height_orig);
// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($jpgFile);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// Fix Orientation
switch($orientation) {
case 3:
$image_p = imagerotate($image_p, 180, 0);
break;
case 6:
$image_p = imagerotate($image_p, -90, 0);
break;
case 8:
$image_p = imagerotate($image_p, 90, 0);
break;
}
// Output
imagejpeg($image_p, $thumbFile, 90);
}
resample($jpgFile, $thumbFile, $width, $orientation);