PHPackages                             phpthumb/phpthumb - 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. phpthumb/phpthumb

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

phpthumb/phpthumb
=================

A fluent image manipulation library for PHP 8.2+ with interchangeable GD and Imagick backends.

2.5.0(1w ago)615.3k↓46.3%4[1 issues](https://github.com/PHPThumb/PHPThumb/issues)2MITPHPPHP &gt;=8.2CI passing

Since Jul 12Pushed 1w ago1 watchersCompare

[ Source](https://github.com/PHPThumb/PHPThumb)[ Packagist](https://packagist.org/packages/phpthumb/phpthumb)[ Docs](https://github.com/PHPThumb/PHPThumb)[ RSS](/packages/phpthumb-phpthumb/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (2)Versions (17)Used By (2)

PHP Thumb
=========

[](#php-thumb)

> **A lightweight, chainable image manipulation library for PHP**

PHP Thumb is a simple, modern image manipulation library aimed primarily at thumbnail generation. It provides a clean, fluent interface for common image operations, with **two interchangeable backends**: the ubiquitous **GD** extension and the more feature-rich **Imagick** extension.

---

Table of Contents
-----------------

[](#table-of-contents)

- [What's New in 2.5](#whats-new-in-25)
- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Choosing a Backend: GD vs Imagick](#choosing-a-backend-gd-vs-imagick)
- [Supported Formats](#supported-formats)
- [Core API](#core-api)
    - [Resize Operations](#resize-operations)
    - [Crop Operations](#crop-operations)
    - [Rotate &amp; Filter](#rotate--filter)
    - [Pad](#pad)
    - [Orientation](#orientation)
    - [Flip](#flip)
    - [Sharpen](#sharpen)
    - [Gamma Correction](#gamma-correction)
    - [Border](#border)
    - [Text Overlay](#text-overlay)
    - [Advanced Filters](#advanced-filters)
    - [Output](#output)
- [Plugins](#plugins)
- [Configuration Options](#configuration-options)
- [Examples](#examples)
- [Documentation](#documentation)
- [Testing](#testing)
- [Contributing](#contributing)
- [License](#license)

---

What's New in 2.5
-----------------

[](#whats-new-in-25)

PHPThumb 2.5 is a **feature expansion** release — every manipulation method still returns `$this` for chaining, and the API stays unified across the GD and Imagick backends. New capabilities:

FeatureOne-liner`autoOrient()`Auto-rotate phone photos based on EXIF orientation`flip()`Mirror horizontally, vertically, or both`gamma()`Lighten/darken with output gamma`sharpen()`Unsharp-mask style sharpening`border()`Add a solid-color frame of any thickness`text()`Render text with font (auto-resolved via fontconfig), color, size, shadow, stroke, background, multi-line alignment, and 9-grid positioning**Advanced filter wrappers**`grayscale()`, `brightness()`, `contrast()`, `blur()`, `pixelate()`, `edgeDetect()`, `emboss()`, `smooth()` — chainable convenience wrappers around `imageFilter()`All new methods are available on **both** backends. See the dedicated sections below for full documentation.

**Migration notes for 2.4 → 2.5:**

- The default options array now includes three additional keys: `sharpenAmount`, `textFont`, `textDefaultSize`. Existing code that compares `getOptions()` output byte-for-byte (i.e. test assertions) will need to be updated to include the new keys.
- No public method signatures were changed. No methods were renamed or removed.

---

Features
--------

[](#features)

### Core image operations

[](#core-image-operations)

- **Two interchangeable backends** — Use `PHPThumb\GD` (built on PHP's GD extension) or `PHPThumb\Imagick` (built on the PECL Imagick extension). Same API, switch with one `use` statement.
- **Fluent chaining API** — Perform multiple manipulations on a single instance
- **Flexible resizing** — By width, height, percentage, or adaptive (with crop)
- **Crop operations** — From-center, quadrant-based, percentage-based, or vanilla x/y cropping
- **Rotation** — 90° clockwise/counter-clockwise or arbitrary degrees
- **Remote image support** — Load images from URLs as well as local files

### Image correction &amp; enhancement

[](#image-correction--enhancement)

- **EXIF auto-orientation** — Correct phone-photo rotation based on embedded EXIF tags
- **Flip / mirror** — Horizontal, vertical, or both axes
- **Sharpen** — One-call unsharp-mask sharpening
- **Gamma correction** — Adjust output gamma to brighten or darken
- **Filters** — Chainable wrappers (`grayscale`, `brightness`, `contrast`, `blur`, `pixelate`, `edgeDetect`, `emboss`, `smooth`) for the common cases, plus a low-level `imageFilter()` escape hatch for any backend-native filter constant.

### Text &amp; decoration

[](#text--decoration)

- **Text overlay / captioning** — Render text with font (auto-resolved via fontconfig on Linux/macOS), color, size, multi-line alignment (`align`), per-line spacing (`lineHeight`), shadow, stroke, and background pill
- **Border / frame** — Solid-color border around the image

### Extensibility &amp; integration

[](#extensibility--integration)

- **Plugin system** — Extend the library with custom manipulations (Reflection, Trim, Watermark included). Plugins transparently dispatch to the correct backend.
- **Modern PHP 8.2+** — Strict types, enums where appropriate, modern syntax
- **Composer-ready** — PSR-4 autoloading and Composer integration out of the box

---

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

[](#requirements)

- **PHP 8.2** or higher
- At least one of:
    - **GD** extension (&gt;= 2.3.2)
    - **Imagick** extension (&gt;= 3.7.0; required for BMP, HEIC, TIFF, and other Imagick-only formats)
- **Composer** (recommended for installation)

The library auto-detects format support at runtime — an exception is thrown if your environment cannot handle the loaded file.

---

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

[](#installation)

Install via Composer:

```
composer require phpthumb/phpthumb
```

Then autoload in your project:

```
require_once 'vendor/autoload.php';
```

### Manual Installation

[](#manual-installation)

If you prefer not to use Composer, clone the repository and include the files manually:

```
git clone https://github.com/PHPThumb/PHPThumb.git
```

Then include the autoloader or files manually — but **Composer is strongly recommended**.

---

Quick Start
-----------

[](#quick-start)

```
