• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Facades\Image类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: postAdd

 public function postAdd(Request $request, Agent $agent)
 {
     $data = $request->all();
     $validation = Validator::make($data, Poster::getValidationRules());
     if ($validation->fails()) {
         return view('message', ['OKs' => [], 'errors' => $validation->errors()->all()]);
     }
     $original_image_dir = 'images/original/';
     $small_image_dir = 'images/small/';
     $original_image_name = $original_image_dir . "no_image.jpg";
     $small_image_name = $small_image_dir . "no_image_sml.jpg";
     if ($request->hasFile('image')) {
         $time = time();
         $original_image_name = $original_image_dir . $time . '.jpg';
         $small_image_name = $small_image_dir . $time . '.jpg';
         Image::make(Input::file('image'))->save($original_image_name)->resize(200, null, function ($constraint) {
             $constraint->aspectRatio();
         })->save($small_image_name);
     } else {
     }
     $data['image'] = $original_image_name;
     $data['image_sml'] = $small_image_name;
     $data['author_ip'] = $request->getClientIp();
     $data['author_browser'] = $agent->browser();
     $data['author_country'] = "Ukraine";
     Poster::create($data);
     return view('message', array('OKs' => ['Poster created'], 'errors' => ['']));
 }
开发者ID:antoha805,项目名称:PostersBase,代码行数:28,代码来源:PosterController.php


示例2: findByUserNameOrCreate

 public function findByUserNameOrCreate($userData)
 {
     $user = User::where('social_id', '=', $userData->id)->first();
     if (!$user) {
         $user = new User();
         $user->social_id = $userData->id;
         $user->email = $userData->email;
         $user->first_name = $userData->user['first_name'];
         $user->last_name = $userData->user['last_name'];
         $name = str_random(32);
         while (!User::where('avatar', '=', $name . '.jpg')->get()->isEmpty()) {
             $name = str_random(32);
         }
         $filename = $name . '.' . 'jpg';
         Image::make($userData->avatar_original)->fit(1024, 1024)->save(public_path() . '/avatars_large/' . $filename);
         Image::make(public_path() . '/avatars_large/' . $filename)->resize(200, 200)->save(public_path() . '/avatars/' . $filename);
         $user->avatar = $filename;
         $user->gender = $userData->user['gender'];
         $user->verified = $userData->user['verified'];
         $user->save();
         \Session::put('auth_photo', $filename);
     } else {
         $this->checkIfUserNeedsUpdating($userData, $user);
         \Session::put('auth_photo', $user->avatar);
     }
     return $user;
 }
开发者ID:charlieboo,项目名称:creatrip,代码行数:27,代码来源:UserRepository.php


示例3: update

 public function update(Request $request)
 {
     $user = $request->auth;
     $id = $request->route('id');
     $uniq = md5(uniqid(time(), true));
     if ($request->hasFile('image')) {
         $types = array('115x69', '285x170', '617x324');
         // Width and height for thumb and resiged
         $sizes = array(array('115', '69'), array('285', '170'), array('617', '324'));
         $targetPath = 'img/media/';
         $image = $request->file('image');
         $ext = $image->getClientOriginalExtension();
         foreach ($types as $key => $type) {
             Image::make($image)->fit($sizes[$key][0], $sizes[$key][1])->save($targetPath . $type . "/" . $uniq . '.' . $ext);
         }
     }
     $post = PostModel::findOrFail($id);
     $post->pos_name = ucfirst($request->input('pos_name'));
     $post->pos_slug = $request->input('pos_slug');
     if ($request->hasFile('image')) {
         $post->pos_image = $uniq . '.' . $ext;
     }
     $post->pos_sum = $request->input('pos_sum');
     $post->pos_desc = $request->input('pos_desc');
     $post->pos_status_cd = "ACT";
     $post->cat_id = $request->input('cat_id');
     $post->updated_by = $user->usr_id;
     if (!$post->save()) {
         return "Error";
     }
     return Redirect::route('postHome');
 }
开发者ID:sochea09,项目名称:laravel-blog,代码行数:32,代码来源:Post.php


示例4: putEdit

 public function putEdit(Request $request)
 {
     if (!ACL::hasPermission('awards', 'edit')) {
         return redirect(route('awards'))->withErrors(['Você não pode editar os prêmios.']);
     }
     $this->validate($request, ['title' => 'required|max:45', 'warning' => 'required', 'image' => 'image|mimes:jpeg,bmp,gif,png'], ['title.required' => 'Informe o título do prêmio', 'title.max' => 'O título do prêmio não pode passar de :max caracteres', 'warning.required' => 'Informe o aviso sobre o prêmio', 'image.image' => 'Envie um formato de imagem válida', 'image.mimes' => 'Formato suportado: .png com fundo transparente']);
     $award = Awards::find($request->awardsId);
     $award->title = $request->title;
     $award->warning = $request->warning;
     if ($request->image) {
         //DELETE OLD IMAGE
         if ($request->currentImage != "") {
             if (File::exists($this->folder . $request->currentImage)) {
                 File::delete($this->folder . $request->currentImage);
             }
         }
         $extension = $request->image->getClientOriginalExtension();
         $nameImage = Carbon::now()->format('YmdHis') . "." . $extension;
         Image::make($request->file('image'))->resize($this->imageWidth, $this->imageHeight)->save($this->folder . $nameImage);
         $award->image = $nameImage;
     }
     $award->save();
     $success = "Prêmio editado com sucesso";
     return redirect(route('awards'))->with(compact('success'));
 }
开发者ID:brunomartins-com,项目名称:hipodermeomega,代码行数:25,代码来源:AwardsController.php


示例5: uploadTextarea

 public static function uploadTextarea($texto, $tipo_midia)
 {
     $nomeTipo = TipoMidia::findOrFail($tipo_midia)->descricao;
     // gravando imagem do corpo da noticia
     $dom = new \DOMDocument();
     $dom->loadHtml($texto, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
     $images = $dom->getElementsByTagName('img');
     // foreach <img> in the submited message
     foreach ($images as $img) {
         $src = $img->getAttribute('src');
         // if the img source is 'data-url'
         if (preg_match('/data:image/', $src)) {
             // get the mimetype
             preg_match('/data:image\\/(?<mime>.*?)\\;/', $src, $groups);
             $mimetype = $groups['mime'];
             // Generating a random filename
             $filename = md5(uniqid());
             $filepath = "uploads/" . $nomeTipo . "/" . $filename . '.' . $mimetype;
             // @see http://image.intervention.io/api/
             $image = Image::make($src)->encode($mimetype, 100)->save(public_path($filepath));
             $new_src = asset($filepath);
             $img->removeAttribute('src');
             $img->setAttribute('src', $new_src);
         }
     }
     return $dom->saveHTML();
 }
开发者ID:safaricco,项目名称:admfw,代码行数:27,代码来源:Midia.php


示例6: store

 /**
  * Update the users profile
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $user = User::find($request->input('user_id'));
     $user->name = $request->input('name');
     $user->email = $request->input('email');
     $user->username = $request->input('username');
     if ($request->input('password') != '') {
         $user->password = bcrypt($request->input('password'));
     }
     $user->update();
     $company = Company::where('user_id', $request->input('user_id'))->first();
     $company->name = $request->input('company_name');
     $company->description = $request->input('company_description');
     $company->phone = $request->input('company_phone');
     $company->email = $request->input('company_email');
     $company->address1 = $request->input('company_address');
     $company->address2 = $request->input('company_address2');
     $company->city = $request->input('company_city');
     $company->postcode = $request->input('company_postcode');
     if ($request->hasFile('logo')) {
         $file = $request->file('logo');
         $name = Str::random(25) . '.' . $file->getClientOriginalExtension();
         $image = Image::make($request->file('logo')->getRealPath())->resize(210, 113, function ($constraint) {
             $constraint->aspectRatio();
         });
         $image->save(public_path() . '/uploads/' . $name);
         $company->logo = $name;
     }
     $company->update();
     flash()->success('Success', 'Profile updated');
     return back();
 }
开发者ID:wyrover,项目名称:applications,代码行数:39,代码来源:ProfileController.php


示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store($image, $type, $primary_id, $current_link)
 {
     $image_link = array_key_exists($type, Input::all()) ? Input::file($type) != '' ? '/allgifted-images/' . $type . '/' . $primary_id . '.' . $image->getClientOriginalExtension() : $current_link : $current_link;
     array_key_exists($type, Input::all()) ? File::exists(public_path($image_link)) ? File::delete(public_path($image_link)) : null : null;
     $image ? Image::make($image)->fit(500, 300)->save(public_path($image_link)) : null;
     return $image_link;
 }
开发者ID:2ppaamm,项目名称:mathImageall,代码行数:13,代码来源:ImageController.php


示例8: makeImage

 protected function makeImage($file, $height, $width, $randomFilename, $thumbnail = null)
 {
     $md5 = md5_file($file->getRealPath());
     $img = Image::make($file)->fit($height, $width);
     $path = 'images/';
     if ($thumbnail != null) {
         $path = 'images/thumb/';
     }
     $image = Images::where('md5_hash', $md5)->first();
     if ($image === null or $image->thumbnail_file == null) {
         Clockwork::info('Storing on Filesystem');
         $img->save(storage_path() . '/app/' . $path . $randomFilename . '.png', 90);
     }
     if ($image === null and $thumbnail === null) {
         Clockwork::info('New Image');
         $image = new Images();
         $image->user_id = Auth::user()->id;
         $image->filename = $file->getClientOriginalName();
         $image->file = $randomFilename . '.png';
         $image->height = $height;
         $image->width = $width;
         $image->md5_hash = $md5;
     } elseif ($thumbnail != null and $image->thumbnail_file == null) {
         Clockwork::info('Thumbnail Updated');
         $image->thumbnail_file = $randomFilename . '.png';
     }
     $image->save();
     return $image;
 }
开发者ID:becast,项目名称:GameReviewSite,代码行数:29,代码来源:ImageController.php


示例9: putEdit

 public function putEdit(Request $request)
 {
     if (!ACL::hasPermission('winners2014', 'edit')) {
         return redirect(route('winners2014'))->withErrors(['Você não pode editar os ganhadores de 2014.']);
     }
     $this->validate($request, ['category' => 'required', 'position' => 'required', 'name' => 'required|max:50', 'city' => 'required|max:45', 'state' => 'required|max:2|min:2', 'quantityVotes' => 'required|numeric', 'image' => 'image|mimes:jpeg,bmp,gif,png'], ['category.required' => 'Escolha a categoria', 'position.required' => 'Escolha a posição', 'name.required' => 'Informe o nome do ganhador', 'name.max' => 'O nome do ganhador não pode passar de :max caracteres', 'city.required' => 'Informe o nome da cidade do ganhador', 'city.max' => 'O nome da cidade não pode passar de :max caracteres', 'state.required' => 'Informe o Estado do ganhador', 'state.max' => 'O UF do Estado deve ter apenas :max caracteres', 'state.min' => 'O UF do Estado deve ter apenas :min caracteres', 'quantityVotes.required' => 'Informe a quantidade de votos', 'quantityVotes.numeric' => 'Somente números são aceitos', 'image.image' => 'Envie um formato de imagem válida', 'image.mimes' => 'Formatos suportados: .jpg, .gif, .bmp e .png']);
     $winner = WinnersLastYear::find($request->winnersLastYearId);
     $winner->category = $request->category;
     $winner->position = $request->position;
     $winner->name = $request->name;
     $winner->city = $request->city;
     $winner->state = $request->state;
     $winner->quantityVotes = $request->quantityVotes;
     if ($request->photo) {
         //DELETE OLD PHOTO
         if ($request->currentPhoto != "") {
             if (File::exists($this->folder . $request->currentPhoto)) {
                 File::delete($this->folder . $request->currentPhoto);
             }
         }
         $extension = $request->photo->getClientOriginalExtension();
         $namePhoto = Carbon::now()->format('YmdHis') . "." . $extension;
         $img = Image::make($request->file('photo'));
         if ($request->photoCropAreaW > 0 or $request->photoCropAreaH > 0 or $request->photoPositionX or $request->photoPositionY) {
             $img->crop($request->photoCropAreaW, $request->photoCropAreaH, $request->photoPositionX, $request->photoPositionY);
         }
         $img->resize($this->photoWidth, $this->photoHeight)->save($this->folder . $namePhoto);
         $winner->photo = $namePhoto;
     }
     $winner->save();
     $success = "Ganhador editado com sucesso";
     return redirect(route('winners2014'))->with(compact('success'));
 }
开发者ID:brunomartins-com,项目名称:hipodermeomega,代码行数:33,代码来源:Winners2014Controller.php


示例10: create

 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     //Dodavanje slika
     if (isset($data['foto'])) {
         $image = $data['foto'];
         $image_name = $image->getClientOriginalName();
         $image->move('img/korisnici', $image_name);
         $image_final = 'img/korisnici/' . $image_name;
         $int_image = Image::make($image_final);
         $int_image->resize(300, null, function ($promenljiva) {
             $promenljiva->aspectRatio();
         });
         $int_image->save($image_final);
     } else {
         $image_final = 'img/default/slika-korisnika.jpg';
     }
     //Dodavanje novog grada
     if ($data['novi_grad']) {
         $pomocna = DB::table('grad')->where('grad.naziv', '=', $data['novi_grad'])->first();
         if ($pomocna) {
             $data['grad_id'] = $pomocna->id;
         } else {
             Grad::create(['naziv' => $data['novi_grad']]);
             $pomocna = DB::table('grad')->where('grad.naziv', '=', $data['novi_grad'])->first();
             $data['grad_id'] = $pomocna->id;
         }
     }
     //Dodavanje novog korisnika
     $aktivacioni_kod = str_random(30);
     $podaci = array('aktivacioni_kod' => $aktivacioni_kod);
     Mail::send('emails.aktiviranje_naloga', $podaci, function ($message) {
         $message->to(Input::get('email'), Input::get('username'))->subject('Активирање налога');
     });
     return User::create(['prezime' => $data['prezime'], 'ime' => $data['ime'], 'password' => bcrypt($data['password']), 'username' => $data['username'], 'email' => $data['email'], 'adresa' => $data['adresa'], 'grad_id' => $data['grad_id'], 'telefon' => $data['telefon'], 'opis' => $data['bio'], 'foto' => $image_final, 'aktivacioni_kod' => $aktivacioni_kod, 'token' => $data['_token']]);
 }
开发者ID:duxor,项目名称:GUSLE,代码行数:41,代码来源:AuthController.php


示例11: __construct

 /**
  * Create a new UploadImageAbstract instance
  *
  * @param \Symfony\Component\HttpFoundation\File\UploadedFile $file
  */
 public function __construct($file)
 {
     $this->file = $file;
     $this->hash = mt_rand(1000000000, 4294967295);
     $this->image = InterventionImage::make($this->file);
     $this->uploaded_at = Carbon::now();
 }
开发者ID:BePsvPT,项目名称:CCU,代码行数:12,代码来源:ImageAbstract.php


示例12: create

 public function create(Offer $offer, Request $request)
 {
     if ($request->user()->cannot('edit-offer', [$offer])) {
         abort(403);
     }
     $this->validate($request, ['title' => 'required', 'image' => 'required|image', 'expired_at' => 'required']);
     $user = Auth::user();
     // wildcard is needed
     $offer = $user->offers()->where('id', $offer->id)->where('status', 1)->valid()->firstOrFail();
     $input = $request->all();
     $data = $request->input('cropper_json');
     $data = json_decode(stripslashes($data));
     $image = $input['image'];
     $imageName = $user->id . str_random(20) . "." . $image->getClientOriginalExtension();
     $image->move(public_path() . '/img/files/' . $user->id, $imageName);
     $src = public_path() . '/img/files/' . $user->id . '/' . $imageName;
     $img = Image::make($src);
     $img->rotate($data->rotate);
     $img->crop(intval($data->width), intval($data->height), intval($data->x), intval($data->y));
     $img->resize(851, 360);
     $img->save($src, 90);
     $service = $user->coupon_gallery()->create(['offer_id' => $offer->id, 'title' => $input['title'], 'description' => $input['description'], 'expired_at' => $input['expired_at'], 'image' => $user->id . "/" . $imageName]);
     Flash::success(trans('messages.offerCreated'));
     $user->usage->add(filesize(public_path() . '/img/files/' . $user->id . '/' . $imageName) / (1024 * 1024));
     // storage add
     return redirect()->back();
 }
开发者ID:emadmrz,项目名称:Hawk,代码行数:27,代码来源:OfferController.php


示例13: show

 /**
  * Display the specified resource.
  *
  * @param $image_slug
  * @param int $width
  * @return Response
  */
 public function show($image_slug, $width = 500)
 {
     $currentUser = $this->getUser();
     //$size = (Input::get('size')? (is_numeric(Input::get('size'))? Input::get('size') : 500) : 500);//TODO: Extract this to global config
     $comicImage = ComicImage::where('image_slug', '=', $image_slug)->first();
     if (!$comicImage) {
         return $this->respondNotFound(['title' => 'Image Not Found', 'detail' => 'Image Not Found', 'status' => 404, 'code' => '']);
     }
     $userCbaIds = $currentUser->comics()->lists('comic_book_archive_id')->all();
     $comicCbaIds = $comicImage->comicBookArchives()->lists('comic_book_archive_id')->all();
     foreach ($comicCbaIds as $comicCbaId) {
         if (!in_array($comicCbaId, $userCbaIds)) {
             return $this->respondNotFound(['title' => 'Image Not Found', 'detail' => 'Image Not Found', 'status' => 404, 'code' => '']);
         }
     }
     $img = Image::make($comicImage->image_url);
     $imgCache = Image::cache(function ($image) use($img, $width) {
         $image->make($img)->interlace()->resize(null, $width, function ($constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         });
     }, 60, true);
     //dd($imgCache->response());
     return $imgCache->response();
 }
开发者ID:kidshenlong,项目名称:comic-cloud-lumen,代码行数:32,代码来源:ComicImagesController.php


示例14: uploadPhoto

 public function uploadPhoto($userId, $filePath, $newImage = false)
 {
     $tmpFilePath = storage_path('app') . '/' . $userId . '.png';
     $tmpFilePathThumb = storage_path('app') . '/' . $userId . '-thumb.png';
     try {
         $this->correctImageRotation($filePath);
     } catch (\Exception $e) {
         \Log::error($e);
         //Continue on - this isnt that important
     }
     //Generate the thumbnail and larger image
     Image::make($filePath)->fit(500)->save($tmpFilePath);
     Image::make($filePath)->fit(200)->save($tmpFilePathThumb);
     if ($newImage) {
         $newFilename = \App::environment() . '/user-photo/' . md5($userId) . '-new.png';
         $newThumbFilename = \App::environment() . '/user-photo/' . md5($userId) . '-thumb-new.png';
     } else {
         $newFilename = \App::environment() . '/user-photo/' . md5($userId) . '.png';
         $newThumbFilename = \App::environment() . '/user-photo/' . md5($userId) . '-thumb.png';
     }
     Storage::put($newFilename, file_get_contents($tmpFilePath), 'public');
     Storage::put($newThumbFilename, file_get_contents($tmpFilePathThumb), 'public');
     \File::delete($tmpFilePath);
     \File::delete($tmpFilePathThumb);
 }
开发者ID:adamstrawson,项目名称:BBMembershipSystem,代码行数:25,代码来源:UserImage.php


示例15: __toString

 public function __toString()
 {
     if ($this->isSkip) {
         return '';
     }
     $methodsHash = md5(serialize($this->methods));
     $hash = md5($this->fileHash . $methodsHash);
     $source = 'storage/cropp/' . $hash . $this->extension;
     if (is_readable(public_path($source))) {
         return $source;
     }
     $image = Image::make($this->source);
     foreach ($this->methods as $method) {
         call_user_func_array(array($image, $method['name']), $method['arguments']);
     }
     $res = $image->save(public_path($source));
     if (!$res) {
         throw new RuntimeException('Do you have writeable [public/storage/cropp/] directory?');
     }
     if (\Config::get('jarboe::cropp.is_optimize')) {
         $optimizer = new \Extlib\ImageOptimizer(array(\Extlib\ImageOptimizer::OPTIMIZER_OPTIPNG => \Config::get('jarboe::cropp.binaries.optipng'), \Extlib\ImageOptimizer::OPTIMIZER_JPEGOPTIM => \Config::get('jarboe::cropp.binaries.jpegoptim'), \Extlib\ImageOptimizer::OPTIMIZER_GIFSICLE => \Config::get('jarboe::cropp.binaries.gifsicle')));
         $optimizer->optimize(public_path($source));
     }
     return $source;
 }
开发者ID:OlesKashchenko,项目名称:Jarboe,代码行数:25,代码来源:Cropp.php


示例16: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     // register
     // Log::info('register pochetok');
     // Log::info($request);
     // Log::info($request->get('first_name')); // ti dava samo value
     // Log::info($request->only('first_name')); // ti dava cela niza so key value
     $user = new User();
     $user->first_name = $request->get('first_name');
     $user->last_name = $request->get('last_name');
     $user->email = $request->get('email');
     $user->password = bcrypt($request->get('password'));
     $user->skype_id = $request->get('skype_id');
     $user->contact_number = $request->get('contact_number');
     if (Input::hasFile('profile_picture')) {
         Log::info('has file');
         $file = Input::file('profile_picture');
         $extension = pathinfo($file->getClientOriginalName(), PATHINFO_EXTENSION);
         $filename = base64_encode($user->email) . "." . $extension;
         $file->move('uploads/profile_pictures', $filename);
         // vistinskata profilna slika
         $image = Image::make('uploads/profile_pictures/' . $filename);
         $image->fit(160, 160);
         $image->save('uploads/profile_pictures/thumbnails/' . $filename);
         // update vo folder
         $user->profile_picture = $filename;
     }
     // proverka za email dali vekje ima (verojatno Eloquent sam kje vrati) imame staveno unique :)
     $user->save();
 }
开发者ID:1993Dajana,项目名称:pet-care,代码行数:36,代码来源:RegisterController.php


示例17: get

 public function get($source, $options)
 {
     if (!$source) {
         return;
     }
     $this->setOptions($options);
     $source = "/" . ltrim($source, "/");
     $sourceArray = pathinfo($source);
     //create variables $dirname , $basename, $extension, $filename
     extract($sourceArray);
     $this->nameFile = $filename . "_" . $this->quality . "." . $extension;
     $this->pathFolder = $dirname . "/" . $this->size;
     $this->picturePath = $this->pathFolder . "/" . $this->nameFile;
     if (self::checkExistPicture()) {
         return $this->picturePath;
     }
     try {
         $img = Image::make(public_path() . $source);
         $this->createRatioImg($img, $options);
         @mkdir(public_path() . $this->pathFolder);
         $pathSmallImg = public_path() . "/" . $this->picturePath;
         $img->save($pathSmallImg, $this->quality);
         OptmizationImg::run($this->picturePath);
         return $this->picturePath;
     } catch (\Exception $e) {
         return $e->getMessage();
     }
 }
开发者ID:arturishe21,项目名称:buider,代码行数:28,代码来源:Img.php


示例18: preview

 public function preview($mode = 'auto', $size = null, $name = null)
 {
     if (!is_null($mode) && !is_null($size) && !is_null($name)) {
         if (preg_match('/http\\:\\/\\//', $name) || !preg_match('/http\\:\\/\\//', $name) && \File::exists(public_path() . '/' . $name)) {
             $file = pathinfo($name)['basename'];
             $folder = $this->generateFolder($mode, $size, $name);
             $fullname = public_path() . '/' . $folder . $file;
             $size = explode('x', $size);
             $width = isset($size[0]) ? $size[0] : null;
             $height = isset($size[1]) ? $size[1] : null;
             if ($mode == 'crop') {
                 $image = Image::make($name)->fit($width, $height);
             } else {
                 $image = Image::make($name)->resize($width, $height, function ($constraint) {
                     $constraint->aspectRatio();
                     $constraint->upsize();
                 });
             }
             $image->save($fullname, 100);
             $info = getimagesize($fullname);
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
开发者ID:azatkama,项目名称:adminka,代码行数:28,代码来源:PreviewController.php


示例19: getBrazzifiedImage

 private function getBrazzifiedImage($url, $logo_loc)
 {
     $valid_logo_locations = ['top-left', 'top', 'top-right', 'left', 'center', 'right', 'bottom-left', 'bottom', 'bottom-right'];
     try {
         $img = Image::make($url);
     } catch (\Exception $e) {
         return ['error' => 'Image or URL is not valid.'];
     }
     if (!in_array($logo_loc, $valid_logo_locations)) {
         return ['error' => 'Not a valid logo location.'];
     }
     $img->insert(base_path() . '/resources/images/brazzers-logo.png', $logo_loc, 10, 10);
     $finished_image = $img->encode('png');
     $image_hash = hash('sha256', $finished_image . $logo_loc);
     $existing_image = ImageModel::where('hash', $image_hash)->first();
     if ($existing_image) {
         $imgur_id = $existing_image->image_host_id;
     } else {
         $client = new Client(['base_uri' => 'https://api.imgur.com', 'timeout' => 10, 'headers' => ['Authorization' => 'Client-ID ' . env('IMGUR_CLIENT_ID')]]);
         $response = $client->request('POST', '3/image', ['form_params' => ['image' => base64_encode($finished_image), 'type' => 'base64', 'description' => 'Image generated by http://brazzify.me']]);
         if ($response->getStatusCode() != 200) {
             return ['error' => 'Error uploading image to imgur.'];
         }
         $imgur_response = json_decode($response->getBody()->getContents());
         $imgur_id = $imgur_response->data->id;
         $image_model = new ImageModel();
         $image_model->hash = $image_hash;
         $image_model->image_host = 1;
         $image_model->image_host_id = $imgur_id;
         $image_model->save();
     }
     return ['imgur_id' => $imgur_id];
 }
开发者ID:sethryder,项目名称:brazzify,代码行数:33,代码来源:BrazzifyController.php


示例20: register

 /**
  * User registration
  *
  * @param Request $request
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
  */
 public function register(Request $request)
 {
     if ($request->isMethod('post')) {
         $rules = ['first_name' => 'required', 'last_name' => 'required', 'position' => 'required', 'phone' => 'phone:AM', 'username' => 'required|unique:users,username', 'email' => 'required|email|unique:users,email', 'pass' => 'required|min:6|max:12', 'pass_confirmation' => 'required|min:6|max:12|same:pass', 'image' => 'mimes:jpeg,jpg,png'];
         Validator::make($request->all(), $rules)->validate();
         $user = new User();
         $user->first_name = $request->input('first_name');
         $user->last_name = $request->input('last_name');
         $user->position = $request->input('position');
         $user->role_id = 2;
         if ($request->has('phone')) {
             $user->phone = $request->input('phone');
         }
         if (!empty($request->file("image"))) {
             $generated_string = str_random(32);
             $file = $request->file("image")->store('uploads');
             $new_file = $generated_string . '.' . $request->file("image")->getClientOriginalExtension();
             Storage::move($file, 'uploads/' . $new_file);
             $img = Image::make($request->file('image'));
             $img->crop(200, 200);
             $img->save(storage_path('app/public/uploads/' . $new_file));
             $user->image = $new_file;
         }
         $user->username = $request->input('username');
         $user->email = $request->input('email');
         $user->password = Hash::make($request->input('pass'));
         $user->activation_token = str_random(32);
         $user->save();
         return redirect('/');
     } else {
         return view('site.auth.register');
     }
 }
开发者ID:GHarutyunyan,项目名称:cms,代码行数:39,代码来源:AuthController.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Isotope\Isotope类代码示例发布时间:2022-05-23
下一篇:
PHP Image\ImageManagerStatic类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap