PHPackages                             jessyledama/kompressor - 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. jessyledama/kompressor

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

jessyledama/kompressor
======================

Lossless-style image compressor for Laravel

v0.0.3(5mo ago)03MITPHPPHP &gt;=8.1

Since Nov 16Pushed 5mo agoCompare

[ Source](https://github.com/JessyLedama/kompressor)[ Packagist](https://packagist.org/packages/jessyledama/kompressor)[ RSS](/packages/jessyledama-kompressor/feed)WikiDiscussions master Synced 1mo ago

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

Kompressor
==========

[](#kompressor)

### A lightweight Laravel image compression library

[](#a-lightweight-laravel-image-compression-library)

Kompressor is a Laravel-ready package that compresses uploaded images using **Intervention Image** and **Spatie Image Optimizer**, with automatic fallback between `imagick` and `gd`. The system will prefer `imagic`. If it is not installed, the system will attempt to install it. If installation fails, it will fallback to `gd`.

It provides an easy, fluent API:

```
$compressed = Kompressor::compress($request->file('image'));

```

---

Features
--------

[](#features)

- Automatic driver selection (`imagick → gd`)
- Compress images to a target max size (KB)
- Optimizes using external binaries when available
- Stores original + compressed versions
- Laravel Storage-ready
- Zero configuration required (auto-publishes config)

---

Installation
============

[](#installation)

### Install via Composer

[](#install-via-composer)

```
composer require jessyledama/kompressor

```

---

Dependencies
============

[](#dependencies)

Kompressor depends on these packages:

### Laravel packages (installed automatically)

[](#laravel-packages-installed-automatically)

PackagePurpose**intervention/image**Image manipulation (GD/Imagick)**spatie/image-optimizer**Lossless optimizationThese will be installed automatically. If they are not, run:

```
composer require intervention/image spatie/image-optimizer

```

---

System Dependencies
===================

[](#system-dependencies)

Spatie/ImageOptimizer uses external binaries (**optional** but **highly recommended**) for best compression speed &amp; quality.

### Ubuntu / Debian

[](#ubuntu--debian)

```
sudo apt install jpegoptim optipng pngquant gifsicle webp

```

### CentOS / AlmaLinux

[](#centos--almalinux)

```
sudo yum install epel-release
sudo yum install jpegoptim optipng pngquant gifsicle libwebp-tools

```

### macOS (Homebrew)

[](#macos-homebrew)

```
brew install jpegoptim optipng pngquant gifsicle webp

```

If these tools are missing, Kompressor still works (slower, purely PHP).

---

Publish Config (optional)
=========================

[](#publish-config-optional)

If you want to customize the directories or max allowed size:

```
php artisan vendor:publish --tag=kompressor-config

```

This creates:

```
config/kompressor.php

```

Example:

```
return [
    'original_path'   => 'original-images',
    'compressed_path' => 'compressed-images',
    'max_kb'          => 300, // target size in KB
];

```

---

Usage
=====

[](#usage)

### Basic Example (Controller)

[](#basic-example-controller)

```
use Kompressor;
use Illuminate\Http\Request;

public function store(Request $request)
{
    $validated = $request->validate([
        'image' => ['required', 'mimes:jpg,jpeg,png,gif'],
    ]);

    $compressed = Kompressor::compress($request->file('image'));

    // Example return:
    [
        "original" => "original-images/abc123.jpg",
        "compressed" => "compressed-images/compressed_abc123.jpg",
        "final_size_kb" => 152,
        "driver_used" => "imagick",
        "compression_time_seconds" => $elapsed
    ]

    $path = $compressed['compressed'];

    // Save to DB, etc...
}

```

---

Returned Data Structure
=======================

[](#returned-data-structure)

Kompressor returns an array:

```
[
    'original'       => 'original-images/filename.jpg',
    'compressed'     => 'compressed-images/compressed_filename.jpg',
    'final_size_kb'  => 120.45,
    'driver_used'    => 'imagick',
    'compression_time_seconds' => $elapsed
]

```

---

Using in Blade
==============

[](#using-in-blade)

```

```

---

Custom Max Size
===============

[](#custom-max-size)

Edit `config/kompressor.php`:

```
'max_kb' => 200,

```

---

Driver Fallback Logic
=====================

[](#driver-fallback-logic)

Kompressor checks in order:

StateAction**imagick installed**Uses Imagick (fastest &amp; cleanest)**imagick missing**Logs warning + uses GD---

Development Instructions
========================

[](#development-instructions)

Clone the repo:

```
git clone https://github.com/jessyledama/kompressor.git

```

Install dependencies:

```
composer install

```

---

License
=======

[](#license)

This package is open-source software licensed under the **MIT License**.

---

Contributions
=============

[](#contributions)

Pull requests and issues are welcome!

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance70

Regular maintenance activity

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

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 ~3 days

Total

3

Last Release

171d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/549178d842a122413216475a94d9ddf5d7a16ae8377fd0f630608f36a6e2b6be?d=identicon)[JessyLedama](/maintainers/JessyLedama)

---

Top Contributors

[![JessyLedama](https://avatars.githubusercontent.com/u/16636809?v=4)](https://github.com/JessyLedama "JessyLedama (8 commits)")

---

Tags

image-compressionimage-optimizationimage-processinglaravelphpphp-image-processor

### Embed Badge

![Health badge](/badges/jessyledama-kompressor/health.svg)

```
[![Health](https://phpackages.com/badges/jessyledama-kompressor/health.svg)](https://phpackages.com/packages/jessyledama-kompressor)
```

###  Alternatives

[spatie/image

Manipulate images with an expressive API

1.4k54.4M138](/packages/spatie-image)[league/glide

Wonderfully easy on-demand image manipulation library with an HTTP based API.

2.6k51.2M116](/packages/league-glide)[spatie/laravel-image-optimizer

Optimize images in your Laravel app

1.3k6.5M43](/packages/spatie-laravel-image-optimizer)[jenssegers/imagehash

Perceptual image hashing for PHP

2.1k2.2M5](/packages/jenssegers-imagehash)[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)

PHPackages © 2026

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