Merge pull request #13448 from owncloud/fix-exif-orientation

Fix exif orientation for flipped images
This commit is contained in:
Georg Ehrke 2015-01-19 00:12:55 +01:00
commit 9cef90da98
1 changed files with 12 additions and 5 deletions

View File

@ -358,35 +358,42 @@ class OC_Image {
$o = $this->getOrientation(); $o = $this->getOrientation();
$this->logger->debug('OC_Image->fixOrientation() Orientation: ' . $o, array('app' => 'core')); $this->logger->debug('OC_Image->fixOrientation() Orientation: ' . $o, array('app' => 'core'));
$rotate = 0; $rotate = 0;
$flip = false;
switch ($o) { switch ($o) {
case -1: case -1:
return false; //Nothing to fix return false; //Nothing to fix
case 1: case 1:
$rotate = 0; $rotate = 0;
break; break;
case 2: // Not tested case 2:
$rotate = 0; $rotate = 0;
$flip = true;
break; break;
case 3: case 3:
$rotate = 180; $rotate = 180;
break; break;
case 4: // Not tested case 4:
$rotate = 180; $rotate = 180;
$flip = true;
break; break;
case 5: // Not tested case 5:
$rotate = 90; $rotate = 90;
$flip = true;
break; break;
case 6: case 6:
//$rotate = 90;
$rotate = 270; $rotate = 270;
break; break;
case 7: // Not tested case 7:
$rotate = 270; $rotate = 270;
$flip = true;
break; break;
case 8: case 8:
$rotate = 90; $rotate = 90;
break; break;
} }
if($flip) {
imageflip($this->resource, IMG_FLIP_HORIZONTAL);
}
if ($rotate) { if ($rotate) {
$res = imagerotate($this->resource, $rotate, 0); $res = imagerotate($this->resource, $rotate, 0);
if ($res) { if ($res) {