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

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

anakadote/image-manager
=======================

Image resizing and cropping package for Laravel.

1.1.2(9mo ago)65.7k↓33.3%1[1 issues](https://github.com/anakadote/ImageManager/issues)MITPHPPHP ^7.0 || ^8.0

Since Nov 25Pushed 9mo ago1 watchersCompare

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

READMEChangelogDependencies (2)Versions (7)Used By (0)

Image Resizing and Cropping Package for Laravel
===============================================

[](#image-resizing-and-cropping-package-for-laravel)

This Laravel package provides a convenient way of resizing and cropping images.

Begin by installing this package through Composer via the terminal.

```
composer require anakadote/image-manager

```

Next, add the service provider. Open `config/app.php` and add a new item to the providers array.

```
Anakadote\ImageManager\ImageManagerServiceProvider::class

```

The final step is to use artisan to move the package assets to the public directory, also from the Terminal:

```
php artisan vendor:publish --provider="Anakadote\ImageManager\ImageManagerServiceProvider"

```

Usage
-----

[](#usage)

This package is accessible via a Laravel Facade so to use simply call its methods on the Facade "ImageManager".

### getImagePath($filename, $width, $height, $mode, $quality = 90)

[](#getimagepathfilename-width-height-mode-quality--90)

Example 1: Resize or crop an image and get the newly generated image's web path.

```

```

Example 2: Use an HTML picture element to display a webp version of the image, if supported by the browser.

```

```

The getImagePath() method has six parameters, the first four of which are required:

1. File Name *(string)* The fully qualified name of image file. The file must reside in your app's `public` directory. You'll need to grant write access by the web server to the `public` directory and its children.
2. Width *(integer)* Desired width of the image.
3. Height *(integer)* Desired height of the image.
4. Output Mode *(string)* The output mode. Options are:

    1. **crop** - Crop from the vertical middle.
    2. **crop-top** - Crop from the top.
    3. **crop-bottom** - Crop from the bottom.
    4. **fit** - Fit while maintaining aspect ratio.
    5. **fit-x** - Fit to the given width while maintaining aspect ratio.
    6. **fit-y** - Fit to the given height while maintaining aspect ratio.
5. Image Quality - *(integer, 0 - 100)* Default value is 90.
6. Format - *(string)* Convert the image to the given format/extension, e.g. "webp";

---

### getUniqueFilename($filename, $destination)

[](#getuniquefilenamefilename-destination)

Generate a unique file name within a destination directory — uses the original file name as the basis for the new file name.

```
