From 7b4b27098d886effc98ff024b9c25b714df6b1d8 Mon Sep 17 00:00:00 2001 From: Will Franklin Date: Thu, 24 Aug 2023 16:30:11 +0100 Subject: [PATCH] Add support for flipping images too --- content-controllers/image/image.controller.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/content-controllers/image/image.controller.php b/content-controllers/image/image.controller.php index 3219c9b..584c1a2 100644 --- a/content-controllers/image/image.controller.php +++ b/content-controllers/image/image.controller.php @@ -32,12 +32,29 @@ public function handleUpload($tmpfile,$hash=false) $exif = exif_read_data($tmpfile); if (!empty($exif['Orientation'])) { switch ($exif['Orientation']) { + case 2: + imageflip($res, IMG_FLIP_HORIZONTAL); + case 1: + // Nothing to do + break; + + case 4: + imageflip($res, IMG_FLIP_HORIZONTAL); + // Also rotate case 3: $res = imagerotate($res, 180, 0); break; + + case 5: + imageflip($res, IMG_FLIP_VERTICAL); + // Also rotate case 6: $res = imagerotate($res, -90, 0); break; + + case 7: + imageflip($res, IMG_FLIP_VERTICAL); + // Also rotate case 8: $res = imagerotate($res, 90, 0); break;