Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gnahotelsolutions/image-cacher
🖼️ Generate resized versions of an image in order to optimize transfer data consumption.
https://github.com/gnahotelsolutions/image-cacher
cache hacktoberfest image package php webp
Last synced: 1 day ago
JSON representation
🖼️ Generate resized versions of an image in order to optimize transfer data consumption.
- Host: GitHub
- URL: https://github.com/gnahotelsolutions/image-cacher
- Owner: gnahotelsolutions
- License: mit
- Created: 2020-02-20T10:40:16.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-09-12T14:23:49.000Z (2 months ago)
- Last Synced: 2024-09-14T00:08:36.855Z (2 months ago)
- Topics: cache, hacktoberfest, image, package, php, webp
- Language: PHP
- Homepage:
- Size: 720 KB
- Stars: 6
- Watchers: 6
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Create smaller versions of the same image
[![Latest Version on Packagist](https://img.shields.io/packagist/v/gnahotelsolutions/image-cacher.svg?style=flat-square)](https://packagist.org/packages/gnahotelsolutions/image-cacher)
![Build status](https://github.com/gnahotelsolutions/image-cacher/actions/workflows/php.yml/badge.svg)
[![Quality Score](https://img.shields.io/scrutinizer/g/gnahotelsolutions/image-cacher.svg?style=flat-square)](https://scrutinizer-ci.com/g/gnahotelsolutions/image-cacher)
[![Total Downloads](https://img.shields.io/packagist/dt/gnahotelsolutions/image-cacher.svg?style=flat-square)](https://packagist.org/packages/gnahotelsolutions/image-cacher)With this package you can create smaller versions of the same image to optimize user's transfer data. What's the point of downloading a 3000x3000 image on a 200x200 thumbnail? This package is very helpful when dealing with [responsive images](https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images)
## Installation
You can install the package via composer:
```bash
composer require gnahotelsolutions/image-cacher
```## Usage
```php
use GNAHotelSolutions\ImageCacher\Cacher;
use GNAHotelSolutions\ImageCacher\Image;// Image located in public/img/hotel/rooms/double-room.jpg
$image = new Image('hotel/rooms/double-room.jpg', 'img');$resized = (new Cacher())->resize($image, 1920, 1080); // Get a smaller version of the image or the same if the size is smaller.
$cropped = (new Cacher())->crop($image, 1920, 1080); // Get a cropped version of the image.
```### Generating a thumbnail
```php
```### Combining with srcset attribute
```php
```### Using with Laravel
The package comes with a Facade you can use on your Laravel projects. Use the configuration file to tell where the cache path and the images root path are.
First of all, publish the package configuration file:
```
php artisan vendor:publish --provider="GNAHotelSolutions\ImageCacher\Adapters\Laravel\ImageCacherServiceProvider"
```Adapt the `config/image-cacher.php` file variables to your needs. Default ones works well with a standard Laravel app.
```php
```### Testing
``` bash
composer test
```### Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
### Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
## Credits
- [David Llop](https://github.com/lloople)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.