本文整理汇总了PHP中Intervention\Image\ImageManagerStatic::cache方法的典型用法代码示例。如果您正苦于以下问题:PHP ImageManagerStatic::cache方法的具体用法?PHP ImageManagerStatic::cache怎么用?PHP ImageManagerStatic::cache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Intervention\Image\ImageManagerStatic
的用法示例。
在下文中一共展示了ImageManagerStatic::cache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTest2
public function getTest2()
{
$this->layout = null;
$img = Image::cache(function ($image) {
$image->make('5721fc06d139a.jpg')->fit(300)->encode(null, 52);
// $image->make('5721fc06d139a.jpg')->resize(300)->encode(null, 52);
}, 12000, true);
// $img = Image::make('5721fc06d139a.jpg')->resize(300, 300)->greyscale();
// $img = Image::make('5721fc06d139a.jpg')->crop(300, 300, 200, 600);
// $img = Image::make('5721fc06d139a.jpg')->fit(400, 200);
// echo $img->response(null, 10);
// echo $img->fit(100,100)->response(null, 52);
echo $img->response();
// echo "<pre>";
// print_r($img);
// die;
}
示例2: thumbnails
protected function thumbnails($template, $filename)
{
\Config::set('veer.image_templates.original', null);
$image_path = public_path() . '/' . config('veer.images_path') . '/' . str_replace('..', '', $filename);
if (!$this->checkTemplate($template) || !$this->checkFilename($image_path)) {
return abort(404);
}
$params = config("veer.image_templates.{$template}");
if (!is_null($params)) {
//image manipulation based on callback
$content = Image::cache(function ($image) use($image_path, $params) {
$img = $image->make($image_path);
return $img->{array_get($params, 0, 'fit')}(array_get($params, 1), array_get($params, 2), function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
})->encode(null, 100);
}, config('veer.image_lifetime'));
} else {
$content = file_get_contents($image_path);
}
$mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $content);
return response($content, 200, array('Content-Type' => $mime, 'Cache-Control' => 'max-age=' . config('veer.image_lifetime') * 60 . ', public', 'Etag' => md5($content)));
}