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


PHP ImageManager::make方法代码示例

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


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

示例1: run

 /**
  * Perform image manipulations.
  * @param  string $source Source image binary data.
  * @param  array  $params The manipulation params.
  * @return string Manipulated image binary data.
  */
 public function run($source, array $params)
 {
     $image = $this->imageManager->make($source);
     foreach ($this->manipulators as $manipulator) {
         $manipulator->setParams($params);
         $image = $manipulator->run($image);
     }
     return $image->getEncoded();
 }
开发者ID:whismat,项目名称:glide,代码行数:15,代码来源:Api.php

示例2: processAvatar

 public function processAvatar($path)
 {
     $manager = $this->imgManager->make($path);
     $manager->orientate();
     $manager->fit($this->width);
     $name = $this->getFileName();
     $manager->save($this->getUploadPath($name));
     return $name;
 }
开发者ID:quentin-sommer,项目名称:WebTv,代码行数:9,代码来源:AvatarManager.php

示例3: store

 /**
  * Proccess image and write the text
  * Verify if the image needs to be downloaded
  * @param Request $request
  */
 public function store(Request $request)
 {
     $validator = Validator::make($request->all(), ['top' => 'max:' . Image::$maxCharCount, 'bottom' => 'required|max:' . Image::$maxCharCount, 'image' => 'required']);
     if ($validator->fails()) {
         $errors = '';
         foreach ($validator->errors()->all() as $error) {
             $errors .= "<br/>" . $error;
         }
         return response('Erro(s) de validação: ' . $errors, 500);
     }
     $image = $request->get('image');
     if (substr($image, -4) !== '.jpg') {
         $image .= '.jpg';
     }
     $imageObject = $this->manager->make(public_path() . '/images/' . $image);
     $token = Image::generateImageToken();
     $path = public_path() . '/images/' . $token . '.jpg';
     $imageObject = $this->write($imageObject, $request->get('bottom'));
     if ($request->get('top')) {
         $imageObject = $this->write($imageObject, $request->get('top'), 'top');
     }
     $result = $imageObject->save($path);
     if ($result) {
         return ['message' => 'Your image was saved successfully', 'token' => $token, 'image_src' => asset('images/' . $token . '.jpg')];
     }
 }
开发者ID:bsampaio,项目名称:Laravel-MemeServer,代码行数:31,代码来源:ImageController.php

示例4: resize

 public function resize($image)
 {
     $width = config('medias.max_size.width');
     $height = config('medias.max_size.height');
     // this orientate method needs to be called because sometimes
     // images uploaded came rotated, but need to be ajusted
     $img = $this->image->make(Storage::disk(config('medias.disk'))->get($image))->orientate();
     if ($img->width() <= $width && $img->height() <= $height) {
         return;
     }
     if ($img->width() > $width && $img->height() > $height) {
         $img->resize($width, $height, function ($constraint) {
             $constraint->aspectRatio();
         });
         Storage::disk(config('medias.disk'))->put($image, $img->stream());
         return;
     }
     if ($img->width() > $width) {
         $height = null;
     } elseif ($img->height() > $height) {
         $width = null;
     }
     $img->resize($width, $height, function ($constraint) {
         $constraint->aspectRatio();
     });
     Storage::disk(config('medias.disk'))->put($image, $img->stream());
 }
开发者ID:escapework,项目名称:laramedias,代码行数:27,代码来源:MediasResizeService.php

示例5: execute

 /**
  * {@inheritdoc}
  */
 public function execute(CommandParams $params, CommandExecutionContext $executionContext)
 {
     $fileName = $params->getFirstArgument();
     if (!$executionContext->hasFileInWorkingDirectory($fileName)) {
         throw new ExecutionFailedException("File '{$fileName}' does not exist.");
     }
     $img = $this->imageManager->make($executionContext->getPathOfFileInWorkingDirectory($fileName));
     if (!$params->hasSecondArgument()) {
         return $this->returnImage($img, $params);
     }
     list($width, $height) = $this->parseDimension($params->getSecondArgument());
     switch ($params->getThirdArgument()) {
         case 'stretch':
             $img->resize($width, $height);
             break;
         case 'fit':
             $img->fit($width, $height);
             break;
         case 'crop':
             $x = $this->filterIntOrNullArgument($params->getArgument(3));
             $y = $this->filterIntOrNullArgument($params->getArgument(4));
             $img->crop($width, $height, $x, $y);
             break;
         default:
             $img->resize($width, $height, function (Constraint $constraint) {
                 $constraint->aspectRatio();
             });
             break;
     }
     return $this->returnImage($img, $params);
 }
开发者ID:bigwhoop,项目名称:trumpet,代码行数:34,代码来源:ImageCommand.php

示例6: apply

 /**
  * {@inheritdoc}
  */
 public function apply($source, $options)
 {
     $options = $this->parseOptions($options);
     $image = $this->imageManager->make($source);
     $image->crop($options['width'], $options['height'], $options['x'], $options['y']);
     return $image->encode($image->mime())->getEncoded();
 }
开发者ID:svycka,项目名称:sv-images,代码行数:10,代码来源:Crop.php

示例7: run

 /**
  * Perform image manipulations.
  * @param  Request $request The request object.
  * @param  string  $source  Source image binary data.
  * @return string  Manipulated image binary data.
  */
 public function run(Request $request, $source)
 {
     $image = $this->imageManager->make($source);
     foreach ($this->manipulators as $manipulator) {
         $image = $manipulator->run($request, $image);
     }
     return $image->getEncoded();
 }
开发者ID:awebc,项目名称:web_xbf,代码行数:14,代码来源:Api.php

示例8: apply

 public function apply($source, $options)
 {
     $options = $this->parseOptions($options);
     $image = $this->imageManager->make($source);
     $image->fit($options['width'], $options['height'], function ($constraint) {
         $constraint->upsize();
     }, $options['position']);
     return $image->encode($image->mime())->getEncoded();
 }
开发者ID:svycka,项目名称:sv-images,代码行数:9,代码来源:Fit.php

示例9: makeImage

 /**
  * Make an image object from uploaded image
  *
  * @param string $image
  * @return \Intervention\Image\ImageManager|null
  */
 public function makeImage($image = '')
 {
     try {
         //Make image object and return
         return $this->image->make($image);
     } catch (Exception $e) {
         //Unexpected error
         return null;
     }
 }
开发者ID:AshniSukhoo,项目名称:UOM_connect,代码行数:16,代码来源:ImageHandler.php

示例10: saveFromString

 /**
  * Make and save image to filesystem from base64 encoded string.
  * 
  * @param  string  $string
  * @param  string  $path
  * 
  * @return Intervention\Image\Image
  */
 public function saveFromString($string, $path, $aspectRatio = false, $width = 320, $height = 200)
 {
     $string = preg_replace('/data:image\\/.+?;base64,/', '', $string);
     $img = imagecreatefromstring(base64_decode($string));
     if ($aspectRatio) {
         return $this->manager->make($img)->resize($width, $height, function ($contstraint) {
             $contstraint->aspectRatio();
         })->save($path);
     } else {
         return $this->manager->make($img)->resize($width, $height)->save($path);
     }
 }
开发者ID:shomimn,项目名称:builder,代码行数:20,代码来源:ImagesSaver.php

示例11: process

 /**
  * Run the named template against the image
  * @param  String $template          The template to run
  * @return Intervention\Image\Image  The processed image
  */
 public function process(TemplateInterface $template)
 {
     // Create a new intervention image object
     $image = $this->imageManager->make($this->image);
     $image = $template->process($image);
     // Encode the image if it hasn't
     // been encoded in the template.
     if (!$image->isEncoded()) {
         $image->encode();
     }
     return $image;
 }
开发者ID:diarmuidie,项目名称:imagerack-kernel,代码行数:17,代码来源:Process.php

示例12: validateFile

 private function validateFile(BackdropUploadStrategy $strategy, string $tmpFile)
 {
     if (filesize($tmpFile) > $strategy->getMaxFileSize()) {
         throw new TooBigFileException(sprintf('File is too big'));
     }
     $image = $this->imageManager->make($tmpFile);
     if ($image->getWidth() < $strategy->getMinImageWidth() || $image->getHeight() < $strategy->getMinImageHeight()) {
         throw new InvalidSizeException('Image is too small');
     }
     if ($image->getWidth() > $strategy->getMaxImageWidth() || $image->getHeight() > $strategy->getMaxImageHeight()) {
         throw new InvalidSizeException('Image is too big');
     }
 }
开发者ID:cass-project,项目名称:cass,代码行数:13,代码来源:BackdropService.php

示例13: 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

示例14: 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

示例15: process

 /**
  * Performs image processing
  *
  * @param ModelContract $model
  * @param array         $styleGuides
  * @param string        $path
  */
 public function process(ModelContract &$model, array $styleGuides, $path)
 {
     // load styles
     $styles = $this->getStyles($model, $styleGuides);
     $originalClosure = array_get($styles, 'original', null);
     // get Image object
     $image = $this->imageManager->make($model->getSourceFile()->getFileInfo());
     // apply original style
     $original = $this->processStyle($model, $image, 'original', $originalClosure);
     array_forget($styles, 'original');
     // apply styles
     foreach ($styles as $styleName => $closure) {
         $this->processStyle($model, $original, $styleName, $closure);
     }
 }
开发者ID:fraterblack,项目名称:attacher,代码行数:22,代码来源:AbstractProcessor.php


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