smallpics/imagerx-smallpics
Composer 安装命令:
composer require smallpics/imagerx-smallpics
包简介
Small Pics transformer for Imager X
README 文档
README
Small Pics is a fast, affordable image transform service with global edge caching and AVIF by default. This plugin adds Small Pics as a transformer for Imager X, giving you on-the-fly image resizing, cropping, format conversion, watermarks, and more through a simple URL API.
Plans start at $9/mo with predictable, flat-tier pricing and no per-bandwidth charges. Works with any origin: S3, R2, DigitalOcean Spaces, Hetzner, or any HTTP source. Supports multiple origins per project and signed URLs for secure delivery.
Switching from Imgix? Small Pics includes an Imgix parameter compatibility mode, and most existing Imager X template code works with minimal changes. See the migration guide for a step-by-step walkthrough.
Requirements
- Craft CMS 5.0.0+
- Imager X 5.1.0+
- PHP 8.2+
Installation
composer require smallpics/imagerx-smallpics php craft plugin/install imagerx-smallpics
Configuration
Add the Small Pics configuration to your Imager X Small Pics transformer config file (config/imagerx-smallpics.php):
Options
baseUrl
Base URL for your Small Pics origin.
Example: https://your-origin.smallpics.io/
secret
Default: null.
Optional signing secret for your Small Pics image origin.
Setting this will enable URL signing for generated URLs. If your Small Pics config has signed URL disabled, then including a signature will have no effect on the transformed images.
transformSvgs
Default: false.
Whether SVG images should be transformed.
transformAnimatedGifs
Default: false.
Whether animated GIF images should be transformed.
defaultParams
Global default parameters for Small Pics transformations. See the Small Pics API documentation for available options.
These are applied in addition to any default parameters configured per origin (if any), and are merged with any transformerParams passed when transforming an image.
origins
An array of named origin configurations.
If you require multiple Small Pics origins, you can configure them here instead of configuring the root-level options.
Each origin configuration supports the same options as above, see multi-origin config below for an example configuration and multi-origin usage for how to select an origin when transforming an image.
Example configurations
Single origin config
return [ 'baseUrl' => getenv('SMALLPICS_BASE_URL'), 'secret' => getenv('SMALLPICS_SECRET') ?: null, 'transformSvgs' => false, 'transformAnimatedGifs' => false, 'defaultParams' => [], ];
Multi-origin config
It is possible to configure multiple origins. You can then select the origin to use when transforming an image by setting the origin key in the transformerParams array.
return [ 'defaultParams' => [ 'format' => 'webp', ], 'origins' => [ \smallpics\imagerx\smallpics\models\Settings::DEFAULT_ORIGIN_NAME => [ // Or simply 'default' 'baseUrl' => getenv('SMALLPICS_DEFAULT_ORIGIN_BASE_URL'), 'secret' => getenv('SMALLPICS_DEFAULT_ORIGIN_SECRET') ?: null, 'transformSvgs' => false, 'transformAnimatedGifs' => false, 'defaultParams' => [ 'quality' => 80, ], ], 'origin2' => [ 'baseUrl' => getenv('SMALLPICS_ORIGIN2_BASE_URL'), 'secret' => getenv('SMALLPICS_ORIGIN2_SECRET') ?: null, 'transformSvgs' => true, 'transformAnimatedGifs' => false, 'defaultParams' => [ 'format' => 'png', 'quality' => 90 ], ], ], ];
You can also set the name of the default origin by setting the defaultOrigin key in the config:
return [ 'defaultOrigin' => 'spaces', 'origins' => [ 'spaces' => [ 'baseUrl' => getenv('SMALLPICS_SPACES_BASE_URL'), // ... ], 's3' => [ 'baseUrl' => getenv('SMALLPICS_S3_BASE_URL'), // ... ], ], ];
Usage
Once installed and configured, you can use the transformer with Imager X:
{% set transformedImages = craft.imagerx.transformImage(rawImage, [
{ width: 74, height: 74 },
{ width: 120, height: 120 },
{ width: 172, height: 172 },
{ width: 254, height: 254 }
], {
mode: 'crop',
transformerParams: {
padding: 10,
background: 'ff0000',
border: {
width: 10,
color: '000000',
borderMethod: 'overlay',
}
},
}) %}
Multi-origin usage
{% set transformedImages = craft.imagerx.transformImage(rawImage, [
{ width: 74, height: 74 },
{ width: 120, height: 120 },
{ width: 172, height: 172 },
{ width: 254, height: 254 }
], {
mode: 'crop',
transformerParams: {
origin: 'origin2',
padding: 10,
background: 'ff0000',
border: {
width: 10,
color: '000000',
borderMethod: 'overlay',
}
},
}) %}
Notes
Take a look at the Small Pics API documentation for a list of available options to use in the defaultParams and transformerParams arrays.
This transformer uses smallpics/smallpics-php under the hood. Take a look there for more usage information.
smallpics/imagerx-smallpics 适用场景与选型建议
smallpics/imagerx-smallpics 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.02k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 08 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「images」 「transformer」 「processing」 「smallpics」 「imagerx」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 smallpics/imagerx-smallpics 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 smallpics/imagerx-smallpics 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 smallpics/imagerx-smallpics 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Serializer transformers outputting valid API responses in JSON, JSON API and HAL+JSON API formats.
Symfony 2 & 3 JSON API Transformer Package
A Laravel Nova field for distribute your images as array of object.
Pexels API Client for www.pexels.com
A simple library that allows transform any kind of data to native php data or whatever
HAL+JSON & HAL+XML API transformer outputting valid API responses.
统计信息
- 总下载量: 6.02k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-02