ResizeCommand.php 720 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace Intervention\Image\Imagick\Commands;
  3. use Intervention\Image\Commands\AbstractCommand;
  4. class ResizeCommand extends AbstractCommand
  5. {
  6. /**
  7. * Resizes image dimensions
  8. *
  9. * @param \Intervention\Image\Image $image
  10. * @return boolean
  11. */
  12. public function execute($image)
  13. {
  14. $width = $this->argument(0)->value();
  15. $height = $this->argument(1)->value();
  16. $constraints = $this->argument(2)->type('closure')->value();
  17. // resize box
  18. $resized = $image->getSize()->resize($width, $height, $constraints);
  19. // modify image
  20. $image->getCore()->scaleImage($resized->getWidth(), $resized->getHeight());
  21. return true;
  22. }
  23. }