spacecatninja/imager-x-aws-serverless-transformer
Composer 安装命令:
composer require spacecatninja/imager-x-aws-serverless-transformer
包简介
AWS Serverless Image Handler transformer for Imager X
关键字:
README 文档
README
A plugin for using AWS Serverless Image Handler as a transformer in Imager X.
Also, an example of how to make a custom transformer for Imager X.
Requirements
This plugin requires Craft CMS 5.0.0-beta.1 or later, Imager X 5.0.0-beta.1 or later, and a working AWS Serverless Image Handler setup.
Usage
First of all, you need to set up an AWS Serverless Image Handler in AWS. If you need help and pointers, Andrew Welch has a thorough blog post about it.
Next, install and configure this transformer as described below. Then, in your Imager X config,
set the transformer to awsserverless, ie:
'transformer' => 'awsserverless',
Transforms are now by default transformed with the AWS Serverless Image Handler. Test your configuration with a simple transform like this:
{% set transform = craft.imagerx.transformImage(asset, { width: 600 }) %}
<img src="{{ transform.url }}" width="600">
<p>URL is: {{ transform.url }}</p>
If this doesn't work, make sure the distribution URL is correct, and that the image handler is set up to use the same buckets that you assets are on.
Cave-ats, shortcomings, and tips
This transformer only supports a subset of what Imager X can do when using the default craft transformer.
All the basic transform parameters are supported, with the following exceptions:
- Percentage based focal points are not supported by the image handler, it only supports edge-based positions like
left top,right center, etc. Craft focal points are automatically converted to the nearest possible position. - Only assets that are stored in AWS buckets are possible to transform.
- The
cropOnlyresize mode is not supported. - The
cropZoomtransform parameter is not supported. - The
framesandpreEffectsare not relevant and supported. - The following
effectsare converted and supported:grayscale,negative,normalize,sharpenandblur. - The URL that comes from the image handler is... not pretty.
To pass additional options that is understood by the underlying sharp.js library the Serverless
Image Handler uses, you can use the transformerParams transform parameter. Example:
{% set transforms = craft.imagerx.transformImage(asset,
[{width: 400}, {width: 600}, {width: 800}],
{ ratio: 2/1, transformerParams: { tint: '#ff0066' } }
) %}
You can also override the automatic converted parameters, like toFormat and resize, if you need to:
{% set transforms = craft.imagerx.transformImage(asset,
[{width: 400}, {width: 600}, {width: 800}],
{ ratio: 2/1, transformerParams: { tint: '#ff0066', toFormat: 'png', resize: { position: 'left top' } } }
) %}
For more information, check out the sharp.js documentation.
Installation
To install the plugin, follow these instructions:
- Install with composer via
composer require spacecatninja/imager-x-aws-serverless-transformerfrom your project directory. - Install the plugin in the Craft Control Panel under Settings > Plugins, or from the command line via
./craft plugin/install imager-x-aws-serverless-transformer.
Configuration
You can configure the transformer by creating a file in your config folder called
imager-x-aws-serverless-transformer.php, and override settings as needed.
distributionUrl [string] (required)
Default: 'distributionUrl'
This is the URL to your AWS Serverless Image Handler distribution. Example:
'distributionUrl' => 'https://dg5e6u1m25arf.cloudfront.net',
autoConvertGif [bool]
Default: true
The AWS Image Handler can't output GIF. With this setting set to true (default), the transformer
will automatically convert GIF images to PNG to avoid errors. If you manually would like to
override this at the template level (by explicitly setting format), you can disable this.
defaultBucket [string]
Default: ''
By default, Imager will try to get the bucket name of the AWS volume for the asset you're
trying to transform, and send that to the image handler so that it knows where to get the
image from. You can configure the default bucket it should fall back to with this setting.
Probably not needed, but you never know.
Make sure you add all the buckets you've set up Craft to use, when you set up your Image Handler in AWS.
signatureKey [string]
Default: ''
The AWS Image Handler supports using signed URLs
to prevent third parties from generating their own transforms. Once you’ve configured the image handler to use them,
add your signing key and generated URLs will include a ?signature= param that’s properly hashed and ready to go.
Be careful with this! Once enabled on the server side, any transform URL without a valid signature will return an error.
Price, license and support
The plugin is released under the MIT license. It requires Imager X, which is a commercial plugin available in the Craft plugin store. If you need help, or found a bug, please post an issue in this repo, or in Imager X' repo.
spacecatninja/imager-x-aws-serverless-transformer 适用场景与选型建议
spacecatninja/imager-x-aws-serverless-transformer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21.64k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 10 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「image」 「cms」 「aws」 「transform」 「responsive」 「picture」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 spacecatninja/imager-x-aws-serverless-transformer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 spacecatninja/imager-x-aws-serverless-transformer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 spacecatninja/imager-x-aws-serverless-transformer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
GraphQL authentication for your headless Craft CMS applications.
This package includes a script and fail2ban configuration that allows you to use fail2ban when utilizing AWS elastic load balancer (ELB) and an apache webserver.
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
Set Links with a specific language parameter
Elastic Driver for Laravel Scout
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
统计信息
- 总下载量: 21.64k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 13
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-11