fixes regression in createthumb.php, adds readability

This commit is contained in:
Jan Niggemann 2015-02-23 16:17:21 +01:00
parent 6cf6beb978
commit 4b7ce9dbec

View file

@ -124,23 +124,41 @@ else
} }
// Rotate JPG pictures // Rotate JPG pictures
// for more info on orientation see
// http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto/
$degrees = 0; $degrees = 0;
$flip = ''; $flip = '';
if ($get_filename_type == "JPG") if (preg_match("/.jpg$|.jpeg$/i", $_GET['filename'])) {
{ if (function_exists('exif_read_data') && function_exists('imagerotate')) {
if (function_exists('exif_read_data') && function_exists('imagerotate')) $exif = exif_read_data($_GET['filename'], 0, true);
{
$exif = exif_read_data($get_filename, 0, true);
if (isset($exif['IFD0']) && isset($exif['IFD0']['Orientation']))
$ort = $exif['IFD0']['Orientation']; $ort = $exif['IFD0']['Orientation'];
else switch ($ort) {
$ort = 0; case 3: // 180 rotate right
// for more info on orientation see $degrees = 180;
// http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto/ break;
$ort2deg = array(3=>180, 4=>180, 5=>270, 6=>270, 7=>90, 8=>90); case 6: // 90 rotate right
$degrees = in_array($ort, $ort2deg) ? $ort2deg[$ort] : 0; $degrees = 270;
$ort2flip = array(2, 4, 5, 7); break;
$flip = in_array($ort, $flip2deg) ? 'vertical' : ''; case 8: // 90 rotate left
$degrees = 90;
break;
case 2: // flip vertical
$flip = 'vertical';
break;
case 7: // flipped
$degrees = 90;
$flip = 'vertical';
break;
case 5: // flipped
$degrees = 270;
$flip = 'vertical';
break;
case 4: // flipped
$degrees = 180;
$flip = 'vertical';
break;
}
} }
} }