diff options
-rw-r--r-- | src/PHPImageWorkshop/Core/ImageWorkshopLayer.php | 19 | ||||
-rw-r--r-- | src/PHPImageWorkshop/Exif/ExifOrientations.php | 19 |
2 files changed, 29 insertions, 9 deletions
diff --git a/src/PHPImageWorkshop/Core/ImageWorkshopLayer.php b/src/PHPImageWorkshop/Core/ImageWorkshopLayer.php index 5bab943..185a0e3 100644 --- a/src/PHPImageWorkshop/Core/ImageWorkshopLayer.php +++ b/src/PHPImageWorkshop/Core/ImageWorkshopLayer.php @@ -2,6 +2,7 @@ namespace PHPImageWorkshop\Core;
+use PHPImageWorkshop\Exif\ExifOrientations;
use PHPImageWorkshop\ImageWorkshop as ImageWorkshop;
use PHPImageWorkshop\Core\ImageWorkshopLib as ImageWorkshopLib;
use PHPImageWorkshop\Core\Exception\ImageWorkshopLayerException as ImageWorkshopLayerException;
@@ -1872,43 +1873,43 @@ class ImageWorkshopLayer */
public function fixOrientation()
{
- if (!isset($this->exif['Orientation'])) {
+ if (!isset($this->exif['Orientation']) || 0 == $this->exif['Orientation']) {
return;
}
switch ($this->exif['Orientation']) {
- case 2:
+ case ExifOrientations::TOP_RIGHT:
$this->flip('horizontal');
break;
- case 3:
+ case ExifOrientations::BOTTOM_RIGHT:
$this->rotate(180);
break;
- case 4:
+ case ExifOrientations::BOTTOM_LEFT:
$this->flip('vertical');
break;
- case 5:
+ case ExifOrientations::LEFT_TOP:
$this->rotate(-90);
$this->flip('vertical');
break;
- case 6:
+ case ExifOrientations::RIGHT_TOP:
$this->rotate(90);
break;
- case 7:
+ case ExifOrientations::RIGHT_BOTTOM:
$this->rotate(90);
$this->flip('horizontal');
break;
- case 8:
+ case ExifOrientations::LEFT_BOTTOM:
$this->rotate(-90);
break;
}
- $this->exif['Orientation'] = 1;
+ $this->exif['Orientation'] = ExifOrientations::TOP_LEFT;
}
// Deprecated, don't use anymore
diff --git a/src/PHPImageWorkshop/Exif/ExifOrientations.php b/src/PHPImageWorkshop/Exif/ExifOrientations.php new file mode 100644 index 0000000..94fa5df --- /dev/null +++ b/src/PHPImageWorkshop/Exif/ExifOrientations.php @@ -0,0 +1,19 @@ +<?php + +namespace PHPImageWorkshop\Exif; + +/** + * Container for all EXIF orientations. + */ +final class ExifOrientations +{ + const UNDEFINED = 0; + const TOP_LEFT = 1; + const TOP_RIGHT = 2; + const BOTTOM_RIGHT = 3; + const BOTTOM_LEFT = 4; + const LEFT_TOP = 5; + const RIGHT_TOP = 6; + const RIGHT_BOTTOM = 7; + const LEFT_BOTTOM = 8; +} |