{"id":20980771,"url":"https://github.com/gnahotelsolutions/image-cacher","last_synced_at":"2025-05-14T15:30:51.147Z","repository":{"id":62511443,"uuid":"241858118","full_name":"gnahotelsolutions/image-cacher","owner":"gnahotelsolutions","description":"🖼️ Generate resized versions of an image in order to optimize transfer data consumption.","archived":false,"fork":false,"pushed_at":"2025-05-08T13:58:51.000Z","size":1216,"stargazers_count":6,"open_issues_count":2,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-08T14:42:21.329Z","etag":null,"topics":["cache","hacktoberfest","image","package","php","webp"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gnahotelsolutions.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-02-20T10:40:16.000Z","updated_at":"2025-04-14T07:06:01.000Z","dependencies_parsed_at":"2024-09-12T20:37:14.421Z","dependency_job_id":"d175e733-cc69-4ec4-99d0-850abaae09de","html_url":"https://github.com/gnahotelsolutions/image-cacher","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnahotelsolutions%2Fimage-cacher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnahotelsolutions%2Fimage-cacher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnahotelsolutions%2Fimage-cacher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnahotelsolutions%2Fimage-cacher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gnahotelsolutions","download_url":"https://codeload.github.com/gnahotelsolutions/image-cacher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254171608,"owners_count":22026473,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","hacktoberfest","image","package","php","webp"],"created_at":"2024-11-19T05:30:03.889Z","updated_at":"2025-05-14T15:30:50.493Z","avatar_url":"https://github.com/gnahotelsolutions.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Create smaller versions of the same image\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/gnahotelsolutions/image-cacher.svg?style=flat-square)](https://packagist.org/packages/gnahotelsolutions/image-cacher)\n![Build status](https://github.com/gnahotelsolutions/image-cacher/actions/workflows/php.yml/badge.svg)\n[![Quality Score](https://img.shields.io/scrutinizer/g/gnahotelsolutions/image-cacher.svg?style=flat-square)](https://scrutinizer-ci.com/g/gnahotelsolutions/image-cacher)\n[![Total Downloads](https://img.shields.io/packagist/dt/gnahotelsolutions/image-cacher.svg?style=flat-square)](https://packagist.org/packages/gnahotelsolutions/image-cacher)\n\nWith 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)\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require gnahotelsolutions/image-cacher\n```\n\n## Usage\n\n```php\n\nuse GNAHotelSolutions\\ImageCacher\\Cacher;\nuse GNAHotelSolutions\\ImageCacher\\Image;\n\n// Image located in public/img/hotel/rooms/double-room.jpg\n$image = new Image('hotel/rooms/double-room.jpg', 'img');\n\n$resized = (new Cacher())-\u003eresize($image, 1920, 1080); // Get a smaller version of the image or the same if the size is smaller.\n\n$cropped = (new Cacher())-\u003ecrop($image, 1920, 1080); // Get a cropped version of the image.\n```\n\n### Generating a thumbnail\n\n```php\n\u003c?php \n$cacher = new Cacher();\n$image = new Image('hotel/rooms/double-room.jpg', 'img'); \n?\u003e\n\n\u003cimg src=\"\u003c?= $cacher-\u003ecrop($image, 200, 200)-\u003egetOriginalName(); ?\u003e\" class=\"thumbnail\"\u003e\n```\n\n### Combining with srcset attribute\n\n```php\n\u003c?php \n$cacher = new Cacher();\n$image = new Image('hotel/rooms/double-room.jpg', 'img'); \n?\u003e\n\n\u003cimg src=\"\u003c?= $cacher-\u003ecrop($image, 800, 600)-\u003egetOriginalName(); ?\u003e\"\n     srcset=\"\u003c?= $cacher-\u003ecrop($image, 400, 280)-\u003egetOriginalName(); ?\u003e 400w,\n             \u003c?= $cacher-\u003ecrop($image, 800, 600)-\u003egetOriginalName(); ?\u003e 800w\"\n     sizes=\"(max-width: 480px) 400px), 800px\"\n\u003e\n```\n\n### Using with Laravel\n\nThe 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.\n\nFirst of all, publish the package configuration file:\n\n```\nphp artisan vendor:publish --provider=\"GNAHotelSolutions\\ImageCacher\\Adapters\\Laravel\\ImageCacherServiceProvider\"\n```\n\nAdapt the `config/image-cacher.php` file variables to your needs. Default ones works well with a standard Laravel app.\n\n```php\n\u003cimg src=\"{{ ImageCacher::crop('hotel/rooms/double-room.jpg', 800, 600)-\u003egetOriginalName() }}\"\u003e\n```\n\n### Testing\n\n``` bash\ncomposer test\n```\n\n### Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n### Security\n\nIf you discover any security related issues, please email dllop@gnahs.com instead of using the issue tracker.\n\n## Credits\n\n- [David Llop](https://github.com/lloople)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgnahotelsolutions%2Fimage-cacher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgnahotelsolutions%2Fimage-cacher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgnahotelsolutions%2Fimage-cacher/lists"}