PHPackages                             croppy/croppy - 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. croppy/croppy

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

croppy/croppy
=============

PHP Framework for image manipulation (.jpg, .jpeg, .png, .gif, .webp)

1.3(3y ago)6150MITPHPPHP &gt;=8.0.0

Since Aug 14Pushed 3y ago2 watchersCompare

[ Source](https://github.com/armin-runggaldier/croppy)[ Packagist](https://packagist.org/packages/croppy/croppy)[ RSS](/packages/croppy-croppy/feed)WikiDiscussions master Synced today

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

[![Croppy](images/logo.svg)](images/logo.svg)

Croppy - PHP Framework for image manipulation
=============================================

[](#croppy---php-framework-for-image-manipulation)

Version: 1.3
PHP Version: php &gt;= 8.0

Features
--------

[](#features)

- image resize
- image crop
- extend image area
- image conversion
- supported formats: .jpeg, .jpg, .png, .gif, .webp
- image quality management
- image save to filesystem or output
- designed for PHP &gt;= 8.1

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

[](#installation)

Croppy is actually available trough [Composer](https://getcomposer.org) (recommended) or direct download.

To use [Composer](https://getcomposer.org), just add this line to your `composer.json` file:

```
"croppy/croppy": "~1.1"
```

and run the follow command:

```
composer install
```

You can also run the follow command in the terminal (you must be in the project directory):

```
composer require croppy/croppy
```

Usage
-----

[](#usage)

**Basic usage:**

```
use Croppy\Croppy\Croppy;
use Croppy\Croppy\Exception;

require 'path/to/src/Croppy.php';
require 'path/to/src/Exception.php';

$croppy = new Croppy();
$croppy->setSourcePath(__DIR__.'/path/to/image.jpg');
$croppy->setJpegQuality(60);
$croppy->resize(700, 700, false); // width, height, crop
$croppy->save(__DIR__.'/path/to/destination.jpg');
```

**Resize, crop and output:**

```
use Croppy\Croppy\Croppy;
use Croppy\Croppy\Exception;

require 'path/to/src/Croppy.php';
require 'path/to/src/Exception.php';

$croppy = new Croppy();
$croppy->setSourcePath(__DIR__.'/path/to/image.png');
$croppy->setPngCompression(6);
// set crop position x, y
$croppy->setCropPosition($croppy::CROPCENTER, $croppy::CROPSTART); // $croppy::CROPSTART | $croppy::CROPCENTER | $croppy::CROPEND
// set background color
$croppy->setBackground(255, 255, 255, 100); // R, G, B, opacity
$croppy->resize(700, 700, true); // width, height, crop
$croppy->output();

// get path of input file
echo $croppy->getSourcePath();
```

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

[](#documentation)

**setSourcePath** `(string $sourcePath) : void`
Defines the path of the source image, can be relative or absolute

**setJpegQuality** `(int $quality = 80) : void`
Defines quality for JPEG images (0 - 100), 100 best quality

**setWebpQuality** `(int $quality = 80) : void`
Defines quality for WEBP images (0 - 100), 100 best quality

**setPngCompression** `(int $compression = 6) : void`
Defines quality for PNG images (0 - 9), 0 means no compression

**setUpScaleAllowed** `(bool $upScaleAllowed = false) : void`
Deinfes if images should be scaled up (distort image), default is false

**getSourcePath** `() : string`
Returns the path to the source image. It could return a relative or absolute path (depends on input)

**setCropPosition** `($cropAlignmentX = Croppy::CROPCENTER, $cropAlignmentY = Croppy::CROPCENTER) : void`
Defines the crop position of the image. `$crop` flag must be set to true.
$cropAlignmentX defines the horizontal alignment, $cropAlignmentY defines the vertical alignment. Possible values: Croppy::CROPSTART, Croppy::CROPCENTER, Croppy::CROPEND

**setBackground** `($backgroundColorR, $backgroundColorB, $backgroundColorG, $opacity = 100) : void`
Set background color, which is always set in `resize` and `extend` method. Actually Croppy only supports RGB. `$opacity` defines the opacity of the background color (100 is complete transparent).

**resize** `(float $destinationWidth, float $destinationHeight, bool $crop = false) : bool`
Resize image to the given `$destinationWidth` and `$destinationHeight`. If `$crop` is set to true, the image will be cropped. If `$crop` is set to false, the image will be adjusted (max width and max height).

**extend** `(float $destinationWidth, float $destinationHeight) : bool`
Extends image area and fill background with `$backgroundColor`. Could also used for crop image without resize.

**save** `($destinationPath, $convertType = false) : bool`
Writes the generated image to the defined `$destinationPath`.
`$convertType` enables the conversion of the image type. The destination image type will be identify from the filename in `$destinationPath` (ex. path/to/image.webp will convert the image to WEBP). Return true on success or false on failure.

**output** `($convertType = false) : void`
Streams the image direct to output and set `Content-Type` header.
`$convertType` enables the conversion of the image type. The destination image type will be identify from the filename in `$destinationPath` (ex. path/to/image.webp will convert the image to WEBP). Return true on success or false on failure.

Planned features for further releases:
--------------------------------------

[](#planned-features-for-further-releases)

- image ratio resize

Changelog version 1.3 (15.11.2022):
-----------------------------------

[](#changelog-version-13-15112022)

- Support for PHP Version 8
- minor bugfixes for `$upScaleAllowed` property

Changelog version 1.2 (31.12.2020):
-----------------------------------

[](#changelog-version-12-31122020)

- image upscale definiton
- extend image area and fill with background color
- image type conversion (for example .png to .jpg)

Changelog version 1.1 (19.09.2020):
-----------------------------------

[](#changelog-version-11-19092020)

- image quality settings (jpeg, png and webp)

If you are missing a feature, please create a pull request :)

Made with ❤ in *South Tyrol* by **Armin Runggaldier**

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 94.2% 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 ~274 days

Total

4

Last Release

1325d ago

PHP version history (2 changes)1.0PHP &gt;=5.6.0

1.3PHP &gt;=8.0.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/62376688?v=4)[Armin Runggaldier](/maintainers/armin-runggaldier)[@armin-runggaldier](https://github.com/armin-runggaldier)

---

Top Contributors

[![armin-runggaldier](https://avatars.githubusercontent.com/u/62376688?v=4)](https://github.com/armin-runggaldier "armin-runggaldier (49 commits)")[![armin-gardenanet](https://avatars.githubusercontent.com/u/85606805?v=4)](https://github.com/armin-gardenanet "armin-gardenanet (3 commits)")

---

Tags

composercropcrop-imageimagemanipulationphpresizeresize-images

### Embed Badge

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

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

###  Alternatives

[char0n/ffmpeg-php

PHP wrapper for FFmpeg application

495240.6k1](/packages/char0n-ffmpeg-php)[goat1000/svggraph

Generates SVG graphs

135911.1k3](/packages/goat1000-svggraph)[gravatarphp/gravatar

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

16653.6k2](/packages/gravatarphp-gravatar)[rsoury/wp-imgix

Rewrites WordPress image URLs to use ImgIX

167.2k](/packages/rsoury-wp-imgix)

PHPackages © 2026

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