Answer the question
In order to leave comments, you need to log in
How to rotate a photo based on data from EXIF correctly and once?
I welcome everyone!
On the same versions of PHP, the imagecreatefromstring and imagejpeg functions work differently.
For example, there is a code:
if (move_uploaded_file($tmp_filename, $fullpath)) {
$image = imagecreatefromstring(file_get_contents($fullpath));
# rotate
$exif = exif_read_data($fullpath);
$angles= array(8 => 90, 3 => 180, 6 => -90);
if(!empty($exif['Orientation']) && isset($angles[$exif['Orientation']])) {
$image = imagerotate($image, $angles[$exif['Orientation']], 0);
}
# rotate
imagejpeg($image, $fullpath);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question