當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。