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

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

lassehaslev/image
=================

0.2.1(9y ago)11061MITPHPPHP &gt;=5.4.0

Since Jun 29Pushed 9y ago1 watchersCompare

[ Source](https://github.com/LasseHaslev/image-handler)[ Packagist](https://packagist.org/packages/lassehaslev/image)[ RSS](/packages/lassehaslev-image/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (1)Versions (8)Used By (1)

image-handler
=============

[](#image-handler)

PHP image handler gives easy to use function for manipulating images

Motivation
----------

[](#motivation)

Resizing and cropping images on web is pain, and i wanted an image-engine that does this for me.

This package and its base concept is greatly inspired by [Croppa](https://github.com/BKWLD/croppa).

Usage
-----

[](#usage)

I use this package mainly in my [Laravel](https://laravel.com/) projects.

Run `composer require lassehaslev/image` in your project folder

#### Laravel

[](#laravel)

If you want to use this package in you laravel project. We automaticly crops and resize the images based on the filename.

Open `config/app.php` and add `LasseHaslev\Image\Providers\LaravelServiceProvider::class` to `providers` array.

Classes
-------

[](#classes)

You can nativly use this package in all php projects.

#### CropHandler

[](#crophandler)

Adds base folder and crops folder and handle image from image path.

If no crops folder is set, we crate crops in same folder as original.

```
$baseFolder = '/image';
$cropsFolder = '/image/crops';
$handler = CropHandler::create( $baseFolder, $cropsFolder );

$this->handler
    ->handle( [
        'name'=>'test-image.jpg',
        'width'=>89,
        'height'=>89,
        'resize'=>true,
    ] )
    ->save( 'test-image-89x89-resize.jpg' );
```

#### Adaptors

[](#adaptors)

You can use adapotors to handle image.

```
class Adaptor implements CropAdaptorInterface
{
    public function transform( $input, $handler = null )
    {
        return [
            'name'=>$input,
            'width'=>300,
            'height'=>200,
            'resize'=>true,
        ];
    }
}
$baseFolder = '/image';
$cropsFolder = '/image/crops';
$handler = CropHandler::create( $baseFolder, $cropsFolder, new Adaptor );

$this->handler
    ->handle( 'originalFilename.jpg' )
    ->save( 'newFilename' );
```

#### ImageModifier

[](#imagemodifier)

The `ImageModifier` is the base image class for manipulating the images.

```
use LasseHaslev\Image\Modifiers\ImageModifier;
$modifier = ImageModifier::create( { absolute image path } );

// Crop image function
$modifier->crop( $x1, $y1, $x2, $y2 );

// Crop image to width and height based on fucuspoint
$modifier->cropToFit( $width, $height, $focusPointX = 0, $focusPointY = 0 );

// Resize width and height
$modifier->resize( $width, $height );

// Save the new image
$modifier->save( {absolutePath} );

// Example
$modifier->cropToFit( 300, 300 )
    ->save( '/path/to/image.jpg' );
```

#### ImageHandler

[](#imagehandler)

The ImageHandler is for handling image and the crops. It extends from `ImageModifier`.

```
use LasseHaslev\Image\Handlers\ImageHandler;
$modifier = ImageHandler::create( $filepath );

// Remove the crops
$modifier->removeCrops();

// Save
$modifier->save( $pathOrFilename, $isFullPath = false );
```

Development
-----------

[](#development)

I have a problem with my tests. but i dont know why. Sometimes it passes and sometimes it dont.

```
# Prepare test images
sh prepare.sh

# Install php dependencies
composer install

# Install elixir dependencies
npm install

# run Test driven development through elixir
gulp tdd
```

``

License
-------

[](#license)

MIT, dawg

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

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 ~60 days

Recently: every ~16 days

Total

6

Last Release

3350d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/39edaff7913420649a4d7e159faecfef8210b583f645ef2f89545f2c72b64a9b?d=identicon)[LasseHaslev](/maintainers/LasseHaslev)

---

Top Contributors

[![LasseHaslev](https://avatars.githubusercontent.com/u/3670799?v=4)](https://github.com/LasseHaslev "LasseHaslev (69 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[goat1000/svggraph

Generates SVG graphs

133890.0k3](/packages/goat1000-svggraph)[imagekit/imagekit

PHP library for Imagekit

46877.3k10](/packages/imagekit-imagekit)[gravatarphp/gravatar

Gravatar URL builder which is most commonly called as a Gravatar library

12644.1k2](/packages/gravatarphp-gravatar)

PHPackages © 2026

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