diff options
author | Aaron Parecki <aaron@parecki.com> | 2017-02-24 16:40:56 -0800 |
---|---|---|
committer | Aaron Parecki <aaron@parecki.com> | 2017-02-24 16:40:56 -0800 |
commit | 202a7876ec508fd70385497c1508b33aeb367c67 (patch) | |
tree | 43d4b47bdded27b9f7d8a591462ac61e0d0562e5 /lib | |
parent | 4f1c21523f5d1ef511b0b23d19674d761f932694 (diff) |
nicer photo uploading experience
Diffstat (limited to 'lib')
-rw-r--r-- | lib/helpers.php | 32 |
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){} } } |