Skip to content

Commit

Permalink
Merge pull request #2 from ucraft-com/feature/implement-new-factory-m…
Browse files Browse the repository at this point in the history
…ethod

Feature/implement new factory method
  • Loading branch information
tiko-star authored Aug 8, 2024
2 parents 8c675f3 + b4a0806 commit fba7d51
Show file tree
Hide file tree
Showing 24 changed files with 752 additions and 607 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Thumbnail Generator is a versatile Laravel package designed to create and manage
## Features

- **Multiple File Type Support**: Generate thumbnails from images (JPEG, PNG, GIF), videos, audios, documents, and PDF files.
- **WebP Support**: Generate WebP thumbnails for better compression and faster load times.
- **Customizable Dimensions**: Specify the width and height of the thumbnails.
- **Quality Control**: Adjust the quality of the generated thumbnails to balance between size and visual fidelity.
- **Aspect Ratio Maintenance**: Automatically maintain the aspect ratio of the original media.
Expand All @@ -30,5 +31,20 @@ php artisan vendor:publish --provider="Uc\ThumbnailGenerator\ThumbnailGeneratorS
```php
use Uc\ThumbnailGenerator\ThumbnailGeneratorFactory;

$gen = ThumbnailGeneratorFactory::createImageThumbnailGenerator();
['frameContent' => $content, 'webPContent' => $webP] = $gen->generate($file, 200, 200);
$factory = new ThumbnailGeneratorFactory(...);
$gen = $factory->createImageThumbnailGenerator();
$content = $gen->generate($file, 200, 200);
```
#### WebP Thumbnails
To generate WebP thumbnails, use the makeWebPAware method to decorate the ThumbnailGenerator instance:

```php
use Uc\ThumbnailGenerator\ThumbnailGeneratorFactory;

$factory = new ThumbnailGeneratorFactory(...);
$gen = $factory->createImageThumbnailGenerator();
$webPGen = $factory->makeWebPAware($gen);

// Generate a WebP thumbnail using a decorated instance
[$content, $webPContent] = $webPGen->generate($file, 200, 200);
```
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"require-dev": {
"orchestra/testbench": "8.24.0",
"phpunit/phpunit": "9.6.x-dev"
"phpunit/phpunit": "^10.5"
},
"extra": {
"laravel": {
Expand Down
Loading

0 comments on commit fba7d51

Please sign in to comment.