PHPackages                             rkcreative/aws-image-handler - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. rkcreative/aws-image-handler

ActiveLibrary[Image &amp; Media](/categories/media)

rkcreative/aws-image-handler
============================

A Laravel package to generate image urls from the AWS Serverless Image Handler CloudFormation Stack.

v1.0.4(2y ago)073MITPHP

Since Feb 29Pushed 2y ago1 watchersCompare

[ Source](https://github.com/rkcreative/aws-image-handler)[ Packagist](https://packagist.org/packages/rkcreative/aws-image-handler)[ RSS](/packages/rkcreative-aws-image-handler/feed)WikiDiscussions main Synced today

READMEChangelog (5)Dependencies (4)Versions (6)Used By (0)

AWS Serverless Image Handler Laravel Package
============================================

[](#aws-serverless-image-handler-laravel-package)

[![Latest Stable Version](https://camo.githubusercontent.com/092e7ae8fd718a98e5b5d3e03a56a6af954b51b667dfb9c988c0a4fad0cef95f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726b63726561746976652f6177732d696d6167652d68616e646c65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rkcreative/aws-image-handler)[![Total Downloads](https://camo.githubusercontent.com/17b9fe2830112bfa910e736d5baf6dc63b7d215ad64bef59ffab8a55878250dc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726b63726561746976652f6177732d696d6167652d68616e646c65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rkcreative/aws-image-handler)[![GitHub stars](https://camo.githubusercontent.com/9f7296fba9bcbfda06357bafa0e4b501d5f69c73890d3932d50dcebc22c06384/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f726b63726561746976652f6177732d696d6167652d68616e646c65722e7376673f7374796c653d666c61742d737175617265)](https://github.com/rkcreative/aws-image-handler/stargazers)[![Last Commit](https://camo.githubusercontent.com/060d71aca9e19508356c02db6fc2b39a81e84e786d699d906ad6c3117eba35ad/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6173742d636f6d6d69742f726b63726561746976652f6177732d696d6167652d68616e646c65723f7374796c653d666c61742d737175617265)](https://github.com/rkcreative/aws-image-handler/commits)[![CI](https://github.com/rkcreative/aws-image-handler/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/rkcreative/aws-image-handler/actions/workflows/ci.yml)[![License](https://camo.githubusercontent.com/02ae2c520f9e4cab4ac8ca1e1669447f8f26ec0e92efa6c18c30b193b6c74124/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f726b63726561746976652f6177732d696d6167652d68616e646c65723f7374796c653d666c61742d737175617265)](LICENSE.md)

This package provides a Laravel wrapper for the [AWS Serverless Image Handler](https://aws.amazon.com/solutions/implementations/serverless-image-handler/) service.

Requirements
------------

[](#requirements)

- PHP &gt;= 7.3
- Laravel &gt;= 5.0
- An AWS account with Image Handler service installed

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require rkcreative/aws-image-handler
```

After installing the package, the `AwsImageHandlerServiceProvider` and the `ImageHandler` facade are automatically registered, thanks to Laravel's package discovery feature.

If you're using Laravel 5.5 or later, no further steps are required. You can start using the `ImageHandler` facade right away:

```
use Rkcreative\AwsImageHandler\Facades\ImageHandler;

$url = ImageHandler::resize(200, 200)->createUrl('path/to/image.jpg');
```

If you're using a version of Laravel that's earlier than 5.5, you'll need to manually register the service provider and facade. Add the following lines to the `providers` and `aliases` arrays in your `config/app.php` file:

```
'providers' => [
    // Other service providers...

    Rkcreative\AwsImageHandler\AwsImageHandlerServiceProvider::class,
],

'aliases' => [
    // Other aliases...

    'ImageHandler' => Rkcreative\AwsImageHandler\Facades\ImageHandler::class,
],
```

Configuration
-------------

[](#configuration)

After installing the package, you should publish the configuration file:

```
php artisan vendor:publish --provider="Rkcreative\AwsImageHandler\AwsImageHandlerServiceProvider" --tag="config"
```

This command will create a `aws-image-handler.php` configuration file in your `config` directory. In this file, you can set your distribution URL and the default S3 bucket:

```
return [
    'distributionUrl' => env('AWS_IMAGE_HANDLER_URL', 'default-url'),
    'defaultBucket'   => env('AWS_IMAGE_HANDLER_S3_BUCKET', 'default-bucket'),
];
```

You should also add the `AWS_IMAGE_HANDLER_URL` and `AWS_IMAGE_HANDLER_S3_BUCKET` variables to your `.env` file:

```
AWS_IMAGE_HANDLER_URL=your-distribution-url
AWS_IMAGE_HANDLER_S3_BUCKET=your-default-bucket

```

Usage
-----

[](#usage)

Here's a detailed example of how to use the `ImageHandler` class:

```
use Rkcreative\AwsImageHandler\Services\ImageHandler;

$imageHandler = new ImageHandler();
$imageHandler->resize(200, 200);

// Generate the URL for the transformed image
$url = $imageHandler->createUrl('path/to/image.jpg');
```

In this example, the `resize` macro is used to set the desired image dimensions, and then the `createUrl` method is used to generate the URL for the transformed image. The resulting URL will look something like this:

```
https://your-cloudfront-url.com/eyJidWNrZXQiOiJidWNrZXQiLCJrZXkiOiJwYXRoL3RvL2ltYWdlLmpwZyIsImVkaXRzIjp7InJlc2l6ZSI6eyJ3aWR0aCI6MjAwLCJoZWlnaHQiOjIwMH19fQ==

```

In this URL, `your-cloudfront-url.com` is your CloudFront distribution URL, and the long base64 string is the encoded edit options.

Using the Alias
---------------

[](#using-the-alias)

The package also provides an alias, which you can use for even easier access. Here's an example:

```
use ImageHandler;

$url = ImageHandler::resize(200, 200)->createUrl('path/to/image.jpg');
```

In this example, `ImageHandler::resize(200, 200)` is equivalent to `(new Rkcreative\AwsImageHandler\Services\ImageHandler())->resize(200, 200)`. You can use this alias anywhere in your Laravel application.

Available Macros
----------------

[](#available-macros)

The `ImageHandler` class comes with the following macros:

- `smartCrop`
- `roundCrop`
- `contentModeration`
- `crop`
- `quality`
- `resize`
- `setRgba`
- `rotate`

You can use these macros like any other method on the `ImageHandler` class:

```
$imageHandler = new ImageHandler();
$imageHandler->smartCrop($options);
$imageHandler->roundCrop($options);
// etc.
```

Extending with Custom Macros
----------------------------

[](#extending-with-custom-macros)

You can extend the `ImageHandler` class with your own macros. The options are from the [Sharp Node.js image processing library](https://sharp.pixelplumbing.com/api-operation). Here's how to do it:

1. Create a new service provider:

```
php artisan make:provider ImageHandlerMacroServiceProvider
```

2. In the `boot` method of your new service provider, add your macro:

```
namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Rkcreative\AwsImageHandler\Services\ImageHandler;

class ImageHandlerMacroServiceProvider extends ServiceProvider
{
    public function boot()
    {
        // Sample blur image operation from the Sharp node.js image library to show how you could add it as a custom option.
        ImageHandler::macro('blur', function ($blur) {
            if ($blur < 0.3 || $blur > 1000) {
                throw new \InvalidArgumentException('Invalid blur value. It must be = a sigma value between 0.3 and 1000.');
            }

            $this->options['blur'] = $blur;

            return $this;
        });
    }
}
```

In this example, the `blur` macro receives a `blur` value as an argument. The `blur` value is then added to the image handler options. The macro modifies the state of the `ImageHandler` instance and then returns the instance itself, allowing for method chaining.

3. Register your new service provider in the `providers` array in `config/app.php`:

```
'providers' => [
    // Other service providers...

    App\Providers\ImageHandlerMacroServiceProvider::class,
],
```

Now, you can use your macro like any other method on the `ImageHandler` class:

```
$imageHandler = new ImageHandler();
$imageHandler->blur(3)->createUrl('path/to/image.jpg');
```

In this example, the `blur` macro is used to add a blur effect to the image. The `blur` value can be any number between 0.3 (low blur) and 1000 (maximum blur).

Contributing
------------

[](#contributing)

Contributions are welcome. We accept contributions via Pull Requests on Github.

### Bug Reports

[](#bug-reports)

If you've found a bug, please create an issue on Github describing the problem and include as much relevant information as you can. Screenshots, error messages, and sample code that reproduces the problem are all helpful.

### Pull Requests

[](#pull-requests)

- **Document any change in behavior** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
- **Create topic branches** - Don't ask us to pull from your master branch.
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.
- **Write tests for your feature** - This helps us ensure that everything is working as expected and protects against regressions when new changes are made.

To run the tests, use the following command:

```
vendor/bin/phpunit
```

**Happy coding**!

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

### Authors

[](#authors)

- [Robert Pettique](https://github.com/r0biabl0)

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

5

Last Release

853d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/432557?v=4)[Robert](/maintainers/r0bdiabl0)[@r0bdiabl0](https://github.com/r0bdiabl0)

---

Top Contributors

[![r0bdiabl0](https://avatars.githubusercontent.com/u/432557?v=4)](https://github.com/r0bdiabl0 "r0bdiabl0 (26 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/rkcreative-aws-image-handler/health.svg)

```
[![Health](https://phpackages.com/badges/rkcreative-aws-image-handler/health.svg)](https://phpackages.com/packages/rkcreative-aws-image-handler)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.0k](/packages/craftcms-cms)[illuminate/http

The Illuminate Http package.

11937.9M6.8k](/packages/illuminate-http)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

252.5k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
