FlipCommand.php 628 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace Intervention\Image\Imagick\Commands;
  3. use Intervention\Image\Commands\AbstractCommand;
  4. class FlipCommand extends AbstractCommand
  5. {
  6. /**
  7. * Mirrors an image
  8. *
  9. * @param \Intervention\Image\Image $image
  10. * @return boolean
  11. */
  12. public function execute($image)
  13. {
  14. $mode = $this->argument(0)->value('h');
  15. if (in_array(strtolower($mode), [2, 'v', 'vert', 'vertical'])) {
  16. // flip vertical
  17. return $image->getCore()->flipImage();
  18. } else {
  19. // flip horizontal
  20. return $image->getCore()->flopImage();
  21. }
  22. }
  23. }