PHPackages                             sz4h/image - 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. sz4h/image

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

sz4h/image
==========

This image on the fly resize package

1.1.4(1mo ago)2109MITPHPPHP ^8.1|^8.2|^8.3|^8.4|^8.5

Since Aug 18Pushed 1mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (18)Versions (16)Used By (0)

This image on the fly resize package
====================================

[](#this-image-on-the-fly-resize-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/aec195a4fca44e9233c14ccc8539a532c2523d6af77e5347081dd4fc1819dfeb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f737a34682f696d6167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/space/image)[![GitHub Tests Action Status](https://camo.githubusercontent.com/ee1ce31786a871483ca1ce54e119e9f4b273215c10f0ab13c2093182beb51441/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f737a34682f696d6167652f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/space/image/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/b073918524ed7340338b8f7b0653a8ba178cf1aad760eaf7b688ae00ccc38ae9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f737a34682f696d6167652f466978253230504850253230636f64652532307374796c652532306973737565733f6c6162656c3d636f64652532307374796c65)](https://github.com/space/image/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/1970d08f2825f5369553b62db546903051a98ce4c5cea8b06e33ebe50905a56f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f737a34682f696d6167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/space/image)

This package simplifies the resized version of stored images. It's support both local images and remote ones. It uses the intervention/image.

### Requirements

[](#requirements)

- PHP &gt;= 8.0
- fileinfo php extension
- GD Library OR Imagick PHP extension

### Todo

[](#todo)

Apply some kind of cache mechanism on top of the resize core

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

[](#installation)

You can install the package via composer:

```
composer require sz4h/image
```

You should publish the config/assets file with:

```
php artisan vendor:publish --tag="image-config"
php artisan vendor:publish --tag="image-assets"
```

This is the contents of the published config file:

```
// config for Space/Image
return [

	'route' => [
		/*
		 * The route domain used for on fly resize (Can be helpful in multi-tenant system)
		 */
		'domain' => false,

		/*
		 * The route name used for on fly resize
		 */
		'name' => 'resize',

		/*
		 * The route prefix used for on fly resize
		 */
		'prefix' => 'resize',

		/*
		 * The middlewares for resize route
		 */
		'middlewares' => [
			'web',
		],
	],

	'watermark' => [
		/*
		 * Watermark image path
		 * You may need to do a vendor:publish --tag=space-watermark
		 * Or Add the watermark image into the provided path
		 * If you face an Exception on type CouldNotRetrieveWatermark
		 */
		'image' => public_path('vendor/image/watermark.png'),

		/*
		 * Watermark image position on the image
		 * Accepted values are:
		 * bottom-center
		 * bottom-right
		 * bottom-left
		 * top-center
		 * top-right
		 * top-left
		 * center-center
		 * center-left
		 * center-right
		 */
		'position' => 'bottom-right',

		/*
		 * Offset horizontally of the watermark can be positive or negative value
		*/
		'offsetX' => 10,

		/*
		 * Offset vertically of the watermark can be positive or negative value
		*/
		'offsetY' => 10,

		/*
		 * Percentage ratio between the resized image and the watermark
		 */
		'ratio' => 0.20,
	],

	/*
	 * Presets for faster sizes creations
	 * Param:
	 * w => width of the image (Type: integer)
	 * h => height of the image (Type: integer)
	 * crop => used to allow cropping (Type: boolean)
	 * retain => used to retain the aspect ratio of the image. If used with the crop then the crop will determinate the nearest value for both width and height (Type: boolean)
	 * bg => background color in hex format (Type: string)
	 * watermark => used to allow watermark of the image (Type: boolean)
	 */
	'presets' => [
		'thumbnail' => 'w=150&h=150&crop=true&retain=false&bg=ffffff&watermark=false',
		'medium' => 'w=300&h=300&crop=true&retain=true&bg=ffffff&watermark=false',
		'large' => 'w=1024&h=1024&crop=true&retain=true&bg=ffffff&watermark=true',
	],

	/*
	 * Define the fallback image if the image not found
	 */
	'not_found_image_path' => public_path('vendor/image/not-found.png'),

	/*
	 * Default values
	 */
	'default' => [
		'w' => 200,
		'h' => 200,
		'crop' => true,
		'retain' => true,
		'bg' => null,
		'watermark' => false,
	],
];
```

Usage
-----

[](#usage)

```
echo resize_url(
    'storage/default/1/2022-08-15-9d5862c703.png',
    'thumbnail',
    [
        'retain' => true,
        'crop'=> true,
        'watermark'=> true,
        'bg'=> 'ff6666',
    ]
);
echo resize_url(
    'storage/default/1/2022-08-15-9d5862c703.png',
    '300x200'
);
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/sz4h/.github/blob/main/CONTRIBUTING.md) for details.

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

[](#security-vulnerabilities)

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

Credits
-------

[](#credits)

- [Ahmed Safaa](https://github.com/mello21century)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance90

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 96.4% 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 ~94 days

Recently: every ~70 days

Total

15

Last Release

53d ago

PHP version history (4 changes)1.0.0PHP ^8.1

1.0.2PHP ^8.1|^8.2|^8.3

1.0.7PHP ^8.1|^8.2|^8.3|^8.4

1.1.3PHP ^8.1|^8.2|^8.3|^8.4|^8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/45b920e55ed62c8321c1eab4dc7a8ce226b29e4ecf4fe0923f8be1012566ef3d?d=identicon)[Mello21century](/maintainers/Mello21century)

---

Top Contributors

[![Mello21century](https://avatars.githubusercontent.com/u/4740180?v=4)](https://github.com/Mello21century "Mello21century (27 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

laravelimagespacesz4h

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/sz4h-image/health.svg)

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

###  Alternatives

[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)[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)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[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)[johncarter/filament-focal-point-picker

An image focal point picker for Filament Admin.

4326.5k1](/packages/johncarter-filament-focal-point-picker)

PHPackages © 2026

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