digitalcorehub/tinypng-laravel

Tinypng Laravel Package

v1.0.0 2024-11-17 16:55 UTC

This package is not auto-updated.

Last update: 2025-05-05 17:34:19 UTC


README

tinypng-laravel is a Laravel package that provides an easy and seamless way to integrate the TinyPNG API into your Laravel application. This package allows you to compress, optimize, and resize images programmatically, ensuring faster load times and reduced storage usage.

Installation

You can install the package via composer:

composer require digitalcorehub/tinypng-laravel

You can publish the config file with:

php artisan vendor:publish // select TinypngLaravelServiceProvider

This is the contents of the published config file:

return [
      'api_key' => env('TINYPNG_API_KEY'),
];

Usage

use DigitalCoreHub\TinypngLaravel\Facades\TinypngLaravel;

TinypngLaravel::compressFromUrl("https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png", $outputPath);

TinypngLaravel::compressFromFile($inputPath, $outputPath);

TinypngLaravel::compressFromBuffer("base64", $outputPath);

TinypngLaravel::resize($inputPath, $outputPath, $options);

API Reference

Please see API Reference for details.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.