PHPackages                             sivka/img-5 - 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. sivka/img-5

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

sivka/img-5
===========

v1.0.1(7y ago)06MITPHP

Since Feb 10Pushed 7y agoCompare

[ Source](https://github.com/alexSivka/Img-5)[ Packagist](https://packagist.org/packages/sivka/img-5)[ RSS](/packages/sivka-img-5/feed)WikiDiscussions master Synced yesterday

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

Image library
=============

[](#image-library)

This library is provided for resize, watermark images on fly. Works with php 5.0 or higher.

Result images will be cached, so converting is made only one time, if source or converted images are not modified.

This is legacy variant without namespaces for compatibility to older php versions.

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

[](#requirements)

- PHP 5.0+
- [GD extension](http://php.net/manual/en/book.image.php)

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

[](#installation)

```
composer require sivka/img-5

```

Or [Download](https://github.com/alexSivka/Img-5/releases) zip package and unzip anywhere to your project.

### Example

[](#example)

```
$params = array(
    'width' => 100,
    'height' => 150,
    'crop' => false,
    'watermark' => '',
    'wm_position' => 'center',
    'wm_opacity' => 0.6,
    'quality' => 80,
    'wm_text' => '',
    'wm_text_color' => '#FFFFFF',
    'wm_text_size' => 64,
    'wm_text_font' => 'arial.ttf',
    'default' => ''
);
require_once 'Img/Img.php';

//without setting cache directory
$src = Img::get('path/to/file.jpg', $params));

$src = Img::get('path/to/file.jpg', array('width' => 100, 'height' => 150)));
//returns /path/to/thumbs/100x150/file.jpg

//or simple
$src = Img::get('path/to/file.jpg', $width, [$height, [$crop]]);
$src = Img::get('path/to/file.jpg', 100, 100, true);
//returns /path/to/thumbs/100x100cp/file.jpg

//with setting cache directory
Img::setCacheDirectory('cache');
$src = Img::get('path/to/file.jpg', 100, 100, true);
//returns /cache/path/to/thumbs/100x100cp/file.jpg
```

### Parameters

[](#parameters)

```
number width - with to resize
number height - height to resize
mixed crop - boolean or number(1/0) or string with crop position center|top|left|//bottom|right|top left|top right|bottom left|bottom right

string watermark - path to watermark file_ext

string wm_position - watermark position center|top|left|bottom|right|top|left|top right|bottom left|bottom right

float wm_opacity - opacity of watermar or watermark text

number quality - quality for result images

string wm_text - text for overlay on images

mixed wm_text_color - color of watermark text, maybe string('#FFFFFF')
or array ['r'=>255,'g'=>255, 'b'=> 255, 'a'=>1] or array [255, 255, 255, 1]

number wm_text_size - font size of watermark text

string wm_text_font - name of font for watermark text, the font file mast be in same directory with Img.php

string default - path to placeholder, if defined and source image does not exists, this file will be converted

```

### methods

[](#methods)

```
static get($filepath, $params);
static get($filepath, $width, [$height, [$crop]]);
convert image and returns relative path to converted images

static setCacheDirectory($path);
sets path to cache directory

static setDocRoot($docRoot);
set DOCUMENT_ROOT, use this if $_SERVER['DOCUMENT_ROOT'] is not real absolute path to home directory

static setPlaceholder($filepath);
set path to placeholder image. If source image does not exists, path to placeholder will be returned.
```

Built With
----------

[](#built-with)

- [Cory LaViska SimpleImage](https://github.com/claviska/SimpleImage)

Authors
-------

[](#authors)

- **AlexSivka** - *Initial work* - [AlexSivka](https://github.com/alexSivka/)

License
-------

[](#license)

This project is licensed under the [MIT License](LICENSE.md)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 71.4% 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

2649d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7dc958a70db32d72289e88ededd1374bf3e9a6da7f9fc5afcb55236a20961363?d=identicon)[alexSivka](/maintainers/alexSivka)

---

Top Contributors

[![alexSivka](https://avatars.githubusercontent.com/u/32399997?v=4)](https://github.com/alexSivka "alexSivka (5 commits)")[![alex-sivka](https://avatars.githubusercontent.com/u/30624922?v=4)](https://github.com/alex-sivka "alex-sivka (2 commits)")

### Embed Badge

![Health badge](/badges/sivka-img-5/health.svg)

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

###  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.0k23](/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)
