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


PHP Image::make方法代码示例

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


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

示例1: initaliseImageFactory

 /**
  * @param $original
  * @param $output
  * @return ImageFactory
  * @throws ImageGenerationException
  */
 private function initaliseImageFactory($original, $output)
 {
     if (file_exists($original)) {
         $path_parts = pathinfo($output);
         if (!is_dir($path_parts['dirname'])) {
             mkdir($path_parts['dirname'], 0777, true);
         }
         $imageFactory = ImageFactory::make($original);
         return $imageFactory;
     }
     throw new ImageGenerationException();
 }
开发者ID:coandacms,项目名称:coanda-core,代码行数:18,代码来源:DefaultImageHandler.php

示例2: saveImage

 /**
  * Save image in filesystem and db and return the image url.
  * 
  * @param  Upload  $image        
  * @param  boolean $useOriginalName
  * @return Image
  */
 public function saveImage(Upload $image, $useOriginalName = false)
 {
     $path = $this->makePath($image, $useOriginalName);
     $this->imagine->make($image->getRealPath())->save($path, 80);
     //save relative path in database instead of absolute so the site
     //won't get messed up if user changes domains.
     $relative = str_replace(public_path() . '/', '', $path);
     $this->model->firstOrNew(array('local' => $relative, 'type' => 'upload'))->save();
     return $this->byPath($relative);
 }
开发者ID:onlystar1991,项目名称:mtdb,代码行数:17,代码来源:MediaRepository.php

示例3: resizeImage

 /**
  * Resize an image
  *
  * @param string  $image
  * @param integer $width
  * @param integer $height
  *
  * @return Image
  */
 public function resizeImage($image, $width, $height)
 {
     $image = Image::make('public/' . $image);
     $image->resize($width, $height);
     $image->save();
     return $image;
 }
开发者ID:dvlpp,项目名称:warkham,代码行数:16,代码来源:AbstractWarkhamController.php

示例4: image

 /**
  * @param $path
  * @param $width
  * @param $height
  * @return Illuminate\Http\Response
  */
 public function image($width, $height, $path)
 {
     $file = storage_path($path);
     if (!file_exists($file)) {
         dd($file);
         App::abort(404);
     }
     return Image::make($file)->resize($width, $height);
 }
开发者ID:boyhagemann,项目名称:uploads,代码行数:15,代码来源:DownloadController.php

示例5: makeNew

 /**
  * Make a new image
  * @param MediaPath      $path
  * @param string      $filename
  * @param string null $thumbnail
  */
 private function makeNew(MediaPath $path, $filename, $thumbnail)
 {
     $image = $this->image->make($path->getUrl());
     foreach ($this->manager->find($thumbnail) as $manipulation => $options) {
         $image = $this->imageFactory->make($manipulation)->handle($image, $options);
     }
     $image = $image->stream(pathinfo($path, PATHINFO_EXTENSION));
     $this->writeImage($filename, $image);
 }
开发者ID:gmonte,项目名称:midig-cms,代码行数:15,代码来源:Imagy.php

示例6: makeNew

 /**
  * Make a new image
  * @param string      $path
  * @param string      $filename
  * @param string null $thumbnail
  */
 private function makeNew($path, $filename, $thumbnail)
 {
     $image = $this->image->make(public_path() . $path);
     foreach ($this->manager->find($thumbnail) as $manipulation => $options) {
         $image = $this->imageFactory->make($manipulation)->handle($image, $options);
     }
     $image = $image->encode(pathinfo($path, PATHINFO_EXTENSION));
     $this->writeImage($filename, $image);
 }
开发者ID:Houbsi,项目名称:Media,代码行数:15,代码来源:Imagy.php

示例7: postUpload

 public function postUpload()
 {
     if (Input::hasFile('upload')) {
         $destinationPath = public_path() . '/assets/ckeditor/upload/';
         $file = Input::file('upload');
         $fileName = Str::random(4) . '.' . $file->getClientOriginalExtension();
         Image::make($file->getRealPath())->save($destinationPath . 'original/' . $fileName)->grab('100', '100')->save($destinationPath . 'thumbnail/' . $fileName)->resize('280', '255', true)->save($destinationPath . 'resize/' . $fileName)->destroy();
         return 'success';
     }
     return App::abort(403, 'Unauthorized action.');
 }
开发者ID:gitda,项目名称:inventory2,代码行数:11,代码来源:FaqController.php

示例8: redactor__upload

 public function redactor__upload()
 {
     if (!Auth::getCurrentMember()) {
         exit("Invalid Request");
     }
     $path = Request::get('path');
     $is_image = Request::get('is_image');
     if (isset($path)) {
         $dir = Path::tidy(ltrim($path, '/') . '/');
         if (isset($_POST['subfolder'])) {
             $dir .= $_POST['subfolder'] . '/';
         }
         Folder::make($dir);
         $file_type = strtolower($_FILES['file']['type']);
         $file_info = pathinfo($_FILES['file']['name']);
         // pull out the filename bits
         $filename = $file_info['filename'];
         $ext = $file_info['extension'];
         // build filename
         $file = $dir . $filename . '.' . $ext;
         // check for dupes
         if (File::exists($file)) {
             $file = BASE_PATH . '/' . $dir . $filename . '-' . date('YmdHis') . '.' . $ext;
         }
         if (!Folder::isWritable($dir)) {
             Log::error('Upload failed. Directory "' . $dir . '" is not writable.', 'redactor');
             echo json_encode(array('error' => "Redactor: Upload directory not writable."));
             die;
         }
         if ($is_image && ($_FILES['file']['type'] == 'image/png' || $_FILES['file']['type'] == 'image/jpg' || $_FILES['file']['type'] == 'image/gif' || $_FILES['file']['type'] == 'image/jpeg')) {
             if (Request::get('resize', false)) {
                 $image = Image::make($_FILES['file']['tmp_name']);
                 $width = Request::get('width', null);
                 $height = Request::get('height', null);
                 $ratio = Request::get('ratio', true);
                 $upsize = Request::get('upsize', false);
                 $quality = Request::get('quality', '75');
                 $image->resize($width, $height, $ratio, $upsize)->save($file, $quality);
             } else {
                 move_uploaded_file($_FILES['file']['tmp_name'], $file);
             }
         } else {
             move_uploaded_file($_FILES['file']['tmp_name'], $file);
         }
         $return = array('filelink' => Path::toAsset($file));
         echo stripslashes(json_encode($return));
     } else {
         echo json_encode(array('error' => "Redactor: Upload directory not set."));
     }
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:50,代码来源:hooks.redactor.php

示例9: process

 /**
  * Process an uploaded file and store it in a web-accessible place.
  *
  * @param UploadedFile $file
  * @param $publishFilename
  */
 public function process(UploadedFile $file, $publishFilename)
 {
     // Temporary filename to work with.
     $fileName = uniqid() . '_' . $file->getClientOriginalName();
     $file->move($this->publishDir, $fileName);
     $speakerPhoto = Image::make($this->publishDir . '/' . $fileName);
     if ($speakerPhoto->height > $speakerPhoto->width) {
         $speakerPhoto->resize($this->size, null, true);
     } else {
         $speakerPhoto->resize(null, $this->size, true);
     }
     $speakerPhoto->crop($this->size, $this->size);
     if ($speakerPhoto->save($this->publishDir . '/' . $publishFilename)) {
         unlink($this->publishDir . '/' . $fileName);
     }
 }
开发者ID:AaronMuslim,项目名称:opencfp,代码行数:22,代码来源:ProfileImageProcessor.php

示例10: save

 /**
  * Function that saves a new company
  * @param                 array $data, string $logotype
  * @return                Orcamentos\Model\Company $company
  */
 public function save($data, $logotype)
 {
     $data = json_decode($data);
     if (!isset($data->name) || !isset($data->telephone)) {
         throw new Exception("Invalid Parameters", 1);
     }
     $company = $this->getCompany($data);
     $taxes = 6;
     if (isset($data->taxes)) {
         $taxes = $data->taxes;
     }
     if (!isset($data->responsable)) {
         $data->responsable = null;
     }
     $company->setName($data->name);
     $company->setResponsable($data->responsable);
     $company->setTaxes($taxes);
     if (isset($data->city)) {
         $company->setCity($data->city);
     }
     if (isset($data->site)) {
         $company->setSite($data->site);
     }
     if (isset($data->telephone)) {
         $company->setTelephone($data->telephone);
     }
     if (isset($data->email)) {
         $company->setEmail($data->email);
     }
     if (isset($logotype)) {
         $originalName = $logotype->getClientOriginalName();
         $components = explode('.', $originalName);
         $fileName = md5(time()) . '.' . end($components);
         $file = Image::make($logotype->getPathName())->grab(80);
         $file->save("public/img/logotypes/" . $fileName);
         $company->setLogotype($fileName);
     }
     try {
         $this->em->persist($company);
         $this->em->flush();
         return $company;
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
开发者ID:luiz158,项目名称:orcamentos,代码行数:50,代码来源:Company.php

示例11: save

 /**
  * Function that saves a new client
  * @param                 array $data, string $logotype
  * @return                Orcamentos\Model\Client $client
  */
 public function save($data, $logotype = null)
 {
     $data = json_decode($data);
     if (!isset($data->name) || !isset($data->corporateName) || !isset($data->responsable) || !isset($data->email) || !isset($data->companyId)) {
         throw new Exception("Parâmetros inválidos", 1);
     }
     $client = null;
     if (isset($data->id)) {
         $client = $this->em->getRepository("Orcamentos\\Model\\Client")->find($data->id);
     }
     if (!$client) {
         $client = new ClientModel();
     }
     $client->setName($data->name);
     $client->setCorporateName($data->corporateName);
     $client->setResponsable($data->responsable);
     $client->setEmail($data->email);
     if (isset($data->cnpj)) {
         $client->setCnpj($data->cnpj);
     }
     if (isset($data->telephone)) {
         $client->setTelephone($data->telephone);
     }
     $company = $this->em->getRepository('Orcamentos\\Model\\Company')->find($data->companyId);
     if (!isset($company)) {
         throw new Exception("Empresa não encontrada", 1);
     }
     $client->setCompany($company);
     if (isset($logotype)) {
         $originalName = $logotype->getClientOriginalName();
         $components = explode('.', $originalName);
         $fileName = md5(time()) . '.' . end($components);
         $file = Image::make($logotype->getPathName())->grab(80);
         $file->save("public/img/logotypes/" . $fileName);
         $client->setLogotype($fileName);
     }
     try {
         $this->em->persist($client);
         $this->em->flush();
         return $client;
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
开发者ID:luiz158,项目名称:orcamentos,代码行数:49,代码来源:Client.php

示例12: postImage

 /**
  * Post an image from the admin
  *
  * @return Json
  */
 public function postImage()
 {
     $file = Input::file('file');
     $imageDir = Config::get('wardrobe.image_dir', 'img');
     $destinationPath = public_path() . "/" . $imageDir . "/";
     $filename = $file->getClientOriginalName();
     $resizeEnabled = Config::get('wardrobe.image_resize.enabled', false);
     if ($resizeEnabled) {
         $resizeWidth = Config::get('wardrobe.image_resize.width');
         $resizeHeight = Config::get('wardrobe.image_resize.height');
         $image = Image::make($file->getRealPath())->resize($resizeWidth, $resizeHeight, true);
         $image->save($destinationPath . $filename);
     } else {
         $file->move($destinationPath, $filename);
     }
     if (File::exists($destinationPath . $filename)) {
         return Response::json(array('filename' => "/{$imageDir}/" . $filename, 'filelink' => "/{$imageDir}/" . $filename));
     }
     return Response::json(array('error' => 'Upload failed. Please ensure your public/' . $imageDir . ' directory is writable.'));
 }
开发者ID:sekouzed,项目名称:cabinet,代码行数:25,代码来源:DropzoneController.php

示例13: resize

 /**
  * Resize the image
  * @return boolean
  */
 private function resize()
 {
     $filename = $this->uploadObject->getAbsoluteSrc();
     $extension = $this->uploadObject->extension;
     // Does the original file exist? If not return false
     if (!File::exists($filename)) {
         return false;
     }
     // Check to see our directory for caching exists, if it doesn't recursively create it
     if (!File::isDirectory($this->getPath())) {
         File::makeDirectory($this->getPath(), 0777, true);
     }
     $img = Image::make($filename);
     if ($this->crop) {
         $img->fit($this->width, $this->height)->save($this->getPathFilename());
     } else {
         $img->resize($this->width, $this->height, true, true)->resizeCanvas($this->width, $this->height, null, false, 'ffffff')->save($this->getPathFilename());
     }
     return true;
 }
开发者ID:sharenjoy,项目名称:cmsharenjoy,代码行数:24,代码来源:ImgHelper.php

示例14: process

 /**
  * Process an uploaded file and store it in a web-accessible place.
  *
  * @param UploadedFile $file
  * @param string       $publishFilename
  *
  * @throws \Exception
  */
 public function process(UploadedFile $file, $publishFilename)
 {
     // Temporary filename to work with.
     $tempFilename = $this->generator->generate(40);
     try {
         $file->move($this->publishDir, $tempFilename);
         $speakerPhoto = Image::make($this->publishDir . '/' . $tempFilename);
         if ($speakerPhoto->height > $speakerPhoto->width) {
             $speakerPhoto->resize($this->size, null, true);
         } else {
             $speakerPhoto->resize(null, $this->size, true);
         }
         $speakerPhoto->crop($this->size, $this->size);
         if ($speakerPhoto->save($this->publishDir . '/' . $publishFilename)) {
             unlink($this->publishDir . '/' . $tempFilename);
         }
     } catch (\Exception $e) {
         unlink($this->publishDir . '/' . $tempFilename);
         throw $e;
     }
 }
开发者ID:cloudtracer,项目名称:opencfp,代码行数:29,代码来源:ProfileImageProcessor.php

示例15: postImage

 /**
  * Post an image from the admin
  *
  * @return Json
  */
 public function postImage()
 {
     $file = Input::file('file');
     $imageDir = Config::get('core::wardrobe.image_dir');
     $destinationPath = public_path() . "/{$imageDir}/";
     $filename = $file->getClientOriginalName();
     $resizeEnabled = Config::get('core::wardrobe.image_resize.enabled');
     if ($resizeEnabled) {
         $resizeWidth = Config::get('core::wardrobe.image_resize.width');
         $resizeHeight = Config::get('core::wardrobe.image_resize.height');
         $image = Image::make($file->getRealPath())->resize($resizeWidth, $resizeHeight, true);
         $image->save($destinationPath . $filename);
     } else {
         $file->move($destinationPath, $filename);
     }
     if (File::exists($destinationPath . $filename)) {
         // @note - Using the absolute url so it loads images when ran in sub folder
         // this will make exporting less portable and may need to re-address at a later point.
         return Response::json(array('filename' => url("/{$imageDir}/" . $filename)));
     }
     return Response::json(array('error' => 'Upload failed. Please ensure your public/img directory is writable.'));
 }
开发者ID:sekouzed,项目名称:core,代码行数:27,代码来源:DropzoneController.php


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