PHPackages                             drzippie/crop - 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. drzippie/crop

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

drzippie/crop
=============

Modern PHP library for intelligent image cropping with multiple algorithms

1.0.0(10mo ago)125BSD-2-ClausePHPPHP &gt;=8.3.0CI passing

Since Jul 15Pushed 10mo agoCompare

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

READMEChangelogDependencies (2)Versions (2)Used By (0)

Crop
====

[](#crop)

[![CI Status](https://github.com/drzippie/crop/workflows/CI/badge.svg)](https://github.com/drzippie/crop/actions)[![PHPStan Level](https://camo.githubusercontent.com/d117944b58da8146f96b4ef7403807610a20eeb3fbcaaaf95157bbcdad1686eb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230382d627269676874677265656e2e737667)](https://phpstan.org/)[![PHP Version](https://camo.githubusercontent.com/89899a77bdce65fc4c3d3423dfacff9c6461066a0b5354dc18d7721c23ba596e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d626c75652e737667)](https://php.net)[![License](https://camo.githubusercontent.com/8a9c57aee1ced6433c0c69ffe923a91987b4e999aa49fc1ae9217e015ec54671/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f64727a69707069652f63726f702e737667)](https://github.com/drzippie/crop/blob/master/LICENCE)[![Latest Stable Version](https://camo.githubusercontent.com/84adc955792388971e70a7f2793f95c7cd626095481ab4fbbbf11f186ca3e263/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64727a69707069652f63726f702e737667)](https://packagist.org/packages/drzippie/crop)[![Total Downloads](https://camo.githubusercontent.com/b7c3b052472efe49d7f2ddfebaf41b9490bbbb83cd74daf49e00e494491842bf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64727a69707069652f63726f702e737667)](https://packagist.org/packages/drzippie/crop)

This is a maintained fork of the original [stojg/crop](https://github.com/stojg/crop) library, which was archived on April 30, 2021. This fork continues development and adds modern improvements.

**Key enhancements in this fork:**

- ✅ Modern PHP 8.3+ compatibility with strict typing
- ✅ Comprehensive test suite with PHPUnit 11+
- ✅ PHPStan level 8 compliance for type safety
- ✅ Modernized dependencies and compatibility
- ✅ Active maintenance and bug fixes

This is a small set of image croppers for automated cropping with intelligent algorithms.

Requirements
------------

[](#requirements)

- PHP 8.3 or higher
- ImageMagick extension with sRGB colorspace (version 6.7.5-5 or higher)

Description
-----------

[](#description)

This project includes three intelligent image cropping algorithms:

### CropCenter

[](#cropcenter)

This is the most basic of cropping techniques:

1. Find the exact center of the image
2. Trim any edges that is bigger than the targetWidth and targetHeight

### CropEntropy

[](#cropentropy)

This class finds the a position in the picture with the most "energy" in it. Energy (or entropy) in images are defined by 'edginess' in the image. For example a image of the sky have low edginess and an image of an anthill has very high edginess.

Energy is in this case calculated like this

1. Take the image and turn it into black and white
2. Run a edge filter so that we're left with only edges.
3. Find a piece in the picture that has the highest entropy (i.e. most edges)
4. Return coordinates that makes sure that this piece of the picture is not cropped 'away'

### CropBalanced

[](#cropbalanced)

Crop balanced is a variant of CropEntropy where I tried to the cropping a bit more balanced.

1. Dividing the image into four equally squares
2. Find the most energetic point per square
3. Finding the images weighted mean interest point for all squares

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use drzippie\crop\{CropCenter, CropEntropy, CropBalanced};

// Center-based cropping (fastest)
$center = new CropCenter($filepath);
$croppedImage = $center->resizeAndCrop($width, $height);
$croppedImage->writeimage('assets/thumbs/cropped-center.jpg');

// Entropy-based cropping (intelligent edge detection)
$entropy = new CropEntropy($filepath);
$croppedImage = $entropy->resizeAndCrop($width, $height);
$croppedImage->writeimage('assets/thumbs/cropped-entropy.jpg');

// Balanced cropping (weighted center of interest)
$balanced = new CropBalanced($filepath);
$croppedImage = $balanced->resizeAndCrop($width, $height);
$croppedImage->writeimage('assets/thumbs/cropped-balanced.jpg');
```

### Advanced Usage

[](#advanced-usage)

```
use drzippie\crop\CropEntropy;

// Create cropper with custom settings
$crop = new CropEntropy();
$crop->setImage($imagickObject)
     ->setFilter(Imagick::FILTER_LANCZOS)
     ->setBlur(0.8)
     ->setAutoOrient(true);

$result = $crop->resizeAndCrop(300, 200);
```

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

[](#installation)

Install via Composer:

```
composer require drzippie/crop
```

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

[](#documentation)

📖 **[Complete Documentation](https://drzippie.github.io/crop/)** - GitHub Pages with full API reference and examples

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance54

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

307d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/974d90b7a228585699de6a04009de8d3a1398a8e88f3ce558c9566abeee025e1?d=identicon)[DrZippie](/maintainers/DrZippie)

---

Top Contributors

[![jdeniau](https://avatars.githubusercontent.com/u/1398469?v=4)](https://github.com/jdeniau "jdeniau (27 commits)")[![drzippie](https://avatars.githubusercontent.com/u/239421?v=4)](https://github.com/drzippie "drzippie (16 commits)")[![nmcquay](https://avatars.githubusercontent.com/u/79750?v=4)](https://github.com/nmcquay "nmcquay (3 commits)")[![CheeseSucker](https://avatars.githubusercontent.com/u/1095139?v=4)](https://github.com/CheeseSucker "CheeseSucker (2 commits)")[![christiandavilakoobin](https://avatars.githubusercontent.com/u/46561103?v=4)](https://github.com/christiandavilakoobin "christiandavilakoobin (2 commits)")[![mcuadros](https://avatars.githubusercontent.com/u/1573114?v=4)](https://github.com/mcuadros "mcuadros (2 commits)")[![themightychris](https://avatars.githubusercontent.com/u/458494?v=4)](https://github.com/themightychris "themightychris (2 commits)")[![willjosefi](https://avatars.githubusercontent.com/u/222083?v=4)](https://github.com/willjosefi "willjosefi (1 commits)")[![wapmorgan](https://avatars.githubusercontent.com/u/6000618?v=4)](https://github.com/wapmorgan "wapmorgan (1 commits)")[![ecaron](https://avatars.githubusercontent.com/u/70704?v=4)](https://github.com/ecaron "ecaron (1 commits)")

---

Tags

phpimagecropentropy

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/drzippie-crop/health.svg)

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

###  Alternatives

[stefangabos/zebra_image

A single-file, lightweight PHP library designed for efficient image manipulation featuring methods for modifying images and applying filters

141110.4k6](/packages/stefangabos-zebra-image)[somehow-digital/typo3-media-processing

Media Processing

101.1k](/packages/somehow-digital-typo3-media-processing)

PHPackages © 2026

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