PHPackages                             hkhasib/laravel-shortpixel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. hkhasib/laravel-shortpixel

ActiveLibrary[Image &amp; Media](/categories/media)

hkhasib/laravel-shortpixel
==========================

Laravel 5+ package for ShortPixel API integration

v0.1.7(7mo ago)020MITPHPPHP &gt;=8.0

Since Apr 10Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/hkhasib/laravel-shortpixel)[ Packagist](https://packagist.org/packages/hkhasib/laravel-shortpixel)[ Docs](https://github.com/hkhasib/laravel-shortpixel)[ RSS](/packages/hkhasib-laravel-shortpixel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Laravel-Shortpixel
==================

[](#laravel-shortpixel)

Laravel 5+ wrapper for ShortPixel API. A forked version of [davidcb/laravel-shortpixel](https://github.com/davidcb/laravel-shortpixel)

Installation
------------

[](#installation)

Install via Composer:

```
composer require hkhasib/laravel-shortpixel

```

If you're using Laravel &gt;= 5.5, you can skip this as this package will be auto-discovered. However, if you want, you can follow these steps for Laravel &lt;=10: Add the service provider to `config/app.php`

```
Hkhasib\LaravelShortPixel\LaravelShortPixelServiceProvider::class,
```

You can register the facade in the `aliases` array in the `config/app.php` file

```
'LaravelShortPixel' => Hkhasib\LaravelShortPixel\Facades\LaravelShortPixel::class,
```

For Laravel &gt;=11, you can optionally follow these steps:

Add the service provider to 'bootstrap/providers.php'

```
    return [
    #other providers
    \Hkhasib\LaravelShortPixel\LaravelShortPixelServiceProvider::class,
];
```

Add the alias to 'bootstrap/app.php'

```
    $middleware->alias([
            #other aliases
           'LaravelShortPixel'=>\Hkhasib\LaravelShortPixel\Facades\LaravelShortPixel::class,
        ]);
```

After adding these things on your laravel app for Laravel &lt;=10 and Laravel &gt;=11, follow these steps:

Publish the config file

```
php artisan vendor:publish --provider="Hkhasib\LaravelShortPixel\LaravelShortPixelServiceProvider"

```

Set your API key on your .env file

```
SHORT_PIXEL_API_KEY=secret

```

Usage
-----

[](#usage)

You can find all the methods in the original [short-pixel-optimizer/shortpixel-php package](https://github.com/short-pixel-optimizer/shortpixel-php) and [davidcb/laravel-shortpixel](https://github.com/davidcb/laravel-shortpixel).

My package is exactly same as David. But, my one automatically generate webp by default. Also, I have added a refresh method.

So, if you want to refresh a previously optimized version of image, you can do it in following way:

```
//optimize with refresh
$result = LaravelShortPixel::fromUrls('https://your.site/img/unoptimized.png', '/path/to/save/to', 'filename.png', $compression_level = 1, $width = 200, $height = 200, $maxDimension = true, $refresh=true]);
```

Just set $refresh = false or ignore it completely as it is false by default if you don't want to refresh.

Alternatively, you can use refreshFromUrls method to refresh the optimized image.

```
$result = LaravelShortPixel::refreshfromUrls('https://your.site/img/unoptimized.png', '/path/to/save/to', 'filename.png', $compression_level = 1, $width = 200, $height = 200, $maxDimension = true
```

fromFiles, fromUrls, fromFolder, refreshFromFiles, refreshFromUrls, refreshFromFolder methods are available in this package.

The usage are same as the original package. Only the refresh methods are added in this package.

The compression\_level, width, height and maxDimension are optional. Compression levels are 0 - loseless, 1 - lossy, 2- glossy. Default compression level for your images is set on the configuration file (lossy is set as default).

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance65

Regular maintenance activity

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~184 days

Total

2

Last Release

214d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4d835cb832835ea14319d1b2a3339a2a9c5c99a40f827d5153afbde26f8f65d7?d=identicon)[hkhasib](/maintainers/hkhasib)

---

Top Contributors

[![hkhasib](https://avatars.githubusercontent.com/u/19726091?v=4)](https://github.com/hkhasib "hkhasib (2 commits)")

---

Tags

laravelimageoptimizationintegrationshortpixel

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hkhasib-laravel-shortpixel/health.svg)

```
[![Health](https://phpackages.com/badges/hkhasib-laravel-shortpixel/health.svg)](https://phpackages.com/packages/hkhasib-laravel-shortpixel)
```

###  Alternatives

[intervention/image-laravel

Laravel Integration of Intervention Image

1496.5M102](/packages/intervention-image-laravel)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[joshembling/image-optimizer

Optimize your Filament images before they reach your database.

111145.4k12](/packages/joshembling-image-optimizer)[danihidayatx/image-optimizer

Optimize your Filament images before they reach your database. Forked from joshembling/image-optimizer for Filament v4 &amp; v5 support.

254.4k](/packages/danihidayatx-image-optimizer)[spescina/imgproxy

An image proxy for Laravel

201.3k](/packages/spescina-imgproxy)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
