PHPackages                             zaherg/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. [API Development](/categories/api)
4. /
5. zaherg/laravel-shortpixel

AbandonedArchivedLibrary[API Development](/categories/api)

zaherg/laravel-shortpixel
=========================

Laravel 5 package for the ShortPixel API

v0.0.4(6y ago)22MITPHPPHP ^7.2

Since Mar 2Pushed 5y ago1 watchersCompare

[ Source](https://github.com/zaherg/laravel-shortpixel)[ Packagist](https://packagist.org/packages/zaherg/laravel-shortpixel)[ RSS](/packages/zaherg-laravel-shortpixel/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (3)Versions (5)Used By (0)

Non-Official Laravel Package for ShortPixel SDK and API
=======================================================

[](#non-official-laravel-package-for-shortpixel-sdk-and-api)

[![Latest Stable Version](https://camo.githubusercontent.com/e59f3305b40da91c83940eecacfbc98610fd62db365cb3779350a6bdfa281e1d/68747470733a2f2f706f7365722e707567782e6f72672f7a61686572672f6c61726176656c2d73686f7274706978656c2f762f737461626c65)](https://packagist.org/packages/zaherg/laravel-shortpixel)[![Latest Unstable Version](https://camo.githubusercontent.com/40f4264ffe5590ee081599d838cb15f816a4262c7f91e47fa6056161611fe1c7/68747470733a2f2f706f7365722e707567782e6f72672f7a61686572672f6c61726176656c2d73686f7274706978656c2f762f756e737461626c65)](https://packagist.org/packages/zaherg/laravel-shortpixel)[![License](https://camo.githubusercontent.com/95ebaa9d2ec0acf39ba5c1a7b130f68cea6db71951eb0b9c813ee2b9bd1fa728/68747470733a2f2f706f7365722e707567782e6f72672f7a61686572672f6c61726176656c2d73686f7274706978656c2f6c6963656e7365)](https://packagist.org/packages/zaherg/laravel-shortpixel)[![composer.lock available](https://camo.githubusercontent.com/24697908149fad829abfed44edd06cd5e81f636b021558e5029fcb95c723327d/68747470733a2f2f706f7365722e707567782e6f72672f7a61686572672f6c61726176656c2d73686f7274706978656c2f636f6d706f7365726c6f636b)](https://packagist.org/packages/zaherg/laravel-shortpixel)

Non-Official Laravel Package for the ShortPixel API. [ShortPixel](https://shortpixel.com) optimizes your images and improves website performance by reducing images size. Read more at .

Documentation
-------------

[](#documentation)

[Go to the documentation for the PHP client](https://github.com/short-pixel-optimizer/shortpixel-php).

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

[](#installation)

Install the API client with Composer. Add this to your `composer.json`:

```
{
  "require": {
    "zaherg/laravel-shortpixel": "*"
  }
}
```

Then install with:

```
composer install

```

Get your API Key from

Usage
-----

[](#usage)

Add the API Key to your `.env` file

```
SHORTPIXEL_API_KEY=
```

Then you can use it as the following examples:

```
// Compress with default settings
ShortPixel::fromUrls("https://your.site/img/unoptimized.png")->toFiles("/path/to/save/to");
// Compress with default settings but specifying a different file name
ShortPixel::fromUrls("https://your.site/img/unoptimized.png")->toFiles("/path/to/save/to", "optimized.png");

// Compress with default settings from a local file
ShortPixel::fromFile("/path/to/your/local/unoptimized.png")->toFiles("/path/to/save/to");
// Compress with default settings from several local files
ShortPixel::fromFiles(array("/path/to/your/local/unoptimized1.png", "/path/to/your/local/unoptimized2.png"))->toFiles("/path/to/save/to");

// Compress with a specific compression level: 0 - lossless, 1 - lossy (default), 2 - glossy
ShortPixel::fromFile("/path/to/your/local/unoptimized.png")->optimize(2)->toFiles("/path/to/save/to");

// Compress and resize - image is resized to have the either width equal to specified or height equal to specified
//   but not LESS (with settings below, a 300x200 image will be resized to 150x100)
ShortPixel::fromUrls("https://your.site/img/unoptimized.png")->resize(100, 100)->toFiles("/path/to/save/to");
// Compress and resize - have the either width equal to specified or height equal to specified
//   but not MORE (with settings below, a 300x200 image will be resized to 100x66)
ShortPixel::fromUrls("https://your.site/img/unoptimized.png")->resize(100, 100, true)->toFiles("/path/to/save/to");

// Keep the exif when compressing
ShortPixel::fromUrls("https://your.site/img/unoptimized.png")->keepExif()->toFiles("/path/to/save/to");

// Also generate and save a WebP version of the file - the WebP file will be saved next to the optimized file, with  same basename and .webp extension
ShortPixel::fromUrls("https://your.site/img/unoptimized.png")->generateWebP()->toFiles("/path/to/save/to");

//Compress from a folder - the status of the compressed images is saved in a text file named .shortpixel in each image folder
ShortPixel::ShortPixel::setOptions(["persist_type" => "text"]);
//Each call will optimize up to 10 images from the specified folder and mark in the .shortpixel file.
//It automatically recurses a subfolder when finds it
//Save to the same folder, set wait time to 300 to allow enough time for the images to be processed
$ret = ShortPixel::fromFolder("/path/to/your/local/folder")->wait(300)->toFiles("/path/to/your/local/folder");
//Save to a different folder. CURRENT LIMITATION: When using the text persist type and saving to a different folder, you also need to specify the destination folder as the fourth parameter to fromFolder ( it indicates where the persistence files should be created)
$ret = ShortPixel::fromFolder("/path/to/your/local/folder", 0, array, "/different/path/to/save/to")->wait(300)->toFiles("/different/path/to/save/to");
//use a URL to map the folder to a WEB path in order for our servers to download themselves the images instead of receiving them via POST - faster and less exposed to connection timeouts
$ret = ShortPixel::fromWebFolder("/path/to/your/local/folder", "http://web.path/to/your/local/folder")->wait(300)->toFiles("/path/to/save/to");
//let ShortPixel back-up all your files, before overwriting them (third parameter of toFiles).
$ret = ShortPixel::fromFolder("/path/to/your/local/folder")->wait(300)->toFiles("/path/to/save/to", null, "/back-up/path");
//Recurse only  levels down into the subfolders of the folder ( N == 0 means do not recurse )
$ret = ShortPixel::fromFolder("/path/to/your/local/folder", 0,[], false, ShortPixel::CLIENT_MAX_BODY_SIZE, )->wait(300)->toFiles("/path/to/save/to");

//A simple loop to optimize all images from a folder
$stop = false;
while(!$stop) {
    $ret = ShortPixel::fromFolder("/path/to/your/local/folder")->wait(300)->toFiles("/path/to/save/to");
    if(count($ret->->succeeded) + count($ret->failed) + count($ret->same) + count($ret->pending) == 0) {
        $stop = true;
    }
}

//Get account status and credits info:
$ret = ShortPixel::getClient()->apiStatus(config('shortpixel.key'));
```

License
-------

[](#license)

This software is licensed under the MIT License. [View the license](LICENSE).

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.5% 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 ~50 days

Total

4

Last Release

2477d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ed5edcc08cdb61a7f8e5546ea027060d814a834209434caf34eb5b9ac69dbe64?d=identicon)[zaher](/maintainers/zaher)

---

Top Contributors

[![zaherg](https://avatars.githubusercontent.com/u/27624?v=4)](https://github.com/zaherg "zaherg (23 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (15 commits)")[![dependabot-support](https://avatars.githubusercontent.com/u/112581971?v=4)](https://github.com/dependabot-support "dependabot-support (2 commits)")

---

Tags

apiapi-wrapperimage-optimizationlaravelaravel-5-packagephp-libraryphp7shortpixellaravelimageoptimizationlaravel5integrationshortpixel

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[scottybo/laravel-google-my-business

A package for Laravel which implements the Google My Business API

3360.3k](/packages/scottybo-laravel-google-my-business)[casinelli/laravel-campaignmonitor

A Laravel 5 wrapper for Campaign Monitor

1444.7k](/packages/casinelli-laravel-campaignmonitor)[travoltron/plaid

Laravel specific wrapper for Plaid. Bankdata for developers.

274.8k](/packages/travoltron-plaid)

PHPackages © 2026

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