本文整理汇总了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);
}
}
示例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');
}
示例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;
}
示例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);
}
}
示例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));
}
示例6: makeThumbnail
protected function makeThumbnail()
{
Image::make($this->filePath())->fit(200)->save($this->thumbnailPath());
}
示例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);
}
示例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;
}