summaryrefslogtreecommitdiff
path: root/lib/helpers.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/helpers.php')
-rw-r--r--lib/helpers.php32
1 files changed, 17 insertions, 15 deletions
diff --git a/lib/helpers.php b/lib/helpers.php
index d932e67..b7ae78d 100644
--- a/lib/helpers.php
+++ b/lib/helpers.php
@@ -363,21 +363,23 @@ function validate_photo(&$file) {
// Only does anything if the exif library is loaded, otherwise is a noop.
function correct_photo_rotation($filename) {
if(class_exists('IMagick')) {
- $image = new IMagick($filename);
- $orientation = $image->getImageOrientation();
- switch($orientation) {
- case IMagick::ORIENTATION_BOTTOMRIGHT:
- $image->rotateImage(new ImagickPixel('#00000000'), 180);
- break;
- case IMagick::ORIENTATION_RIGHTTOP:
- $image->rotateImage(new ImagickPixel('#00000000'), 90);
- break;
- case IMagick::ORIENTATION_LEFTBOTTOM:
- $image->rotateImage(new ImagickPixel('#00000000'), -90);
- break;
- }
- $image->setImageOrientation(IMagick::ORIENTATION_TOPLEFT);
- $image->writeImage($filename);
+ try {
+ $image = new IMagick($filename);
+ $orientation = $image->getImageOrientation();
+ switch($orientation) {
+ case IMagick::ORIENTATION_BOTTOMRIGHT:
+ $image->rotateImage(new ImagickPixel('#00000000'), 180);
+ break;
+ case IMagick::ORIENTATION_RIGHTTOP:
+ $image->rotateImage(new ImagickPixel('#00000000'), 90);
+ break;
+ case IMagick::ORIENTATION_LEFTBOTTOM:
+ $image->rotateImage(new ImagickPixel('#00000000'), -90);
+ break;
+ }
+ $image->setImageOrientation(IMagick::ORIENTATION_TOPLEFT);
+ $image->writeImage($filename);
+ } catch(Exception $e){}
}
}