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.99.3(1y ago)0591[1 issues](https://github.com/ajur-media/PHP_GDWrapper/issues)1MITPHPPHP ^7.4 | 8.\*

Since Apr 20Pushed 1y 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 1mo ago

READMEChangelog (10)Dependencies (2)Versions (14)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

32

—

LowBetter than 71% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

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

Recently: every ~4 days

Total

12

Last Release

602d ago

Major Versions

v0.9.2 → v1.0.02022-04-29

PHP version history (5 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.\*

### Community

Maintainers

![](https://www.gravatar.com/avatar/6d4a5bbb45fc701f595e17c74b94658126704ebc4eafb3fb1aa8bc613cdcbbbd?d=identicon)[KarelWintersky](/maintainers/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

[spatie/image-optimizer

Easily optimize images using PHP

2.9k71.3M109](/packages/spatie-image-optimizer)[danog/madelineproto

Async PHP client API for the telegram MTProto protocol.

3.4k855.0k18](/packages/danog-madelineproto)[ps/image-optimizer

Image optimization / compression library. This library is able to optimize png, jpg and gif files in very easy and handy way. It uses optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim and jpegtran tools.

9341.7M25](/packages/ps-image-optimizer)[jcupitt/vips

A high-level interface to the libvips image processing library.

6961.6M31](/packages/jcupitt-vips)[yireo/magento2-next-gen-images

Magento 2 module to add NextGen images support to the Magento frontend

471.1M2](/packages/yireo-magento2-next-gen-images)[godruoyi/ocr

The Best Image Ocr SDK For BAT.

19314.7k1](/packages/godruoyi-ocr)

PHPackages © 2026

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