Skip to content

This PHP package provides a comprehensive solution for generating thumbnails from various file types, including images, videos, PDF documents, and audio files.

Notifications You must be signed in to change notification settings

ucraft-com/thumbnail-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Thumbnail Generator for Laravel

Thumbnail Generator is a versatile Laravel package designed to create and manage thumbnails from various file types, including images, videos, audios, documents, and PDF files. This package provides a straightforward API to generate thumbnails and customize their dimensions and quality.

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.

Requirements

  • PHP: 8.1 or higher
  • Imagick PHP extension: You need to have the Imagick PHP extension installed and enabled to use the ThumbnailGenerator package.

Installation

You can install the package via Composer:

composer require ucraft-com/thumbnail-generator

php artisan vendor:publish --provider="Uc\ThumbnailGenerator\ThumbnailGeneratorServiceProvider"

Basic Usage

Images

use Uc\ThumbnailGenerator\ThumbnailGeneratorFactory;

$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:

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);

About

This PHP package provides a comprehensive solution for generating thumbnails from various file types, including images, videos, PDF documents, and audio files.

Resources

Stars

Watchers

Forks

Packages

No packages published