本文整理汇总了PHP中Intervention\Image\Image::getEncoded方法的典型用法代码示例。如果您正苦于以下问题:PHP Image::getEncoded方法的具体用法?PHP Image::getEncoded怎么用?PHP Image::getEncoded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Intervention\Image\Image
的用法示例。
在下文中一共展示了Image::getEncoded方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Builds PSR7 compatible response. May replace "response" command in
* some future.
*
* Method will generate binary stream and put it inside PSR-7
* ResponseInterface. Following code can be optimized using native php
* streams and more "clean" streaming, however drivers has to be updated
* first.
*
* @param \Intervention\Image\Image $image
* @return boolean
*/
public function execute($image)
{
$format = $this->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, array('Content-Type' => $mimetype, 'Content-Length' => strlen($image->getEncoded())), $stream));
return true;
}
示例2: streamImage
private function streamImage(Application $app, Image $image)
{
$image->encode(null, $this->default_quality);
$mime = self::getMimeFromData($image->getEncoded());
return $app->stream(function () use($image) {
// echo $image->response();
echo $image->getEncoded();
}, 200, array('Content-Type' => $mime));
}