Skip to content

Instantly share code, notes, and snippets.

@cobolfoo
Created December 14, 2017 15:47
Show Gist options
  • Save cobolfoo/a1e84597a26a2ec9ff5556fb3bee86df to your computer and use it in GitHub Desktop.
Save cobolfoo/a1e84597a26a2ec9ff5556fb3bee86df to your computer and use it in GitHub Desktop.
JPG Rotation
$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