amostajo/laravel-image-handler
Composer 安装命令:
composer require amostajo/laravel-image-handler
包简介
Package provides laravel with Image Handler class, perfect to create thumbs, resize or crop images.
README 文档
README
Image handling solution for Laravel 5, creates thumbs on the fly, handles image cropping, upscaling and resizing.
Works with Laravel 5.1.
Installation
Add
"amostajo/laravel-image-handler": "1.0.1"
to your composer.json. Then run composer install or composer update.
Then in your config/app.php add
Amostajo\LaravelImageHandler\Providers\ImageHandlerProvider::class,
in the providers array.
Then add
'ImageHandler' => Amostajo\LaravelImageHandler\Facades\ImageHandler::class,
in the aliases array.
Copy and rename the config file [package]\config\config.php to your laravel's config directory [root]\config\image.php.
Usage
Creating a thumb for an image have never been this easy:
// $imageUrl is exactly that, an image url. // From either your own website or from an external source. $url = ImageHandler::thumb($imageUrl);
ImageHandler will actually create a thumb and place it in public/thumbs directory.
The returned $url can be placed in a img html tag like this (sample using blade):
<img src="{{ ImageHandler::thumb($imageUrl) }}"/>
The thumb created will always be cropped to fit the desired size. By default, the thumb will be cropped to the width and height specified in the configuration file, although you can easily set these as parameters:
<img src="{{ ImageHandler::thumb($imageUrl, 800, 180) }}"/>
If you don't want the image to be cropped, prefer to keep constraints and just resize, use these methods instead:
// Resized / scaled to a specific width $url = ImageHandler::width($imageUrl); // Resized / scaled to a specific height $url = ImageHandler::height($imageUrl);
<img src="{{ ImageHandler::width($imageUrl, 350) }}"/>
<img src="{{ ImageHandler::height($imageUrl, 350) }}"/>
Configuration
Modify the configuration file to adjust the default thumb sizes, set the name of the folder path for the thumbs to be stored and more.
License
This package is free software distributed under the terms of the MIT license.
Additional Information
This package uses php-image-resize.
Image credits
Beach Taken from http://beachgrooves.com on 1st of July of 2015.
Sheep Taken from https://guim.co.uk on 1st of July of 2015.
amostajo/laravel-image-handler 适用场景与选型建议
amostajo/laravel-image-handler 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.28k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2015 年 07 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「image」 「images」 「resize」 「laravel」 「handling」 「handler」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 amostajo/laravel-image-handler 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 amostajo/laravel-image-handler 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 amostajo/laravel-image-handler 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova field for distribute your images as array of object.
Pexels API Client for www.pexels.com
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
Image cache
统计信息
- 总下载量: 1.28k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-07-02