From 4b063ab098f80d4710c0f9d6ea29c7ea40bfc81c Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Thu, 11 Nov 2021 15:21:50 +0000 Subject: [PATCH] RotateModifier --- src/Drivers/Gd/Modifiers/RotateModifier.php | 50 +++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/Drivers/Gd/Modifiers/RotateModifier.php diff --git a/src/Drivers/Gd/Modifiers/RotateModifier.php b/src/Drivers/Gd/Modifiers/RotateModifier.php new file mode 100644 index 00000000..6c8b507a --- /dev/null +++ b/src/Drivers/Gd/Modifiers/RotateModifier.php @@ -0,0 +1,50 @@ +angle = $angle; + $this->backgroundcolor = $backgroundcolor; + } + + public function apply(ImageInterface $image): ImageInterface + { + foreach ($image as $frame) { + imagerotate($frame->getCore(), $this->rotationAngle(), 0); + } + + return $image; + } + + protected function rotationAngle(): float + { + // restrict rotations beyond 360 degrees, since the end result is the same + return fmod($this->angle, 360); + } +}