File indexing completed on 2025-01-26 05:29:14

0001 <?php
0002 
0003 namespace Intervention\Image\Gd\Commands;
0004 
0005 use Intervention\Image\Gd\Color;
0006 
0007 class RotateCommand extends \Intervention\Image\Commands\AbstractCommand
0008 {
0009     /**
0010      * Rotates image counter clockwise
0011      *
0012      * @param  \Intervention\Image\Image $image
0013      * @return boolean
0014      */
0015     public function execute($image)
0016     {
0017         $angle = $this->argument(0)->type('numeric')->required()->value();
0018         $color = $this->argument(1)->value();
0019         $color = new Color($color);
0020 
0021         // restrict rotations beyond 360 degrees, since the end result is the same
0022         $angle %= 360;
0023 
0024         // rotate image
0025         $image->setCore(imagerotate($image->getCore(), $angle, $color->getInt()));
0026 
0027         return true;
0028     }
0029 }