PHPackages                             ronpearl/image-compress - 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. ronpearl/image-compress

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

ronpearl/image-compress
=======================

Allows you to utilize Image Magick in order to compress images as needed.

v1.0.2(9y ago)018MITPHPPHP &gt;=5.5.38

Since Jun 30Pushed 9y ago1 watchersCompare

[ Source](https://github.com/ronpearl/ImageCompress)[ Packagist](https://packagist.org/packages/ronpearl/image-compress)[ RSS](/packages/ronpearl-image-compress/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)DependenciesVersions (2)Used By (0)

ronpearl/image-compress
=======================

[](#ronpearlimage-compress)

Symfony package that will allow you to compress image files using Image Magick

**NOTE:** This is my first attempt at creating a package for packagist. Please feel free to submit any questions or concerns so I can address them accordingly.

Getting Started
---------------

[](#getting-started)

This program requires that you have PHP version 5.6.38 or higher and have Image Magick installed. You would need to confirm this in your phpinfo file, it would be listed under the section called "imagick".

It also assumes that you are using composer and you have a composer.json file already. You can either add this to your require section:

```
    {
        "require": {
           "rpearl/image-compress": ">1.0.0"
        }
    }

```

or you can run the composer command to install the package:

```
composer require pearl/image-compress

```

and then run:

```
composer update

```

Usage
-----

[](#usage)

Once the package is installed, you can use it within your classes. Add the statement:

```
use ImageCompress\Compress;

```

This will then allow you to call the Compress class and start using the program. Here is a sample using an image URL:

```
$imageCompress = new Compress();
$compressionResults = $imageCompress->doImageCompression( "http://location/of/imagefile.jpg", FALSE);
dump( $compressionResults );

```

When creating an instance of the Compress() class, you can pass some variables to customize your compressions. The first variable would be an array of trusted domains (google.com, bing.com, etc...). This way you can limit what domain(s) any compressed image can originate from. The second and third are the compression values based upon Image Magick compression settings. They are based upon images that are either smaller than 800px wide or larger. Both have their own compression values.

Here is a line showing the construction method for Compress():

```
public function __construct($trustedDomains = [], $smCompressionVal = 75, $lrgCompressionVal = 35)

```

Once this is set, you can call the doImageCompression() method. This is what allows you to one-by-one compress and receive values back for the final compressed file. The variables are ($originalFileUrlOrPath, $localFile = true, and $getBase64 = false).

$originalFileUrlOrPath is the image URL or the local path to the image.

$localFile defaults to true, but this sets whether the image is from a URL or from a local file.

$getBase64 defaults to false, but you can set it to true if you would like to get the base64 results of the compressed file as well.

Resulting Image(s)
------------------

[](#resulting-images)

The final images will be saved within your "web" directory under the folder "imageCompress". These folders will be created after your first run of the program. There will be 2 other folders under that: compressed and originals. The originals will temporarily hold the original files, and then the compressed images will be saved into the compressed folder for use later.

Example
-------

[](#example)

Youc an view the example.php file for a raw usage of the package.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

3287d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12748475?v=4)[Ron Pearl](/maintainers/ronpearl)[@ronpearl](https://github.com/ronpearl)

---

Top Contributors

[![ronpearl](https://avatars.githubusercontent.com/u/12748475?v=4)](https://github.com/ronpearl "ronpearl (1 commits)")

### Embed Badge

![Health badge](/badges/ronpearl-image-compress/health.svg)

```
[![Health](https://phpackages.com/badges/ronpearl-image-compress/health.svg)](https://phpackages.com/packages/ronpearl-image-compress)
```

###  Alternatives

[goat1000/svggraph

Generates SVG graphs

133890.0k3](/packages/goat1000-svggraph)[imagekit/imagekit

PHP library for Imagekit

46877.3k10](/packages/imagekit-imagekit)[gravatarphp/gravatar

Gravatar URL builder which is most commonly called as a Gravatar library

12644.1k2](/packages/gravatarphp-gravatar)

PHPackages © 2026

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