本文整理汇总了PHP中Intervention\Image\ImageManagerStatic类的典型用法代码示例。如果您正苦于以下问题:PHP ImageManagerStatic类的具体用法?PHP ImageManagerStatic怎么用?PHP ImageManagerStatic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ImageManagerStatic类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testCanvas
public function testCanvas()
{
$manager = Mockery::mock('Intervention\\Image\\ImageManager');
$managerStatic = new ImageManagerStatic($manager);
$img = $managerStatic->canvas(100, 100);
$this->assertInstanceOf('Intervention\\Image\\Image', $img);
}
开发者ID:RHoKAustralia,项目名称:onaroll21_backend,代码行数:7,代码来源:ImageManagerStaticTest.php
示例2: testCanvas
public function testCanvas()
{
$manager = Mockery::mock('Intervention\\Image\\ImageManager');
$manager->shouldReceive('canvas')->with(100, 100, null)->once();
$managerStatic = new ImageManagerStatic($manager);
$managerStatic->canvas(100, 100);
}
开发者ID:hilmysyarif,项目名称:sic,代码行数:7,代码来源:ImageManagerStaticTest.php
示例3: setAvatarAttribute
public function setAvatarAttribute($avatar)
{
if (is_object($avatar) && $avatar->isValid()) {
ImageManagerStatic::make($avatar)->fit(150, 150)->save(public_path() . "/img/avatars/{$this->id}.jpg");
$this->attributes['avatar'] = true;
}
}
开发者ID:emile442,项目名称:altis-pan,代码行数:7,代码来源:User.php
示例4: uploadBeerImg_callback
public static function uploadBeerImg_callback($request, $fileimage)
{
$image_unique_id = date('Ymdhis') . rand(0, 9999);
$beer_meta = new BeerImg();
$beer_meta->beer_id = $request['beer_id'];
$beer_meta->description = !empty($request['img_description']) ? $request['img_description'] : null;
$beer_name = !empty($request['img_description']) ? $request['img_description'] : null;
$imageName = "beerhit.com_" . strtolower($beer_name) . $request['beer_id'] . $image_unique_id . '.' . $fileimage->getClientOriginalExtension();
$path = public_path('/images/catalog/' . $imageName);
$img = ImageManagerStatic::make($fileimage);
// resize the image to a width of 960
// and constrain aspect ratio (auto width)
$img->resize(960, null, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
$img->save($path);
//Save image information to database
$beer_meta->img_id = $image_unique_id;
$beer_meta->filename = $imageName;
$beer_meta->path = '/images/catalog/' . $imageName;
$beer_meta->user_id = \Auth::user()->id;
$beer_meta->place_id = $request['fb_place_id'];
$beer_meta->save();
\UserBeerHelper::userLog(\Auth::user()->id, $request['beer_id'], 200, $request['fb_place_id'], $image_unique_id);
}
开发者ID:ktardthong,项目名称:beerhit,代码行数:26,代码来源:BeerImg.php
示例5: create
/**
* @param string $name
* @param int $size
* @param string $background_color
* @param string $text_color
* @param string $font_file
* @return ImageManagerStatic
* @throws Exception
*/
public static function create($name = '', $size = 512, $background_color = '#666', $text_color = '#FFF', $font_file = '../../../font/OpenSans-Semibold.ttf')
{
if (strlen($name) <= 0) {
throw new Exception('Name must be at least 2 characters.');
}
if ($size <= 0) {
throw new Exception('Input must be greater than zero.');
}
if ($font_file === '../../../font/OpenSans-Semibold.ttf') {
$font_file = __DIR__ . "/" . $font_file;
}
if (!file_exists($font_file)) {
throw new Exception("Font file not found");
}
$str = "";
$name_ascii = strtoupper(Str::ascii($name));
$words = preg_split("/[\\s,_-]+/", $name_ascii);
if (count($words) >= 2) {
$str = $words[0][0] . $words[1][0];
} else {
$str = substr($name_ascii, 0, 2);
}
$img = ImageManagerStatic::canvas($size, $size, $background_color)->text($str, $size / 2, $size / 2, function ($font) use($size, $text_color, $font_file) {
$font->file($font_file);
$font->size($size / 2);
$font->color($text_color);
$font->align('center');
$font->valign('middle');
});
return $img;
}
开发者ID:a6digital,项目名称:laravel-default-profile-image,代码行数:40,代码来源:DefaultProfileImage.php
示例6: actions
public function actions()
{
return ['picture-upload' => ['class' => UploadAction::className(), 'deleteRoute' => 'picture-delete', 'on afterSave' => function ($event) {
/* @var $file \League\Flysystem\File */
$file = $event->file;
$img = ImageManagerStatic::make($file->read())->fit(self::IMAGE_MAX_WIDTH, self::IMAGE_MAX_HEIGHT);
$file->put($img->encode());
}], 'picture-delete' => ['class' => DeleteAction::className()]];
}
开发者ID:kartrez,项目名称:pitomec,代码行数:9,代码来源:PetCategoryController.php
示例7: actions
/**
* @return array
*/
public function actions()
{
return ['avatar-upload' => ['class' => UploadAction::className(), 'deleteRoute' => 'avatar-delete', 'on afterSave' => function ($event) {
/* @var $file \League\Flysystem\File */
$file = $event->file;
$img = ImageManagerStatic::make($file->read())->fit(215, 215);
$file->put($img->encode());
}], 'avatar-delete' => ['class' => DeleteAction::className()]];
}
开发者ID:rafalsky,项目名称:home-finance,代码行数:12,代码来源:DefaultController.php
示例8: convertBase64ToTmpFile
public function convertBase64ToTmpFile($rawBase64)
{
$name = time() . '_' . mt_rand(0, 999999999) . '.png';
$photo = ImageManagerStatic::make($rawBase64);
$photo->widen($photo->width() / 1.5);
$photo->encode('png');
$photo->save('share/' . $name);
return $name;
}
开发者ID:mrAndersen,项目名称:Creed,代码行数:9,代码来源:Helper.php
示例9: executeCalls
/**
* @param $target
*
* @return mixed
*/
public function executeCalls($target)
{
if (!empty($this->calls)) {
$image = ImageManagerStatic::make($target);
foreach ($this->calls as $call) {
call_user_func_array([$image, $call['method']], $call['arguments'])->save($target);
}
}
return $target;
}
开发者ID:z-song,项目名称:laravel-admin,代码行数:15,代码来源:Image.php
示例10: setFile
public function setFile($file)
{
$this->file = $file;
$this->image = Image::make($this->file);
$this->iptc = $this->image->iptc();
$this->exif = $this->image->exif();
return $this;
}
开发者ID:katzefudder,项目名称:Photoindexer,代码行数:8,代码来源:ImageHandler.php
示例11: run
public function run(File $file)
{
$image = $this->intervention->make($file->getRealPath());
$image->orientate();
$image->save(null, 100);
$image->destroy();
}
开发者ID:bmartel,项目名称:phperclip,代码行数:7,代码来源:FixRotation.php
示例12: run
public function run(File $file)
{
$image = $this->intervention->make($file->getRealPath());
$preserveRatio = $this->preserveRatio;
$image->resize($this->width, $this->height, function ($constraint) use($preserveRatio) {
if ($preserveRatio) {
$constraint->aspectRatio();
}
});
$image->save(null, 100);
$image->destroy();
}
开发者ID:bmartel,项目名称:phperclip,代码行数:12,代码来源:Resize.php
示例13: f_img_resize
function f_img_resize($path, $w, $h, $watermark = null)
{
if (!$path) {
return;
}
//Image::configure(array('driver' => 'gd'));
$path_0 = $path;
if (!file_exists(WEB . $path_0)) {
return;
}
$path = str_replace('/upload/', '/upload/thum/', $path);
$new = file_dir($path);
$ext = file_ext($path);
$new = $new . '/' . file_name($path) . "_{$w_}{$h}" . '.' . $ext;
if (file_exists(WEB . $new)) {
return $new;
}
echo WEB . $path_0;
$img = Image::make(WEB . $path_0);
$img->resize($w, $h);
if (!is_dir(WEB . file_dir($new))) {
mkdir(WEB . $new, 0777, true);
}
if ($watermark) {
$img->insert(WEB . $watermark);
}
$img->save(WEB . $new);
return $new;
}
开发者ID:sunkangtaichi,项目名称:PHPAPPLISTION_START,代码行数:29,代码来源:function.php
示例14: get
public function get($icon, $request, $response)
{
$info = pathinfo($icon);
$iconName = $info["filename"];
$extension = isset($info["extension"]) ? $info["extension"] : "png";
$size = $request->getParameter("size", 512);
$color = trim($request->getParameter("color", "777"), '#');
$filename = "icons/{$iconName}_{$size}_{$color}.{$extension}";
$targetFolder = realpath(".");
$targetLocation = "https://" . $_SERVER["HTTP_HOST"] . dirname($_SERVER["SCRIPT_NAME"]) . "/" . $filename;
if (is_file($targetFolder . '/' . $filename)) {
return $response->status(301)->header("Location", $targetLocation);
}
$ttf = realpath(dirname(__FILE__) . "/../webfonts/fontawesome/fontawesome-webfont.ttf");
$characters = (include realpath(dirname(__FILE__) . "/../webfonts/fontawesome/characters.php"));
if (!isset($characters[$iconName])) {
return $response->status(404);
}
$iconChar = html_entity_decode('&#' . $characters[$iconName] . ';');
$canvas = Image::canvas($size, $size);
$canvas->text($iconChar, $size / 2, $size / 2, function ($font) use($ttf, $size, $color) {
$font->file($ttf);
$font->size($size - 2);
$font->color('#' . $color);
$font->align('center');
$font->valign('center');
});
$canvas->save($targetFolder . '/' . $filename);
return $response->status(301)->header("Location", $targetLocation);
}
开发者ID:phidias-sas,项目名称:icons.api,代码行数:30,代码来源:Controller.php
示例15: savePoster
public function savePoster($filename)
{
$finfo = new finfo(FILEINFO_MIME_TYPE);
$mime = $finfo->file($filename);
$extensions = ['image/jpg' => '.jpg', 'image/jpeg' => '.jpg', 'image/png' => '.png', 'image/gif' => '.gif'];
$extension = '.jpg';
if (!isset($extensions[$mime])) {
$extension = $extensions[$mime];
}
$newFilename = uniqid() . $extension;
$folder = "./images/posters/originals";
// no trailing slash
if (!is_dir($folder)) {
mkdir($folder, 0777, true);
}
$destination = $folder . "/" . $newFilename;
move_uploaded_file($filename, $destination);
$this->poster = $newFilename;
//240x300 80x100
if (!is_dir("./images/posters/300h")) {
mkdir("./images/posters/300h", 0777, true);
}
$img = Image::make($destination);
$img->fit(240, 300);
$img->save("./images/posters/300h/" . $newFilename);
if (!is_dir("./images/posters/100h")) {
mkdir("./images/posters/100h", 0777, true);
}
$img = Image::make($destination);
$img->fit(80, 100);
$img->save("./images/posters/100h/" . $newFilename);
}
开发者ID:Matthew-Amundsen,项目名称:Server-Side-Development,代码行数:32,代码来源:Comment.php
示例16: uploadFile
/**
* Upload File with Request
*
* @param User $user
* @param \Illuminate\Http\Request::file() $file
*/
private function uploadFile($user, $file, $type)
{
$client_original_name = $file->getClientOriginalName();
$fileName = time() . '_' . $client_original_name;
//?
$destinationPath = 'uploads/profile';
$path = $destinationPath . '/' . $fileName;
$image = Image::make($file->getRealPath());
switch ($type) {
case 'profile_photo':
$image->fit(128, 128, function ($constraint) {
$constraint->upsize();
})->save($path);
break;
case 'profile_cover':
$image->resize(1440, null, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
})->save($path);
break;
}
$original_name = pathinfo($client_original_name, PATHINFO_FILENAME);
$file = File::create(['url' => $path, 'original_name' => $original_name, 'type' => $type]);
return $file->id;
}
开发者ID:realnerdo,项目名称:blog,代码行数:31,代码来源:UsersController.php
示例17: image
public function image($display_size, $image_size, $image_path)
{
$max_age_days = 30;
$pixel_density = 2;
$display_sizes = ['sm' => 320, 'md' => 480, 'lg' => 600, 'xl' => 960];
$image_sizes = ['full' => 1, 'half' => 0.5, 'third' => 0.34, 'quarter' => 0.25];
$compressions = ['sm' => 80, 'md' => 80, 'lg' => 80, 'xl' => 80];
$src_path = config('site.assets_path') . '/' . $image_path;
$new_width = (int) ($display_sizes[$display_size] * $pixel_density * $image_sizes[$image_size]);
$compression = $compressions[$display_size];
$colors = (int) Input::get('colors');
// Throw 404 if image does not exist
if (!file_exists($src_path)) {
return response('image not found', 404);
}
$img = Image::make($src_path);
$img->resize($new_width, null, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
if ($colors > 0) {
$img->limitColors($colors, '#ffffff');
}
$response = Response::make($img->encode(null, $compression), 200);
$response->header('Content-Type', $img->mime());
$response->header('Cache-Control', 'max-age=' . $max_age_days * 24 * 60 * 60 . ', public');
return $response;
}
开发者ID:mcculley1108,项目名称:faithpromise.org,代码行数:28,代码来源:AssetsController.php
示例18: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$images = $request->input('images');
$gallery_name = 'gallery_' . time();
$directory = 'uploads/' . $gallery_name . '/';
mkdir($directory, 0755);
$gallery = Gallery::create(['name' => $gallery_name, 'directory' => $directory]);
foreach ($images as $image) {
$url = $image['url'];
$img = Image::make($url);
$img->resize(800, null, function ($constraint) {
$constraint->aspectRatio();
$constraint->upsize();
});
preg_match('/\\.[^\\.]+$/i', $url, $ext);
$filename = $directory . time() . $ext[0];
$stream = $img->stream();
$s3 = Storage::disk('s3');
$s3->put($filename, $stream->__toString(), 'public');
$client = $s3->getDriver()->getAdapter()->getClient();
$public_url = $client->getObjectUrl(env('S3_BUCKET'), $filename);
$gallery->images()->create(['url' => $public_url]);
}
$response = ['message' => 'Images successfully uploaded', 'redirect' => url('gallery', $gallery_name)];
return response()->json($response);
}
开发者ID:realnerdo,项目名称:photoshow,代码行数:32,代码来源:GalleriesController.php
示例19: upload
public function upload()
{
$file = Input::file('file');
$input = array('image' => $file);
$rules = array('image' => 'image');
$validator = Validator::make($input, $rules);
$imagePath = 'public/uploads/';
$thumbPath = 'public/uploads/thumbs/';
$origFilename = $file->getClientOriginalName();
$extension = $file->getClientOriginalExtension();
$mimetype = $file->getMimeType();
if (!in_array($extension, $this->whitelist)) {
return Response::json('Supported extensions: jpg, jpeg, gif, png', 400);
}
if (!in_array($mimetype, $this->mimeWhitelist) || $validator->fails()) {
return Response::json('Error: this is not an image', 400);
}
$filename = str_random(12) . '.' . $extension;
$image = ImageKit::make($file);
//save the original sized image for displaying when clicked on
$image->save($imagePath . $filename);
// make the thumbnail for displaying on the page
$image->fit(640, 480)->save($thumbPath . 'thumb-' . $filename);
if ($image) {
$dbimage = new Image();
$dbimage->thumbnail = 'uploads/thumbs/thumb-' . $filename;
$dbimage->image = 'uploads/' . $filename;
$dbimage->original_filename = $origFilename;
$dbimage->save();
return $dbimage;
} else {
return Response::json('error', 400);
}
}
开发者ID:bobseven,项目名称:onimage-site,代码行数:34,代码来源:ImageController.php
示例20: cropImage
/**
* Description
* @param object $request
* @param string $destino
* @return array
*/
public function cropImage($request, $destino)
{
$data = $request->all();
if ($request->hasFile('avatar')) {
$novoNome = date('d-m-Y-h-i-s') . '-' . $request->file('avatar')->getClientOriginalName();
if ($data['x1'] !== '' && $data['x2'] !== '' && $data['y1'] !== '' && $data['y2'] !== '') {
$w = $data['x2'] - $data['x1'];
$h = $data['y2'] - $data['y1'];
$x = $data['x1'];
$y = $data['y1'];
Image::configure(array('driver' => 'gd'));
$image = Image::make($request->file('avatar'));
// width, height, $x, $y
$image->crop($w, $h, $x, $y);
$image->save($destino . $novoNome);
} else {
$image = Image::make($request->file('avatar'));
$image->save($destino . $novoNome);
}
$data["avatar"] = $novoNome;
}
unset($data['_token']);
unset($data['x1']);
unset($data['y1']);
unset($data['x2']);
unset($data['y2']);
return $data;
}
开发者ID:EnnioSimoes,项目名称:arquivo-dev,代码行数:34,代码来源:UserService.php
注:本文中的Intervention\Image\ImageManagerStatic类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论