StreamCommand.php 609 B

12345678910111213141516171819202122232425
  1. <?php
  2. namespace Intervention\Image\Commands;
  3. class StreamCommand extends AbstractCommand
  4. {
  5. /**
  6. * Builds PSR7 stream based on image data. Method uses Guzzle PSR7
  7. * implementation as easiest choice.
  8. *
  9. * @param \Intervention\Image\Image $image
  10. * @return boolean
  11. */
  12. public function execute($image)
  13. {
  14. $format = $this->argument(0)->value();
  15. $quality = $this->argument(1)->between(0, 100)->value();
  16. $this->setOutput(\GuzzleHttp\Psr7\stream_for(
  17. $image->encode($format, $quality)->getEncoded()
  18. ));
  19. return true;
  20. }
  21. }