dmknvk / laravel-image-optimizer by dmknvk

Images optimization for Google PageSpeed Insights
1,191
11
1
Package Data
Maintainer Username: dmknvk
Maintainer Contact: dmitry.konovalchuk@gmail.com (Dmitry Konovalchuk)
Package Create Date: 2016-11-15
Package Last Update: 2017-12-01
Language: PHP
License: MIT
Last Refreshed: 2024-04-23 03:11:56
Package Statistics
Total Downloads: 1,191
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 11
Total Watchers: 1
Total Forks: 2
Total Open Issues: 0

Laravel Image Optimizer

Packagist License Latest Stable Version Total Downloads

This is a package for Laravel 5 that optimize images for Google PageSpeed Insights requirements.

Requirements

This package uses the following tools in your system:

Installation

Require this package with composer:

composer require dmknvk/laravel-image-optimizer

After updating composer, add the ServiceProvider to the providers array in config/app.php

DmKnvk\LaravelImageOptimizer\ServiceProvider::class,

Copy the package config to your local config with the publish command:

php artisan vendor:publish --provider="DmKnvk\LaravelImageOptimizer\ServiceProvider"

Usage

Set your directories pathes that will be optimized in config/image-optimizer.php

'dirs' => [
  public_path('media'),            // all png/jpeg images in folder public/media will be optimized recursively
  public_path('upload') => [
    'types'     => ['images/png'], // array of mime types, that will be optimized (now supported image/png and image/jpeg)
    'recursive' => false,          // search images only in root directory (public/upload)
  ],
],

Run artisan command (or add to cron) with root priveleges (to avoid problems with permissions)

sudo php artisan image-optimizer:run

All files in your directories will be optimized with max optimization levels (takes some time).