我将图像存储在redis中。
$image = $cache->remember($key, null, function () use ($request, $args) {
$image = $this->get('image');
$storage = $this->get('storage');
return $image->load($storage->get($args['path'])->read())
->withFilters($request->getQueryParams())
->stream();
});
并试图取回它:
return (new Response())
->withHeader('Content-Type', 'image/png')
->withBody($image);
它给了我这个错误:
Return value of Slim\Handlers\Strategies\RequestResponse::__invoke()
must implement interface Psr\Http\Message\ResponseInterface, string returned
$image
变量是该图像的字节。如何将这些字节转换为流?