argument(0)->value(); $quality = $this->argument(1)->between(0, 100)->value(); //Encoded property will be populated at this moment $stream = $image->stream($format, $quality); $mimetype = finfo_buffer( finfo_open(FILEINFO_MIME_TYPE), $image->getEncoded() ); $this->setOutput(new Response( 200, [ 'Content-Type' => $mimetype, 'Content-Length' => strlen($image->getEncoded()) ], $stream )); return true; } }