PHPackages                             antey/image-slice - 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. antey/image-slice

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

antey/image-slice
=================

Library for slicing image into a pieces

1.0.1(3y ago)0341[1 PRs](https://github.com/a-kryvenko/php-image-slice/pulls)1MITPHPPHP &gt;=7.4

Since Dec 3Pushed 6mo ago2 watchersCompare

[ Source](https://github.com/a-kryvenko/php-image-slice)[ Packagist](https://packagist.org/packages/antey/image-slice)[ Docs](https://github.com/a-kryvenko/php-image-slice)[ RSS](/packages/antey-image-slice/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (3)Used By (1)

php-image-slice
===============

[](#php-image-slice)

PHP library to slice image into a pieces.

[![tests workflow](https://github.com/a-kryvenko/php-image-slice/actions/workflows/tests.yml/badge.svg)](https://github.com/a-kryvenko/php-image-slice/actions/workflows/tests.yml/badge.svg)[![Coverage Status](https://camo.githubusercontent.com/7147ccdaff1702a845c66abd48486755e2584c8e661262affeafc681bde8f444/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f612d6b727976656e6b6f2f7068702d696d6167652d736c6963652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/a-kryvenko/php-image-slice?branch=master)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)

---

 [![](https://private-user-images.githubusercontent.com/9430313/255326545-5ba49c73-049d-45c7-a392-5d00cef93c34.jpeg?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc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YXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjYwNDA0VDE0MDc1NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTcwNjI4ZWZhMWE5NDhmYzg5OWU0OWRmOTAyZmMwZGYwZjMxZjU2MzFkMDExNzNjMWIwZWUzMGNmM2QzMDRkYTYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.T0dBGm7B65S-Ffvc12bg-TO3eLlwB4fNZVItzP-QJtQ)

---

Setup
-----

[](#setup)

Via composer:

```
$ composer require antey/image-slice
```

Or by cloning repository

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

[](#requirements)

- PHP version: &gt;= 7.4;
- PHP extensions: gd.

Dependencies
------------

[](#dependencies)

- [php-image-resize](https://github.com/gumlet/php-image-resize)

Usage
-----

[](#usage)

There is two available slice types - slice horizontal and slice vertical. As constructor parameters for `HorizontalImageSlice` and `VerticalImageSlice`take width and height (in pixels) pieces, for what you wish to slice image.

### Horizontal slicing

[](#horizontal-slicing)

```
use Antey\ImageSlice\HorizontalImageSlice;

$imageSlice = new HorizontalImageSlice(100, 100);
$slices = $imageSlice->slice(__DIR__ . '/example.jpeg');
```

As result of this code, our source image will be sliced into several horizontal pieces and paths of this pieces will be returned.

### Vertical slicing

[](#vertical-slicing)

```
use Antey\ImageSlice\VerticalImageSlice;

$imageSlice = new VerticalImageSlice(100, 100);
$slices = $imageSlice->slice(__DIR__ . '/example.jpeg');
```

As result of this code, our source image will be sliced into several vertical pieces and paths of this pieces will be returned.

### Upscale

[](#upscale)

By default, in case when source image has lower resolution, than expected (for example, original image is 2000x500, and we want to get 1000x1000 pieces), result pieces will have height (or width, for `VerticalImageSlice`) same as source image, so we will get two 1000x500 slices.

If we wish to have strict size of pieces, we can allow upscale

```
$imageSlice->allowUpscale();
```

After that, in case of previous image, source image will be up-scaled to 4000x1000, and only after that sliced. As result, we will get four 1000x1000 slices.

### Last slice

[](#last-slice)

In most scenarios, original image cannot be sliced into pieces exactly. When we try to slice 2300x1000 image into 1000x1000 pieces, last part (300px) will be ignored.

But if we want to save this part also - then we need allow saving last piece:

```
$imageSlice->allowLastSlide();
```

As result, we will get three slides - two slides 1000x1000, and one slide 300x1000.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance47

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity47

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

Every ~0 days

Total

2

Last Release

1260d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b04ef163fa5e453b0bba91e7e97bb030870b78c8a03274045faf88974648513e?d=identicon)[a-kryvenko](/maintainers/a-kryvenko)

---

Top Contributors

[![a-kryvenko](https://avatars.githubusercontent.com/u/9430313?v=4)](https://github.com/a-kryvenko "a-kryvenko (41 commits)")

---

Tags

phpphpimagecutslicedivide

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/antey-image-slice/health.svg)

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

###  Alternatives

[yncki/php-fast-image-compare

Image Comparer with different aspect ratios and sizes. Can extract duplicate and unique images in directory and much more.

1869.4k](/packages/yncki-php-fast-image-compare)[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)
