Package Data | |
---|---|
Maintainer Username: | anakadote |
Maintainer Contact: | hello@endif.io (Taylor Collins) |
Package Create Date: | 2015-01-11 |
Package Last Update: | 2023-09-05 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-17 03:04:50 |
Package Statistics | |
---|---|
Total Downloads: | 2,222 |
Monthly Downloads: | 216 |
Daily Downloads: | 3 |
Total Stars: | 6 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 1 |
This Laravel 4 package provides a convenient way of resizing and cropping images.
If you're using Laravel 5, then use this package instead.
Begin by installing this package through Composer. Edit your project's composer.json
file to require anakadote/image-manager
.
"require-dev": {
"anakadote/image-manager": "dev-master"
}
Next, update Composer from the Terminal:
composer update
Next, use artisan to move the package assets to the public directory, also from the Terminal:
php artisan asset:publish anakadote/image-manager
The final step is to add the service provider. Open config/app.php
and add a new item to the providers array.
'Anakadote\ImageManager\ImageManagerServiceProvider'
This package is accessible via a Laravel Facade so to use simply call its methods on the Facade "ImageManager".
Resize or crop an image and get the newly generated image's web path.
<img src="{{ ImageManager::getImagePath( public_path() . '/img/' . $image->filename, 250, 200, 'crop' ) }}" alt="">
The getImagePath() method has five parameters, the first four of which are required:
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.
Width (integer) Desired width of the image.
Height (integer) Desired height of the image.
Output Mode (string) The output mode. Options are:
crop
fit - Fit while maintaining aspect ratio
fit-x - Fit to the given width while maintaining aspect ratio
fit-y - Fit to the given height while maintaining aspect ratio
Image Quality - (integer, 0 - 100) Default value is 90
Delete an image including all resized and/or cropped images generated from it.
<?php
ImageManager::deleteImage( public_path() . '/img/' . $image->filename );
The deleteImage() method has a single parameter which is the fully qualified name of the original image file. This method will recursively delete all generated images from the original image file.