Some times ago i wrote a method to read out the EXIF-data from a uploaded picture in a online-community. After i got the orientation from the picture, i rotated the file in the right direction. Only a short part from my script:
public function rotate($sourceFile, $targetFile, $orienation)
{
switch($orienation){
case 3: $degrees = '180'; break;
case 6: $degrees = '90'; break;
case 8: $degrees = '270'; break;
default: $degrees = '0';
}
$file = $sourceFile . DS . $targetFile;
$rotate = GlobalConfig::BIN_IMAGICK_CONVERT . ' -rotate ' . $degrees . ' ' . $file . ' ' . $file;
exec($rotate);
}
My script is working. But my question is, how other big guys like facebook, handle the rotation from uploaded pictures? Because my solution is certainly not the best.