codebuds/webp-converter
Lightweight PHP 7.4+ WebP converter for Symfony apps. Convert JPEG/PNG/GIF/BMP to WebP from a file path or Symfony File, with options like quality, saveFile, force, output naming/path, and clear exceptions for invalid types or options.
Pros:
Cons:
Storage facade) and request handling (e.g., uploaded files).dispatch()) to offload conversion to background jobs.File class, but Laravel’s Illuminate\Http\UploadedFile or SplFileInfo can be passed via adapters.LONGBLOB), but converted images can be stored in storage/app/public.saveFile=true and force=false (file exists).uniqueFilename() option or use Laravel’s Str::uuid() for filenames.try-catch and log detailed errors with context (e.g., file path, user ID).File class with Laravel’s Storage facade or UploadedFile:
use Illuminate\Http\UploadedFile;
use CodeBuds\WebPConverter\WebPConverter;
$uploadedFile = $request->file('image');
$result = WebPConverter::createWebpImage($uploadedFile->getRealPath());
$path = storage_path('app/public/images/original.jpg');
$webpPath = storage_path('app/public/webp/converted.webp');
WebPConverter::createWebpImage($path, [
'saveFile' => true,
'savePath' => storage_path('app/public/webp'),
'filename' => 'converted_' . $request->user()->id,
]);
$this->app->bind(WebPConverter::class, function () {
return new WebPConverter(); // Hypothetical if made non-static
});
facade(WebPConverter::class, WebPConverterFacade::class);
class ConvertToWebPJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public function handle() {
WebPConverter::createWebPImage($this->filePath, $this->options);
}
}
Creating event for Image model).filesystem.php to use S3/CDN for WebP assets.Cache-Control: public, max-age=31536000) for converted files.extension_loaded('gd')).imagewebp).League\Flysystem).exec() or queues).php.ini: extension=gd.composer require codebuds/webp-converter.app/Services/WebPConverterService.php).filesystem.php for WebP storage.storage/app not writable).Log::error).How can I help you explore Laravel packages today?