PHPackages                             sayme/simple-image-cropper - 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. sayme/simple-image-cropper

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

sayme/simple-image-cropper
==========================

A light weight php library for cropping and resizing images.

00PHP

Since Mar 11Pushed 8y ago1 watchersCompare

[ Source](https://github.com/sayme/SimpleImageCropper)[ Packagist](https://packagist.org/packages/sayme/simple-image-cropper)[ RSS](/packages/sayme-simple-image-cropper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

SimpleImageCropper
==================

[](#simpleimagecropper)

A light weight php library for cropping and resizing images.

[![Build Status](https://camo.githubusercontent.com/cad2471ba2054ecab1ddbe208afd78cf9cfcc7fc8a27f0486d20499d07ac053d/68747470733a2f2f7472617669732d63692e6f72672f7361796d652f53696d706c65496d61676543726f707065722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/sayme/SimpleImageCropper)

Usage
-----

[](#usage)

### Download and install SimpleImageCropper

[](#download-and-install-simpleimagecropper)

To install SimpleImageCropper run the following command:

```
$ composer require sayme/simple-image-cropper
```

### Initialize

[](#initialize)

Initialize SimpleImageCropper with URL as image source.

```
use SimpleImageCropper\Cropper;

$cropper = new Cropper('http://example.com/your-image.png');
```

Or you can use `$_FILES['filename']['tmp_name']` as source.

```
$cropper = new Cropper($_FILE['filename']['tmp_name']);
```

When initializing the Cropper you will have access to some of the original image meta.

- Image width `$cropper->getWidth()`
- Image height `$cropper->getHeight()`
- Image type `$cropper->getType()`

### Crop and save image

[](#crop-and-save-image)

Cropping the image in center and saving the new image.

```
$width = 150;
$height = 150;
// This will crop the image in center with the new width and height
$cropper->crop($width, $height);

// This will save your new image as mynewimage.png in the current directory
$cropper->save('mynewimage.png');

// You can also set the quality of the image to be saved in the second parameter.
// The quality is by default 75, you can set it to a quality between 0-100
$cropper->save('mynewumage.png', 50);
```

### Output image as BLOB

[](#output-image-as-blob)

You can also output the image as BLOB for saving it in your database or just outputting it directly.

```
echo $cropper->getData();
```

### Color png backgrounds

[](#color-png-backgrounds)

You can also set the background color of pngs (RGB)

```
// set the color
$color = [
    'r' => 150,
    'g' => 150,
    'b' => 150
];

$cropper->crop($width, $height, $color['r'], $color['g'], $color['b']);
```

Examples
--------

[](#examples)

### Save image

[](#save-image)

```
use SimpleImageCropper\Cropper;

$cropper = new Cropper('http://example.com/your-image.png');

// Crop the image by 200x200
$cropper->crop(200, 200);

// Save the image as mynewimage.png
$cropper->save('mynewimage.png');
```

### Output image (BLOB)

[](#output-image-blob)

```
// Set header
header('Content-Type: image/png');

use SimpleImageCropper\Cropper;

$cropper = new Cropper('http://example.com/your-image.png');

// Crop the image by 200x200 and output it.
echo $cropper->crop(200, 200)->getData();
```

### Resize image and keep the proportions

[](#resize-image-and-keep-the-proportions)

```
$cropper = new Cropper($_FILES['filename']['tmp_name']);

// Set the new width
$newWidth = 306;

// Check proportions
$proportion = $newWidth / $img->width;

// Set the new height
$newHeight = $img->height * $proportion;

// Crop the image by its new width and height
$cropper->crop($newWidth, $newHeight);

// Save the image with a 50% quality
$cropper->save('mynewimage.png', 50);
```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6029843?v=4)[Sami Wiktorin](/maintainers/sayme)[@sayme](https://github.com/sayme)

---

Top Contributors

[![sayme](https://avatars.githubusercontent.com/u/6029843?v=4)](https://github.com/sayme "sayme (22 commits)")

### Embed Badge

![Health badge](/badges/sayme-simple-image-cropper/health.svg)

```
[![Health](https://phpackages.com/badges/sayme-simple-image-cropper/health.svg)](https://phpackages.com/packages/sayme-simple-image-cropper)
```

###  Alternatives

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k22](/packages/bkwld-croppa)[char0n/ffmpeg-php

PHP wrapper for FFmpeg application

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

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

63991.3k4](/packages/netresearch-rte-ckeditor-image)

PHPackages © 2026

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