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

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

wiejakp/image-crop
==================

Image cropping helper for PHP.

v1.0.7(6y ago)113.1k1MITPHPPHP &gt;=7.2.0CI failing

Since Aug 19Pushed 4y agoCompare

[ Source](https://github.com/wiejakp/ImageCrop)[ Packagist](https://packagist.org/packages/wiejakp/image-crop)[ Docs](https://github.com/wiejakp/ImageCrop)[ RSS](/packages/wiejakp-image-crop/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (6)Dependencies (9)Versions (10)Used By (0)

wiejakp/ImageCrop
=================

[](#wiejakpimagecrop)

[![Source Code](https://camo.githubusercontent.com/e842f842d877bb252b0d15661289c534da0db8aa065729a1c5fefb605c6a725f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736f757263652d7769656a616b70253246696d6167652d2d63726f702d627269676874677265656e)](https://github.com/wiejakp/ImageCrop)[![Latest Version](https://camo.githubusercontent.com/f3e656a06d790aca3bc21fa885194d151e37210220dd660a88b17000834e9f52/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7769656a616b702f696d6167652d63726f702e7376673f7374796c653d666c61742d737175617265266c6162656c3d72656c65617365)](https://packagist.org/packages/wiejakp/ImageCrop)[![Software License](https://camo.githubusercontent.com/1a61d40387a5dd1ce3e0603af09e9913706ea14344a7dd3faca282e3929ee5d3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7769656a616b702f696d6167652d63726f702e7376673f7374796c653d666c61742d737175617265)](https://github.com/wiejakp/ImageCrop/blob/master/LICENSE)[![PHP Version](https://camo.githubusercontent.com/f020d16e8142fe53d0af22256c8c9d55c27523a84aef8e2cda069e96a93c9e2a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7769656a616b702f696d6167652d63726f702e7376673f7374796c653d666c61742d737175617265)](https://php.net)[![Build Status](https://camo.githubusercontent.com/3bcfc253187c6e070ad2ec9a27b884f362514a0d849fb02957532ef914fe755b/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7769656a616b702f696d61676563726f703f7374796c653d666c61742d737175617265)](https://travis-ci.org/wiejakp/ImageCrop)[![Coverage Status](https://camo.githubusercontent.com/31e852a9fa961c71902adab544ce55e124555f411d8ce5190e8714b29ce85a52/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6769746875622f7769656a616b702f496d61676543726f70)](https://coveralls.io/github/wiejakp/ImageCrop?branch=master)[![Total Downloads](https://camo.githubusercontent.com/4d332aabf0b18dad41063648afc6ab4192deefd28f4a3d51ee69c2486702c6fd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7769656a616b702f696d6167652d63726f702e7376673f7374796c653d666c61742d73717561726526636f6c6f72423d6d656469756d76696f6c6574726564)](https://packagist.org/packages/wiejakp/image-crop)

This project adheres to a [Contributor Code of Conduct](https://github.com/wiejakp/ImageCrop/blob/master/.github/CODE_OF_CONDUCT.md). By participating in this project and its community, you are expected to uphold this code.

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

[](#installation)

The preferred method of installation is via [Composer](https://getcomposer.org/). Run the following command to install the package and add it as a requirement to your project's `composer.json`:

```
composer require wiejakp/image-crop
```

Basic Usage
-----------

[](#basic-usage)

```
$imagePath = 'image.jpeg';

$imageCrop = (new ImageCrop())
   ->setReader(JPEGReader::class)
   ->setWriter(JPEGWriter::class);

// load resource into a reader
$imageCrop->getReader()->loadFromPath($imagePath);

// perform cropping actions
$imageCrop->crop();

// skip images that appear to be empty
if (false === $imageCrop->isEmpty()) {

   // save cropped image to the drive
   $imageCrop->getWriter()->write();

   // do stuff with $imageCrop->getData() or $imageCrop->getDataUri()
   $anchor = \sprintf('anchor', $imageCrop->getDataUri());
   ...
}
```

Reader And Writers
------------------

[](#reader-and-writers)

You can mix nad match what image resource is being loaded and what image resource is being generated out.

##### BMP Reader And Writer

[](#bmp-reader-and-writer)

```
$imageCrop = (new ImageCrop())
   ->setReader(BMPReader::class)
   ->setWriter(BMPWriter::class);
```

##### GIF Reader And Writer

[](#gif-reader-and-writer)

```
$imageCrop = (new ImageCrop())
   ->setReader(GIFReader::class)
   ->setWriter(GIFWriter::class);
```

##### JPEG Reader And Writer

[](#jpeg-reader-and-writer)

```
$imageCrop = (new ImageCrop())
   ->setReader(JPEGReader::class)
   ->setWriter(JPEGWriter::class);
```

##### PNG Reader And Writer

[](#png-reader-and-writer)

```
$imageCrop = (new ImageCrop())
   ->setReader(PNGReader::class)
   ->setWriter(PNGWriter::class);
```

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

[](#documentation)

Check out the [documentation website](https://wiejakp.github.io/ImageCrop/) for detailed information and code examples.

Contributing
------------

[](#contributing)

Contributions are welcome! Please read [CONTRIBUTING](https://github.com/wiejakp/ImageCrop/blob/master/.github/CONTRIBUTING.md) for details.

Copyright and License
---------------------

[](#copyright-and-license)

The wiejakp/ImageCrop library is copyright © [Przemek Wiejak](https://www.wiejak.app)and licensed for use under the MIT License (MIT). Please see [LICENSE](https://github.com/wiejakp/ImageCrop/blob/master/LICENSE) for more information.

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Recently: every ~179 days

Total

9

Last Release

1770d ago

PHP version history (2 changes)v1.0PHP &gt;=7.3.0

v1.0.2PHP &gt;=7.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ccb9f721528b7e752bf977365a1881f9698c2683b4238dd7e18e4418b283978?d=identicon)[wiejakp](/maintainers/wiejakp)

---

Top Contributors

[![wiejakp](https://avatars.githubusercontent.com/u/22645549?v=4)](https://github.com/wiejakp "wiejakp (75 commits)")

---

Tags

image-processinglibraryphpphpimagelibrary

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[lciolecki/php-image-optimizer

PHP image file optimizer (uses https://github.com/bensquire/php-image-optim)

347.4k](/packages/lciolecki-php-image-optimizer)

PHPackages © 2026

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