PHPackages                             modularavel/imgenerator - 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. modularavel/imgenerator

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

modularavel/imgenerator
=======================

This is my package image

1.0.0(1y ago)214MITPHPPHP ^8.2

Since Mar 2Pushed 1y ago2 watchersCompare

[ Source](https://github.com/modularavel/imgenerator)[ Packagist](https://packagist.org/packages/modularavel/imgenerator)[ Docs](https://github.com/modularavel/image)[ RSS](/packages/modularavel-imgenerator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (13)Versions (2)Used By (0)

modularavel/imgenerator
=======================

[](#modularavelimgenerator)

[![](./preview/basics.jpg)](./preview/basics.jpg)Dynamically image resizes by url parameters... fast and easy to use and/or customize.

Server Requirements
-------------------

[](#server-requirements)

This should go without saying really but TimThumb requires PHP and the GD image library. These are really really common so you shouldn’t have any problems. If you find yourself without these installed then ask your webhost and many will install the software for you – if they don’t do the installation it’s probably worth considering a new host.

File Permissions
----------------

[](#file-permissions)

Some web hosts won’t execute PHP code if it sits in directories that have permissions set to 777. So make sure that any directories ‘above’ the timthumb.php file are set to a normal level of permissions (644 is good).

Image Formats
-------------

[](#image-formats)

Make sure that the images are one of .JPG, .JPEG, .GIF, or .PNG, or they won’t be resized!

Ensure if the cache/index.html empty file exists
------------------------------------------------

[](#ensure-if-the-cacheindexhtml-empty-file-exists)

To prevent the cache files from being browsable, an index.html file is created in the cache directory. This file should have it’s permissions set to 666

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

[](#installation)

You can install the package via composer:

```
composer require modularavel/imgenerator
```

You can publish the config file with:

```
php artisan vendor:publish --tag="imgenerator-config"
```

This is the contents of the published config file:

```
return [
    'source' => [
        'filesystem' => env('MODULARAVEL_IMGENERATOR_SOURCE_FILESYSTEM', 'public'), // Options: "local", "public", "s3"
    ],
    'cache' => [
        'folder' => env('MODULARAVEL_IMGENERATOR_CACHE_FOLDER', '/cache'),
        'prefix' => env('MODULARAVEL_IMGENERATOR_CACHE_PREFIX', 'cache_'),
        'filesystem' => env('MODULARAVEL_IMGENERATOR_CACHE_FILESYSTEM', 'local'), // Options: "local", "public", "s3"
    ],
    'allow_external_sites' => env('MODULARAVEL_IMGENERATOR_ALLOW_EXTERNAL_SITES', true),
    'allow_all_external_sites' => env('MODULARAVEL_IMGENERATOR_ALLOW_ALL_EXTERNAL_SITES', true),
    'allowed_external_hosts' => env('MODULARAVEL_IMGENERATOR_ALLOWED_EXTERNAL_HOSTS', [
        'facebook.com',
        'img.youtube.com',
        'upload.wikimedia.org',
        'imgur.com',
        'amazonaws.com',
    ]),
];
```

Proportional Image Scaling
--------------------------

[](#proportional-image-scaling)

[![](./preview/cropping-zooming.jpg)](./preview/cropping-zooming.jpg)Usage is simple. The mysterious zc (Zoom &amp; Crop) parameter comes into action, simply give it the value of 2 and it will apply the borders as required.

### The 'zc' parameter = Zoom &amp; Crop

[](#the-zc-parameter--zoom--crop)

- The zc parameter was introduced to TimThumb about 3 months after it was first published. The reason for the inclusion is that the scaling in the original version was purely scaling, there was no cropping. This meant that images could end up severely distorted.
- With the new cropping modes this thought has ended. I have added some new scaling modes, as described below.

    ```
    0 - Resize to Fit specified dimensions (no cropping);
    1 - Crop and resize to best fit the dimensions (default);
    2 - Resize proportionally to fit entire image into specified dimensions, and add borders if required;
    3 - Resize proportionally adjusting size of scaled image so there are no borders gaps.

    ```

Image Filters
-------------

[](#image-filters)

[![](./preview/image-filters.jpg)](./preview/image-filters.jpg)When I talk about image filters, I mean the types of effects you can get in Photoshop or most other image editors. Things like altering brightness and contrast, and blur or emboss. All this functionality is included in TimThumb.

The functionality is actually the implementation of a single PHP function called imagefilter. For more details you can check out the imagefilter documentation on php.net.

- Add parameter "f" to your query url: ...&amp;f=" IMAGE\_FILTERS "
    - Or ?f="IMAGE\_FILTERS" *(when f = first url parameter)*

        ```
          f=1,10

        ```
    - It’s probably easier to understand if you see it in practice so now would be a good time to view the demo.

        - The image filters and arguments that you can use are:

            ```
                  1 = Negate – Invert colours
                  2 = Grayscale – turn the image into shades of grey
                  3 = Brightness – Adjust brightness of image. Requires 1 argument to specify the amount of brightness to add. Values can be negative to make the image darker.
                  4 = Contrast – Adjust contrast of image. Requires 1 argument to specify the amount of contrast to apply. Values greater than 0 will reduce the contrast and less than 0 will increase the contrast.
                  5 = Colorize/ Tint – Apply a colour wash to the image. Requires the most parameters of all filters. The arguments are RGBA
                  6 = Edge Detect – Detect the edges on an image
                  7 = Emboss – Emboss the image (give it a kind of depth), can look nice when combined with the colorize filter above.
                  8 = Gaussian Blur – blur the image, unfortunately you can’t specify the amount, but you can apply the same filter multiple times (as shown in the demos)
                  9 = Selective Blur – a different type of blur. Not sure what the difference is, but this blur is less strong than the Gaussian blur.
                  10 = Mean Removal – Uses mean removal to create a “sketchy” effect.
                  11 = Smooth – Makes the image smoother.

            ```

        ### Multiple Filters at once

        [](#multiple-filters-at-once)

        - To make this super flexible I thought it would be good if I could chain the filters together to use multiple filters on a single image. To do this simply separate multiple filters using a pipe character and then pass the whole lot to TimThumb. For example the values below would apply a brightness of 10 to a grayscale image:

            ```
             f=2|1,10

            ```

            *You can see some examples of multiple filters being used on the demo page.*

        ### s – sharpen

        [](#s--sharpen)

        - One little extra I recently added is a sharpen filter. This is separate to the other filters above as it doesn’t use the imagefilter PHP command. All you have to do is add an s=1 value to the TimThumb query string.

            ```
            s=1

            ```

API Reference
-------------

[](#api-reference)

#### Get all items

[](#get-all-items)

```
  GET /api/items
```

ParameterTypeDescription`api_key``string`**Required**. Your API key#### Get item

[](#get-item)

```
  GET /api/items/${id}
```

ParameterTypeDescription`id``string`**Required**. Id of item to fetch#### add(num1, num2)

[](#addnum1-num2)

Takes two numbers and returns their sum.

Usage
-----

[](#usage)

##### Add this to your .env file

[](#add-this-to-your-env-file)

```
# local | s3 | public
MODULARAVEL_IMGENERATOR_SOURCE_FILESYSTEM=s3
```

```
// Directly parameters
echo '';

// Or...
$image = route('modularavel::imgenerator', [
    // Image file path or image url
    "path" => storage()->drive(config('filesystem.default'))->url('uploads/avatar.jpg'),

    // Output image width
    "w" => 200,

    // Output image height
    "h" => 200,

    // Zoom crop control (numeric)
    "zc" => 1, // min: 0, max: 3
]);

echo '
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Casimiro Rocha](https://github.com/casimirorocha)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance46

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 59.9% 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

Unknown

Total

1

Last Release

442d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7354fd72dfef31d8a9afddab61122ab6ade014057993e0c05b1f7e0d95343742?d=identicon)[modularavel](/maintainers/modularavel)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (359 commits)")[![mvdnbrk](https://avatars.githubusercontent.com/u/802681?v=4)](https://github.com/mvdnbrk "mvdnbrk (46 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (23 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (22 commits)")[![pforret](https://avatars.githubusercontent.com/u/474312?v=4)](https://github.com/pforret "pforret (16 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (16 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (14 commits)")[![modularavel](https://avatars.githubusercontent.com/u/149928614?v=4)](https://github.com/modularavel "modularavel (12 commits)")[![patinthehat](https://avatars.githubusercontent.com/u/5508707?v=4)](https://github.com/patinthehat "patinthehat (10 commits)")[![riasvdv](https://avatars.githubusercontent.com/u/3626559?v=4)](https://github.com/riasvdv "riasvdv (9 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (8 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (7 commits)")[![crynobone](https://avatars.githubusercontent.com/u/172966?v=4)](https://github.com/crynobone "crynobone (7 commits)")[![irfanm96](https://avatars.githubusercontent.com/u/42065936?v=4)](https://github.com/irfanm96 "irfanm96 (5 commits)")[![thecaliskan](https://avatars.githubusercontent.com/u/13554944?v=4)](https://github.com/thecaliskan "thecaliskan (5 commits)")[![IGedeon](https://avatars.githubusercontent.com/u/694313?v=4)](https://github.com/IGedeon "IGedeon (4 commits)")[![yaroslawww](https://avatars.githubusercontent.com/u/23663794?v=4)](https://github.com/yaroslawww "yaroslawww (3 commits)")[![jessarcher](https://avatars.githubusercontent.com/u/4977161?v=4)](https://github.com/jessarcher "jessarcher (3 commits)")[![koossaayy](https://avatars.githubusercontent.com/u/6431084?v=4)](https://github.com/koossaayy "koossaayy (3 commits)")[![lloricode](https://avatars.githubusercontent.com/u/8251344?v=4)](https://github.com/lloricode "lloricode (3 commits)")

---

Tags

laravelimagemodularavel

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/modularavel-imgenerator/health.svg)

```
[![Health](https://phpackages.com/badges/modularavel-imgenerator/health.svg)](https://phpackages.com/packages/modularavel-imgenerator)
```

###  Alternatives

[joshembling/image-optimizer

Optimize your Filament images before they reach your database.

111145.4k12](/packages/joshembling-image-optimizer)[saasykit/laravel-open-graphy

An awesome open graph image (social cards) generator package for Laravel.

13057.0k](/packages/saasykit-laravel-open-graphy)[ace-of-aces/laravel-image-transform-url

Easy, URL-based image transformations inspired by Cloudflare Images.

1756.4k](/packages/ace-of-aces-laravel-image-transform-url)[danihidayatx/image-optimizer

Optimize your Filament images before they reach your database. Forked from joshembling/image-optimizer for Filament v4 &amp; v5 support.

254.4k](/packages/danihidayatx-image-optimizer)

PHPackages © 2026

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