当前位置: 首页>>代码示例>>PHP>>正文


PHP ImageManager::cache方法代码示例

本文整理汇总了PHP中Intervention\Image\ImageManager::cache方法的典型用法代码示例。如果您正苦于以下问题:PHP ImageManager::cache方法的具体用法?PHP ImageManager::cache怎么用?PHP ImageManager::cache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Intervention\Image\ImageManager的用法示例。


在下文中一共展示了ImageManager::cache方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: apply

 /**
  * Apply resize
  * 
  * @param string $path
  * @return Psr-7 stream
  */
 public function apply($path)
 {
     $library = $this->libraryRepostiory->findByPath($path)->toArray();
     $storage = $library['description']['is_moved'] ? $library['description']['storage'] : 'local';
     $filesystem = $this->filesystemFactory->disk($storage);
     $stream = $filesystem->getDriver()->readStream($path);
     $lastModified = $filesystem->lastModified($path);
     return $this->imageManager->cache(function ($image) use($stream, $lastModified) {
         $this->process($image->setProperty('lastModified', $lastModified)->make($stream));
     }, $this->getLifetime());
 }
开发者ID:inoplate,项目名称:media,代码行数:17,代码来源:RuntimeResizer.php

示例2: view

 public function view($width = null, $height = null)
 {
     $filename = $this->asset->exists() ? $this->asset->getFilename() : __DIR__ . '/../../../../vendor/boomcms/boom-core/img/placeholder.png';
     if ($width || $height) {
         $image = $this->manager->cache(function ($manager) use($width, $height, $filename) {
             return $manager->make($filename)->resize($width != 0 ? $width : null, $height != 0 ? $height : null, function ($constraint) {
                 $constraint->aspectRatio();
                 $constraint->upsize();
             })->encode($this->encoding);
         });
     } else {
         $image = $this->manager->make($this->asset->getFilename())->encode();
     }
     return $this->response->header('content-type', $this->asset->getMimetype())->setContent($image);
 }
开发者ID:imanghafoori1,项目名称:boom-core,代码行数:15,代码来源:Image.php

示例3: handle

 /**
  * @param MediaRepositoryInterface $media
  * @param ImageManager $images
  * @param Filesystem $files
  * @return bool
  * @throws Exception
  */
 public function handle(MediaRepositoryInterface $media, ImageManager $images, Filesystem $files)
 {
     list($width, $height) = $this->dimensions($this->size);
     $path = $this->getPath($files);
     $constraint = $this->constraint($width, $height);
     $image = $images->cache(function ($image) use($width, $height, $constraint) {
         if ($this->cachedPath) {
             $image = $image->make($this->cachedPath);
         } else {
             $image = $image->make(public_path($this->image->path));
         }
         $image->resize($width, $height, $constraint);
     }, 60, true)->save($path);
     if ($image) {
         //always fetch the actual width and height from the image,
         //one of them could have been null to auto scale the image.
         $width = $image->getWidth();
         $height = $image->getHeight();
         //use html public path to store in database
         $path = $this->getPath($files, true);
         try {
             $media->createThumbnailImage($this->getPayload($width, $height, $path), $this->image);
         } catch (Exception $e) {
             $files->delete(public_path($path));
             unset($image);
             return false;
         }
         unset($image);
     }
 }
开发者ID:jaffle-be,项目名称:framework,代码行数:37,代码来源:ResizeImage.php

示例4: view

 public function view($width = null, $height = null)
 {
     if (!empty($width) || !empty($height)) {
         $image = $this->manager->cache(function (ImageCache $cache) use($width, $height) {
             $width = empty($width) ? null : $width;
             $height = empty($height) ? null : $height;
             return $cache->make($this->asset->getFilename())->resize($width, $height, function (Constraint $constraint) {
                 $constraint->aspectRatio();
                 $constraint->upsize();
             })->encode($this->encoding);
         });
     } else {
         $image = $this->manager->make($this->asset->getFilename())->encode();
     }
     return $this->response->header('content-type', $this->asset->getMimetype())->setContent($image);
 }
开发者ID:boomcms,项目名称:boom-core,代码行数:16,代码来源:Image.php

示例5: thumb

 public function thumb($width = null, $height = null)
 {
     $manager = new ImageManager();
     $thumb = new PdfThumbnail($this->asset);
     if ($width && $height) {
         $image = $manager->cache(function ($manager) use($width, $height, $thumb) {
             return $manager->make($thumb->getAndMakeFilename())->fit($width, $height);
         });
     } else {
         $image = $manager->make($thumb->getAndMakeFilename())->encode();
     }
     return $this->response->header('content-type', 'image/png')->setContent($image);
 }
开发者ID:boomcms,项目名称:boom-core,代码行数:13,代码来源:Pdf.php

示例6: getImage

 /**
  * Get HTTP response of template applied image file
  *
  * @param  string $template
  * @param  string $filename
  * @return Illuminate\Http\Response
  */
 public function getImage($template, $filename)
 {
     $template = $this->getTemplate($template);
     $path = $this->getImagePath($filename);
     // image manipulation based on callback
     $manager = new ImageManager(Config::get('image'));
     $content = $manager->cache(function ($image) use($template, $path) {
         if ($template instanceof Closure) {
             // build from closure callback template
             $template($image->make($path));
         } else {
             // build from filter template
             $image->make($path)->filter($template);
         }
     }, config('imagecache.lifetime'));
     return $this->buildResponse($content);
 }
开发者ID:powercen,项目名称:imagecache,代码行数:24,代码来源:ImageCacheController.php

示例7: thumb

 public function thumb($width = null, $height = null)
 {
     if (!$this->asset->hasThumbnail()) {
         return parent::thumb();
     }
     $thumbnail = $this->asset->getThumbnail();
     $filename = $thumbnail->getFilename();
     $im = new ImageManager();
     if ($width && $height) {
         $image = $im->cache(function ($manager) use($width, $height, $filename) {
             return $manager->make($filename)->fit($width, $height);
         });
     } else {
         $image = $im->make($filename)->encode();
     }
     return $this->response->header('content-type', $thumbnail->getMimetype())->setContent($image);
 }
开发者ID:robbytaylor,项目名称:boom-core,代码行数:17,代码来源:Video.php

示例8: thumb

 public function thumb($width = null, $height = null)
 {
     if (!$this->asset->hasThumbnail()) {
         return $this->response->header('Content-type', 'image/png')->setContent(readfile(__DIR__ . "/../../../../../public/img/extensions/{$this->asset->getExtension()}.png"));
     }
     $thumbnail = $this->asset->getThumbnail();
     $filename = $thumbnail->getFilename();
     $im = new ImageManager();
     if ($width || $height) {
         $image = $im->cache(function (ImageCache $cache) use($width, $height, $filename) {
             $width = empty($width) ? null : $width;
             $height = empty($height) ? null : $height;
             return $cache->make($filename)->resize($width, $height, function (Constraint $constraint) {
                 $constraint->aspectRatio();
                 $constraint->upsize();
             })->encode('image/png');
         });
     } else {
         $image = $im->make($filename)->encode();
     }
     return $this->response->header('content-type', $thumbnail->getMimetype())->setContent($image);
 }
开发者ID:boomcms,项目名称:boom-core,代码行数:22,代码来源:BaseController.php

示例9: cache

 /**
  * Create new cached image and run callback
  * (requires additional package intervention/imagecache)
  *
  * @param \Closure $callback
  * @param integer $lifetime
  * @param boolean $returnObj
  * @return \Intervention\Image\Image 
  * @static 
  */
 public static function cache($callback, $lifetime = null, $returnObj = false)
 {
     return \Intervention\Image\ImageManager::cache($callback, $lifetime, $returnObj);
 }
开发者ID:tvad911,项目名称:biquyetmuasam.com,代码行数:14,代码来源:_ide_helper.php


注:本文中的Intervention\Image\ImageManager::cache方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。