PHPackages                             carlosafonso/thumbnailr - 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. carlosafonso/thumbnailr

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

carlosafonso/thumbnailr
=======================

A PHP library for dynamically generating image thumbnails

2.0.0(11y ago)7901[1 PRs](https://github.com/carlosafonso/thumbnailr/pulls)PHPPHP &gt;= 5.3.0

Since Apr 3Pushed 8y ago3 watchersCompare

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

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

thumbnailr
==========

[](#thumbnailr)

Thumbnailr is a PHP library for dynamically generating image thumbnails in either PNG or JPEG format.

\##Installation Thumbnailr is available via Composer. Add a reference to Thumbnailr in your `composer.json` file;

```
{
  "require": {
    "carlosafonso/thumbnailr": "2.*"
  }
}
```

Then fire up a terminal and run the following wherever your `composer.json` file is located:

```
$ composer install
```

\##Usage example

```
// the path to the source image
$img = 'path/to/image.png';

// the thumbnail's dimensions
$width = 200;
$height = 100;

// instantiate the library
$thumbnailr = new \Thumbnailr\Thumbnailr($img);

/*
 * Generating the thumbnail
 */
// this will not keep the aspect ratio (both calls are equivalent)
$thumbnailr->buildThumbnail($width, $height);
$thumbnailr->buildThumbnail($width, $height, self::SIZE_FIXED);

// keep the aspect ratio and fit the LONGEST side inside the thumbnail,
// (actual size will be smaller than specified)
$thumbnailr->buildThumbnail($width, $height, self::SIZE_FIT_LONGEST);

// keep the aspect ratio and fit the SHORTEST side inside the thumbnail size,
// (actual size will be larger than specified)
$thumbnailr->buildThumbnail($width, $height, self::SIZE_FIT_SHORTEST);

/*
 * Saving the thumbnail
 */
// save to a PNG file, apply standard compression
$thumbnailr->toPngFile('thumbnail.png');

// same as above specifying a compression level (higher level means smaller file size)
$thumbnailr->toPngFile('thumbnail.png', 7);

// get the thumbnail as raw binary data
$raw_png = $thumbnailr->toPngFile(NULL);

// get the PNG thumbnail as a base 64 string, apply standard compression
$png_b64 = $thumbnailr->toPngBase64();

// same as above specifying a compression level
$png_b64 = $thumbnailr->toPngBase64(4);

// save to a JPEG file, use standard quality
$thumbnailr->toJpegFile('thumbnail.jpg');

// same as above specifying a quality value (higher quality means larger file size)
$thumbnailr->toJpegFile('thumbnail.jpg', 80);

// get the JPEG thumbnail as a base 64 string, use standard quality
$jpeg_b64 = $thumbnailr->toJpegBase64();

// same as the above specifying a quality value
$jpeg_b64 = $thumbnailr->toJpegBase64(40);
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

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

Total

2

Last Release

4111d ago

Major Versions

1.1.0 → 2.0.02015-03-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/298322ba620ba6518bce36e896723f1f771c4ee6257ab49548c45dcb06e2b9ce?d=identicon)[carlosafonso](/maintainers/carlosafonso)

---

Top Contributors

[![carlosafonso](https://avatars.githubusercontent.com/u/1700229?v=4)](https://github.com/carlosafonso "carlosafonso (10 commits)")

### Embed Badge

![Health badge](/badges/carlosafonso-thumbnailr/health.svg)

```
[![Health](https://phpackages.com/badges/carlosafonso-thumbnailr/health.svg)](https://phpackages.com/packages/carlosafonso-thumbnailr)
```

###  Alternatives

[goat1000/svggraph

Generates SVG graphs

133890.0k3](/packages/goat1000-svggraph)[imagekit/imagekit

PHP library for Imagekit

46877.3k10](/packages/imagekit-imagekit)[gravatarphp/gravatar

Gravatar URL builder which is most commonly called as a Gravatar library

12644.1k2](/packages/gravatarphp-gravatar)

PHPackages © 2026

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