View file vendor/intervention/image/src/Intervention/Image/Commands/StreamCommand.php

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