ashleydawson/glide-bundle
Composer 安装命令:
composer require ashleydawson/glide-bundle
包简介
Glide image processing in a Symfony2 project
关键字:
README 文档
README
Add Glide HTTP image processing library to Symfony 2 projects.
Introduction
Glide is an image processing/manipulation/cache for images. It's particularly handy for modifying and storing images on Flysystem filesystems. It leverages the Intervention image manager to do the heavy lifting. The image API is exposed via an HTTP interface allowing you to embed images within your application. For example:
<!-- Embed version of a particular image, truncating the width to 300 pixels --> <img src="/route/to/image/controller/my-image.jpg?w=300" />
For more information and a better explanation, please read the official Glide docs.
This bundle incorporates all aspects of the Glide library within the Symfony 2 service container - adding features and helpers relative to working with the Glide library within Symfony 2 projects.
Installation
You can install the Glide Bundle via Composer. To do that, simply require the package in your composer.json file like so:
{
"require": {
"ashleydawson/glide-bundle": "~1.0"
}
}
Run composer update to install the package. Then you'll need to register the bundle in your app/AppKernel.php:
$bundles = array( // ... new AshleyDawson\GlideBundle\AshleyDawsonGlideBundle(), );
Basic Usage
The most simple example is actually using the glide server to process an image within a controller.
<?php namespace Acme\AcmeBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use League\Flysystem\Adapter\Local; use League\Flysystem\Filesystem; class MyController extends Controller { /** * @Route("/images/{image_name}.jpg") */ public function showImageAction(Request $request) { // Filesystems for source and cache $sourceFilesystem = new Filesystem(new Local('/path/to/source/dir')); $cacheFilesystem = new Filesystem(new Local('/path/to/cache/dir')); // Create a Glide server $glideServer = $this ->get('ashleydawson.glide.server_factory') ->create($sourceFilesystem, $cacheFilesystem) ; // Return the processed image response return $glideServer->getImageResponse($request->get('image_name'), $request->query->all()); } }
The example above will create a glide server using a local filesystem for the source and another for the cache. The action then returns an image response built using the image name (in source filesystem) and request containing the manipulation parameters.
Note: You may want to point the cache filesystem at the Symfony cache, app/cache.
Custom Manipulators
Manipulators are services that transform an image in some way. There is a library of manipulators that ships with Glide that provide transformations for size, effects, output, etc.
If you'd like to register your own custom manipulator, simply create one and tag it into the manipulator collection within the Symfony 2 service container. Like so:
<?php namespace Acme\AcmeBundle\Glide\Manipulator; use League\Glide\Api\Manipulator\ManipulatorInterface; use Intervention\Image\Image; use Symfony\Component\HttpFoundation\Request; class MyAwesomeManipulator implements ManipulatorInterface { /** * {@inheritdoc} */ public function run(Request $request, Image $image) { if ($request->has('awesome')) { // Do something awesome to the image here... } return $image; } }
Then, in the service container, simply tag your new manipulator as being a part of the glide manipulators collection.
In YAML:
services: acme.glide.manipulator.my_awesome_manipulator: class: Acme\AcmeBundle\Glide\Manipulator\MyAwesomeManipulator tags: - { name: ashleydawson.glide.manipulators }
Or, in XML:
<services> <service id="acme.glide.manipulator.my_awesome_manipulator" class="Acme\AcmeBundle\Glide\Manipulator\MyAwesomeManipulator"> <tag name="ashleydawson.glide.manipulators" /> </service> </services>
Ok, now we can use this manipulator on an image:
<img src="/route/to/image/controller/my-image.jpg?awesome=foo" />
ashleydawson/glide-bundle 适用场景与选型建议
ashleydawson/glide-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 22.45k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2015 年 04 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「image」 「http」 「thumbnail」 「resize」 「crop」 「processing」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ashleydawson/glide-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ashleydawson/glide-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ashleydawson/glide-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
repository php library
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.
A PHP library for fetching thumbnails from a URL
The Yii2 extension uses jQuery PrettyPhoto and OwlCarousel js and makes image galary from php array of structure defined.
A Gokaru storage & thumbnail server PHP client
统计信息
- 总下载量: 22.45k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-24