PHPackages                             trismegiste/phpunit-assert-picture - 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. trismegiste/phpunit-assert-picture

ActiveLibrary

trismegiste/phpunit-assert-picture
==================================

Useful assertions on pictures

00PHP

Since Oct 11Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Trismegiste/phpunit-assert-picture)[ Packagist](https://packagist.org/packages/trismegiste/phpunit-assert-picture)[ RSS](/packages/trismegiste-phpunit-assert-picture/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

phpunit-assert-picture
======================

[](#phpunit-assert-picture)

New PhpUnit Assertions for testing Pictures (size, type, text content...)

What
====

[](#what)

It's a set of Traits for adding new assertions on pictures

How
===

[](#how)

Add the library :

```
$ composer require --dev trismegiste/phpunit-assert-picture
```

Use the traits in your TestCase subclass :

```
class MyPictureTest extends \PHPUnit\Framework\TestCase
{
    use \Trismegiste\PhpunitAssertPicture\ImageSpecs;
    use \Trismegiste\PhpunitAssertPicture\TextContent;

    // ... your tests
```

Examples
========

[](#examples)

Here's a picture :

[![Sample](https://github.com/Trismegiste/phpunit-assert-picture/raw/master/tests/fixtures/sample.png)](https://github.com/Trismegiste/phpunit-assert-picture/blob/master/tests/fixtures/sample.png)

Image attributes
----------------

[](#image-attributes)

We can call assertions with the full pathname of the picture or with a \\GdImage instance :

```
   /** @dataProvider getFixture */
   public function testPicture(string $pic)
   {
       // assertions on width and height :
       $this->assertDimension(128, 256, $pic);
       // assetion on mime-type :
       $this->assertMimeType('image/png', $pic);
       // assertion on orientation mode :
       $this->assertPortrait($pic);
   }
```

Text contents
-------------

[](#text-contents)

Assertion on text content inside the picture thanks to OCR :

```
       $this->assertPictureContainsString('YOLO', $pic);
```

Dependencies
============

[](#dependencies)

- Tesseract
- GD2

Contribute
==========

[](#contribute)

Feel free to contribute with new fancy features

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/64cc99ca21a090b2454784670e4ac49db17794d6861078eeceebdbe302365c3f?d=identicon)[trismegiste](/maintainers/trismegiste)

---

Top Contributors

[![Trismegiste](https://avatars.githubusercontent.com/u/1260026?v=4)](https://github.com/Trismegiste "Trismegiste (9 commits)")

### Embed Badge

![Health badge](/badges/trismegiste-phpunit-assert-picture/health.svg)

```
[![Health](https://phpackages.com/badges/trismegiste-phpunit-assert-picture/health.svg)](https://phpackages.com/packages/trismegiste-phpunit-assert-picture)
```

PHPackages © 2026

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