PHPackages                             ajur-media/php\_gdwrapper - 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. ajur-media/php\_gdwrapper

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

ajur-media/php\_gdwrapper
=========================

Wrapper over GD

1.100.0(3mo ago)0604[1 issues](https://github.com/ajur-media/PHP_GDWrapper/issues)1MITPHPPHP ^8.2

Since Apr 20Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/ajur-media/PHP_GDWrapper)[ Packagist](https://packagist.org/packages/ajur-media/php_gdwrapper)[ RSS](/packages/ajur-media-php-gdwrapper/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (4)Versions (15)Used By (1)

PHP\_GDWrapper
==============

[](#php_gdwrapper)

Init
----

[](#init)

```
GDWrapper::init($options = [], $logger = null)

```

- `$options` - Опции передаются через ассоциативный массив (пустой массив означает опции по умолчанию)
    - `JPEG_COMPRESSION_QUALITY` - уровень сжатия оригинальных JPEG-ов, \[1..100\], по умолчанию - 92.
    - `WEBP_COMPRESSION_QUALITY` - уровень сжатия WEBP, \[1..100\], по умолчанию 80.
    - `PNG_COMPRESSION_QUALITY` - уровень сжатия PNG \[0..9\], по умолчанию 0 (без сжатия)
- `$logger` - логгер, реализующий интерфейс `Psr\Log\LoggerInterface`, например `Monolog` или `Arris\AppLogger::scope()` ИЛИ **null**

Используется один уровень логгирования - error - если обрабатываемый файл не существует.

Пример инициализации:

```
use AJUR\Wrappers;
use Arris\AppLogger;

AppLogger::addScope('gdwrapper', [ 'gd_error.log' , Logger::ERROR, 'enabled' => getenv('LOGGING.GDWRAPPER_ERRORS'));

GDWrapper::init([], AppLogger::scope('gdwrapper'));

```

GDImageInfo
-----------

[](#gdimageinfo)

Все методы `GDWrapper` возвращают экземпляр класса GDImageInfo, содержащий информацию о результирующем изображении:

```
{
  "valid":true,
  "error_message":"",
  "width":200,
  "height":135,
  "type":2,
  "mime":"image\/jpeg",
  "mime_extension":".jpeg",
  "filename":"test_RIA.jpg",
  "extension":"jpg",
  "quality":40,
  "data":null
}
```

- `extension` - расширение, определенное на основании filename (без точки)
- `mime` - mime-тип файла
- `mime_extension` - расширение, определенное на основании mime-типа (с точкой)
- `quality` - качество сжатия изображения
- `type` - тип, см константы IMAGETYPE\_BMP, IMAGETYPE\_PNG, IMAGETYPE\_JPEG, IMAGETYPE\_GIF, IMAGETYPE\_WEBP
- `valid` - успешность последней обработки (например, загрузки изображения из файла)
- `error_message` - сообщение об ошибке

Важно: этот класс НЕ КИДАЕТ исключения.

Методы GDWrapper
----------------

[](#методы-gdwrapper)

### cropImage(string $fn\_source, string $fn\_target, array $xy\_source, array $wh\_dest, array $wh\_source, $quality = null):GDImageInfo

[](#cropimagestring-fn_source-string-fn_target-array-xy_source-array-wh_dest-array-wh_source-quality--nullgdimageinfo)

CROP изображения с сохранением в файл

### resizeImageAspect(string $fn\_source, string $fn\_target, int $maxwidth, int $maxheight, $image\_quality = null):GDImageInfo

[](#resizeimageaspectstring-fn_source-string-fn_target-int-maxwidth-int-maxheight-image_quality--nullgdimageinfo)

вписывает изображение в указанные размеры

### resizePictureAspect(string $fn\_source, string $fn\_target, int $maxwidth, int $maxheight, $image\_quality = null):GDImageInfo

[](#resizepictureaspectstring-fn_source-string-fn_target-int-maxwidth-int-maxheight-image_quality--nullgdimageinfo)

Ресайзит картинку по большей из сторон

### verticalImage(string $fn\_source, string $fn\_target, int $maxwidth, int $maxheight, $image\_quality = null):GDImageInfo

[](#verticalimagestring-fn_source-string-fn_target-int-maxwidth-int-maxheight-image_quality--nullgdimageinfo)

???

### getFixedPicture(string $fn\_source, string $fn\_target, int $maxwidth, int $maxheight, int $image\_quality = null):GDImageInfo

[](#getfixedpicturestring-fn_source-string-fn_target-int-maxwidth-int-maxheight-int-image_quality--nullgdimageinfo)

Ресайзит картинку в фиксированные размеры

### addWaterMark(string $fn\_source, array $params, int $pos\_index, $quality = null, string $fn\_target = ''):GDImageInfo

[](#addwatermarkstring-fn_source-array-params-int-pos_index-quality--null-string-fn_target--gdimageinfo)

Добавляет на изображение вотермарк

- `$fn_source` - файл изображения (будет заменён)
- `$params` - массив из двух опций \[ 'watermark' =&gt; имя файла, 'margin' =&gt; отступ\]
- `$pos_index` - позиция WM\_POSITION\_LEFT\_TOP = 1, WM\_POSITION\_RIGHT\_TOP = 2, WM\_POSITION\_RIGHT\_BOTTOM = 3 , WM\_POSITION\_LEFT\_BOTTOM = 4
- `$quality` - качество изображения при сохранении
- `$fn_target` - целевой файл, если он указан - то `$fn_source` не будет перезаписан

### rotate(string $fn\_source, string $roll\_direction = "", $quality = null):GDImageInfo

[](#rotatestring-fn_source-string-roll_direction---quality--nullgdimageinfo)

TODO

### rotate2(string $fn\_source, string $roll\_direction = "", $quality = null):GDImageInfo

[](#rotate2string-fn_source-string-roll_direction---quality--nullgdimageinfo)

Враппер над rotate(), под таким именем используется на 47news, должно быть удалено отсюда и из 47news с заменой на Rotate

### flip(string $fn\_source, int $mode, $quality = null, string $fn\_target = ''):GDImageInfo

[](#flipstring-fn_source-int-mode-quality--null-string-fn_target--gdimageinfo)

Переворачивает изображение, используя выбранный режим:

- `$fn_source`
- `$mode` - Режим переворота - одна из констант IMG\_FLIP\_\*:
    - IMG\_FLIP\_HORIZONTAL Переворачивает изображение по горизонтали.
    - IMG\_FLIP\_VERTICAL Переворачивает изображение по вертикали.
    - IMG\_FLIP\_BOTH Переворачивает изображение и по горизонтали и по вертикали.

### imageFillColor(string $fn\_target, int $width, int $height, array $color, $quality = null):GDImageInfo;

[](#imagefillcolorstring-fn_target-int-width-int-height-array-color-quality--nullgdimageinfo)

TODO

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance82

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity69

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

Recently: every ~143 days

Total

13

Last Release

91d ago

Major Versions

v0.9.2 → v1.0.02022-04-29

PHP version history (6 changes)v0.9.0PHP ^7.3

v1.2.2PHP ^7.3|&gt;=8

1.3.0PHP ^7.4

1.99.0PHP 7.4 | 8.\*

1.99.1PHP ^7.4 | 8.\*

1.100.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2164874?v=4)[Karel Wintersky](/maintainers/KarelWintersky)[@KarelWintersky](https://github.com/KarelWintersky)

---

Top Contributors

[![KarelWintersky](https://avatars.githubusercontent.com/u/2164874?v=4)](https://github.com/KarelWintersky "KarelWintersky (18 commits)")

###  Code Quality

Static AnalysisRector

### Embed Badge

![Health badge](/badges/ajur-media-php-gdwrapper/health.svg)

```
[![Health](https://phpackages.com/badges/ajur-media-php-gdwrapper/health.svg)](https://phpackages.com/packages/ajur-media-php-gdwrapper)
```

###  Alternatives

[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k365.0M3.1k](/packages/symfony-cache)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[danog/madelineproto

Async PHP client API for the telegram MTProto protocol.

3.4k885.1k22](/packages/danog-madelineproto)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

562565.8k42](/packages/ecotone-ecotone)[web-auth/webauthn-lib

FIDO2/Webauthn Support For PHP

1237.8M120](/packages/web-auth-webauthn-lib)

PHPackages © 2026

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