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


PHP Image::make方法代码示例

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


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

示例1: setImagenAttribute

 public function setImagenAttribute($imagen)
 {
     if (!empty($imagen)) {
         $this->attributes['imagen'] = \Carbon::now()->second . $imagen->getClientOriginalName();
         $filename = \Carbon::now()->second . $imagen->getClientOriginalName();
         \Storage::disk('local')->put($filename, \File::get($imagen));
         $thumb = \Image::make(\File::get($imagen));
         $ruta = public_path() . '/uploads/noticias/thumbs/';
         $thumb->resize(160, 100);
         $thumb->save($ruta . 'thumb_' . $filename);
     }
 }
开发者ID:byrogr,项目名称:admin_mundo_tuerca,代码行数:12,代码来源:Noticia.php

示例2: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $photo = Request::file('image');
     $notes = Request::input('notes');
     $image = new App\Image();
     $image->make($photo, $notes);
     $image->name = $image->getName();
     $image->latitude = $image->getLatitude();
     $image->longitude = $image->getLongitude();
     $image->date = $image->getDate();
     $image->time = $image->getTime();
     $image->notes = $notes;
     $image->created_at = Carbon::now();
     $image->updated_at = Carbon::now();
     $image->save();
     return redirect()->action('AlleyController@create');
 }
开发者ID:ravencole,项目名称:GDDYN--PORTFOLIO,代码行数:23,代码来源:AlleyController.php

示例3: setProfileImage

 public function setProfileImage($image)
 {
     $img = \Image::make($image);
     // resize image
     $img->fit(600, 600);
     // save image
     $path = 'public/assets/images/profiles/' . $user->id . $user->name . '.jpg';
     $img->save($path);
     return $path;
 }
开发者ID:atindermann08,项目名称:readr,代码行数:10,代码来源:User.php

示例4: resizeImage

 public function resizeImage($filename, $maxWidth = 1024, $quality = 90)
 {
     $img = \Image::make($filename);
     if ($img->width() > $maxWidth) {
         $img->resize($maxWidth, null, function ($constraint) {
             $constraint->aspectRatio();
         });
         $img->save($filename, $quality);
     }
 }
开发者ID:dookda,项目名称:mapigniter2,代码行数:10,代码来源:Content.php

示例5: storeCMPicture

 public static function storeCMPicture($img_url)
 {
     // post save
     $post = \App\Post::create(array('user_id' => \Auth::user()->id, 'content' => ''));
     $post->postGroups()->attach(\Auth::user()->postGroups()->first()->id);
     // photo save
     $types = array('_s.', '_m.', '_l.');
     $sizes = array(100, 300, 600);
     $original_file_name = $img_url;
     $file_ext = 'jpg';
     $target_path = base_path() . '/public/imgs/';
     $hashSeed = "post" . $post->id . $original_file_name;
     while (1) {
         $file_name = \Func::getHashedValue($hashSeed);
         if (!\File::exists($target_path . \Func::getImgPath($file_name))) {
             break;
         }
         $hashSeed .= rand();
     }
     $target_path .= \Func::getImgPath($file_name) . '/';
     if (!\File::exists($target_path)) {
         \File::makeDirectory($target_path, 0775, true);
     }
     foreach ($types as $key => $type) {
         $new_name = $file_name . $type . $file_ext;
         $img = \Image::make($img_url);
         $img->resize($sizes[$key], null, function ($constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         })->save($target_path . $new_name);
         $img->destroy();
     }
     \App\Photo::create(array('post_id' => $post->id, 'sequence' => 1, 'img_path' => $file_name . '.' . $file_ext));
 }
开发者ID:bbig979,项目名称:shoppyst,代码行数:34,代码来源:Post.php

示例6: makeThumbnail

 protected function makeThumbnail()
 {
     Image::make($this->filePath())->fit(200)->save($this->thumbnailPath());
 }
开发者ID:qnk,项目名称:laravel-projectFlyer,代码行数:4,代码来源:Photo.php

示例7: uploadFiles

 public function uploadFiles($idFr, $img_profile)
 {
     $fileSystem = new Filesystem();
     $countProfileImg = count($img_profile);
     //creo la extructura de carpetas para el doctor
     //for profile_img
     if (!empty($img_profile)) {
         $destinationPath = public_path() . "/upload/flores_regalos/{$idFr}/";
         $file = str_replace('data:image/png;base64,', '', $img_profile);
         $img = str_replace(' ', '+', $file);
         $data = base64_decode($img);
         $filename = date('ymdhis') . '_croppedImage' . ".png";
         $file = $destinationPath . $filename;
         $success = file_put_contents($file, $data);
         // THEN RESIZE IT
         $returnData = "upload/flores_regalos/{$idFr}/" . $filename;
         $image = Image::make(file_get_contents(URL::asset($returnData)));
         $image = $image->resize(300, 300)->save($destinationPath . $filename);
         if (!$success) {
             return false;
         }
     } else {
         $filename = "";
     }
     return array('img_profile_name' => $filename);
 }
开发者ID:rldiezn,项目名称:platzy,代码行数:26,代码来源:floresRegalosModel.php

示例8: createFromInput

 /**
  * Create record based on input and save untouched file in storage/images
  * @param UploadedFile $file
  * @return static
  * @throws Exception
  */
 public static function createFromInput(UploadedFile $file)
 {
     if (!in_array($file->getMimeType(), static::$allowedMimes)) {
         throw new Exception("Invalid mime type");
     }
     $newFileName = static::count() . md5(str_random());
     $newExtension = $file->guessExtension();
     $img = ImageLib::make($file)->save(storage_path('images') . DIRECTORY_SEPARATOR . $newFileName . '.' . $newExtension);
     try {
         $dbImage = new Image(['original' => $file->getClientOriginalName(), 'hash' => $newFileName, 'extension' => $newExtension, 'width' => $img->width(), 'height' => $img->height()]);
         $dbImage->save();
     } catch (\Exception $ex) {
         dd($ex);
     }
     return $dbImage;
 }
开发者ID:Aliqhuart,项目名称:puzzle-wp,代码行数:22,代码来源:Image.php


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