Created
December 14, 2017 15:47
-
-
Save cobolfoo/a1e84597a26a2ec9ff5556fb3bee86df to your computer and use it in GitHub Desktop.
JPG Rotation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$pleaseRotate = 0; | |
if ($file["type"] == "image/jpeg") { | |
$exif = exif_read_data($file["tmp_name"]); | |
if(!empty($exif['Orientation'])) { | |
switch($exif['Orientation']) { | |
case 8: | |
$pleaseRotate = 90; | |
break; | |
case 3: | |
$pleaserotate = 180; | |
break; | |
case 6: | |
$pleaseRotate =- 90; | |
break; | |
} | |
} | |
} | |
if ($pleaseRotate != 0) { | |
$img = imagerotate($img,$pleaseRotate,0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment